From jim@REDACTED Tue May 1 00:49:17 2007 From: jim@REDACTED (Jim Thompson) Date: Mon, 30 Apr 2007 12:49:17 -1000 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 Message-ID: <4636726D.3090108@netgate.com> I'm interested in discussing what it would take to get MIPS/MIPS-64 support into HiPE. HiPE already supports SPARC (32 & 64bit), PPC (32 & 64 bit) and x86 (as well as x86-64). I've read that the internal RLT for HiPE looks a lot like the MIPS instruction set. Is it just a matter of defining (or re-using) the ABI for the platform, and then writing the 'glue' for plugging the binary, or is it much, much more complex that that? Yes, this is with an Octeon chipset in-mind (16 cores, discussed on-list last August), seems like an ideal 1U Erlang box to me. Also, why no SPARC-on-Intel support for HiPE? Jim From toby@REDACTED Tue May 1 01:17:35 2007 From: toby@REDACTED (Toby Thain) Date: Mon, 30 Apr 2007 20:17:35 -0300 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 In-Reply-To: <4636726D.3090108@netgate.com> References: <4636726D.3090108@netgate.com> Message-ID: > > Also, why no SPARC-on-Intel support for HiPE? What is "SPARC-on-Intel"? --Toby > > Jim > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jim@REDACTED Tue May 1 01:19:44 2007 From: jim@REDACTED (Jim Thompson) Date: Mon, 30 Apr 2007 13:19:44 -1000 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 In-Reply-To: References: <4636726D.3090108@netgate.com> Message-ID: <46367990.2050203@netgate.com> Toby Thain wrote: >> >> Also, why no SPARC-on-Intel support for HiPE? > > What is "SPARC-on-Intel"? Sorry. "Solaris on Intel". From bob@REDACTED Tue May 1 05:06:38 2007 From: bob@REDACTED (Bob Ippolito) Date: Mon, 30 Apr 2007 20:06:38 -0700 Subject: [erlang-questions] edoc and parameterized modules in R11B-4 Message-ID: <6a36e7290704302006g75d1b942jb747bb1d2625b987@mail.gmail.com> I've noticed that edoc (as of R11B-4) crashes when trying to parse a parameterized module. Apparently the name of a module is {Name, [Var]} instead of just Name when the module is parameterized, so it gets awfully confused when it tries to list_to_atom it :) I've attached a simple workaround that is enough to get it to work, though it doesn't do anything fancy (e.g. prefix all of the functions with "Mod:" and add a "pretty" declaration of new/N). -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: edoc_parameterized_modules-R11B-4-r1.diff Type: application/octet-stream Size: 1878 bytes Desc: not available URL: From toby@REDACTED Tue May 1 05:20:57 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 1 May 2007 00:20:57 -0300 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 In-Reply-To: <46367990.2050203@netgate.com> References: <4636726D.3090108@netgate.com> <46367990.2050203@netgate.com> Message-ID: <53D5EBFE-F792-42A9-B6E1-86461E8F6C9B@smartgames.ca> On 30-Apr-07, at 8:19 PM, Jim Thompson wrote: > Toby Thain wrote: >>> >>> Also, why no SPARC-on-Intel support for HiPE? >> What is "SPARC-on-Intel"? > > Sorry. "Solaris on Intel". > I thought so, just making sure. Can't speak for HiPE, but my undemanding applications (ejabberd) run nicely with the standard emulator on Solaris 10, amd64. --Toby From pat.eyler@REDACTED Tue May 1 05:39:50 2007 From: pat.eyler@REDACTED (pat eyler) Date: Mon, 30 Apr 2007 21:39:50 -0600 Subject: [erlang-questions] erlang users in Utah? Message-ID: <6fd0654b0704302039v6ce307beh3249bfa4b742385b@mail.gmail.com> Anyone up for getting together in May for some introductory Erlang hacking? Several of us from the UtahValley.rb are looking to get together monthly to go over the new Programming Erlang book from the prags. -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com From sflist@REDACTED Tue May 1 05:52:23 2007 From: sflist@REDACTED (Steve Freitas) Date: Mon, 30 Apr 2007 20:52:23 -0700 Subject: [erlang-questions] erlang users in Utah? In-Reply-To: <6fd0654b0704302039v6ce307beh3249bfa4b742385b@mail.gmail.com> References: <6fd0654b0704302039v6ce307beh3249bfa4b742385b@mail.gmail.com> Message-ID: <1177991543.4528.50.camel@lothar> On Mon, 2007-04-30 at 21:39 -0600, pat eyler wrote: > Anyone up for getting together in May for some introductory > Erlang hacking? Several of us from the UtahValley.rb are > looking to get together monthly to go over the new > Programming Erlang book from the prags. Sure, I'll be in Provo from the 4th through the 12th, if that works. I've been meaning to start with the language for a while now -- the peer pressure would help me make the time, so do let me know. Thanks, Steve From pat.eyler@REDACTED Tue May 1 06:00:41 2007 From: pat.eyler@REDACTED (pat eyler) Date: Mon, 30 Apr 2007 22:00:41 -0600 Subject: [erlang-questions] erlang users in Utah? In-Reply-To: <1177991543.4528.50.camel@lothar> References: <6fd0654b0704302039v6ce307beh3249bfa4b742385b@mail.gmail.com> <1177991543.4528.50.camel@lothar> Message-ID: <6fd0654b0704302100j5de7ef0anf37d1ec817daaa59@mail.gmail.com> On 4/30/07, Steve Freitas wrote: > On Mon, 2007-04-30 at 21:39 -0600, pat eyler wrote: > > Anyone up for getting together in May for some introductory > > Erlang hacking? Several of us from the UtahValley.rb are > > looking to get together monthly to go over the new > > Programming Erlang book from the prags. > > Sure, I'll be in Provo from the 4th through the 12th, if that works. > I've been meaning to start with the language for a while now -- the peer > pressure would help me make the time, so do let me know. We were looking at doing it on the third Tuesdays, but I'll ask if there's any interest in making a change to the second Tuesday this month. > > Thanks, > > Steve > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com From ok@REDACTED Tue May 1 06:10:18 2007 From: ok@REDACTED (ok) Date: Tue, 1 May 2007 16:10:18 +1200 Subject: [erlang-questions] per function/process locals In-Reply-To: References: Message-ID: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> On 1 May 2007, at 3:35 am, James Hague basically suggested - the long-known technique of mapping an imperative style (without _shared_ mutable subvariables) to a functional style by setting up a one-to-one correspondence between mutable variables and function arguments - using some kind of preprocessor or language extension to make it easier to get this kind of code right Similar extensions to Prolog have often been suggested. Speaking only for myself, I find that it is a rare algorithm where I need more than a handful of "variables" in a loop, and I would regard the presence of a sufficient number to be painful as indicative of bad design on my part rather than inadequacy on Erlang's (or Prolog's) part. However, see Mercury, where they've provided imperative-looking record update. I'd rather have the let-for-then construct. From sflist@REDACTED Tue May 1 06:33:13 2007 From: sflist@REDACTED (Steve Freitas) Date: Mon, 30 Apr 2007 21:33:13 -0700 Subject: [erlang-questions] erlang users in Utah? In-Reply-To: <6fd0654b0704302100j5de7ef0anf37d1ec817daaa59@mail.gmail.com> References: <6fd0654b0704302039v6ce307beh3249bfa4b742385b@mail.gmail.com> <1177991543.4528.50.camel@lothar> <6fd0654b0704302100j5de7ef0anf37d1ec817daaa59@mail.gmail.com> Message-ID: <1177993993.4528.56.camel@lothar> On Mon, 2007-04-30 at 22:00 -0600, pat eyler wrote: > We were looking at doing it on the third Tuesdays, but I'll ask > if there's any interest in making a change to the second Tuesday > this month. I hate to wag the dog, but if you can make the change, I'll be there. Steve From kostis@REDACTED Tue May 1 08:48:31 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 01 May 2007 08:48:31 +0200 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 In-Reply-To: <4636726D.3090108@netgate.com> References: <4636726D.3090108@netgate.com> Message-ID: <4636E2BF.1040507@cs.ntua.gr> Jim Thompson wrote: > I'm interested in discussing what it would take to get MIPS/MIPS-64 > support into HiPE. HiPE already supports SPARC (32 & 64bit), PPC (32 & > 64 bit) and x86 (as well as x86-64). Pretty correct. However, HiPE does not have a PPC 64 bit port (we started one but we never got access to a machine, so the port never finished). > I've read that the internal RLT for HiPE looks a lot like the MIPS > instruction set. Again pretty correct. However RLT --> RTL (Register Transfer Language). > Is it just a matter of defining (or re-using) the ABI for the platform, > and then writing the 'glue' for plugging the binary, or is it much, much > more complex that that? As far as we are concerned, it's mainly a matter of getting access to a machine and prioritizing this task. Your plan seems correct though. Somebody has to encode the ABI in Erlang and then write the RTL -> MIPS translator. Given access to a machine it should be a matter of about a month to do this port. > Yes, this is with an Octeon chipset in-mind (16 cores, discussed on-list > last August), seems like an ideal 1U Erlang box to me. > > Also, why no SPARC-on-Intel support for HiPE? I do not know of any problem of our Solaris on Intel support. It should be working. > Jim Kostis From tim@REDACTED Tue May 1 10:53:58 2007 From: tim@REDACTED (Tim Bates) Date: Tue, 01 May 2007 18:23:58 +0930 Subject: [erlang-questions] Testing with EUnit In-Reply-To: <17972.61171.982277.549789@antilipe.corelatus.se> References: <17972.61171.982277.549789@antilipe.corelatus.se> Message-ID: <46370026.6080606@bates.id.au> Matthias Lang wrote: > Note the "-s init stop". > > You could also use Escript, but that's bleeding edge. EUnit also has other problems when run from Escript, as detailed in my earlier mail which nobody has replied to. Can I please draw people's attention to it again? http://www.erlang.org/pipermail/erlang-questions/2007-April/026233.html Thanks, Tim. -- Tim Bates tim@REDACTED From mikpe@REDACTED Tue May 1 13:38:40 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Tue, 1 May 2007 13:38:40 +0200 (MEST) Subject: [erlang-questions] HiPE on MIPS/MIPS-64 Message-ID: <200705011138.l41BceOO006020@harpo.it.uu.se> On Mon, 30 Apr 2007 12:49:17 -1000, Jim Thompson wrote: > I'm interested in discussing what it would take to get MIPS/MIPS-64 > support into HiPE. HiPE already supports SPARC (32 & 64bit), PPC (32 & > 64 bit) and x86 (as well as x86-64). HiPE doesn't support SPARC64 or PPC64 user-mode; it does support SPARC32 and PPC32 user-mode on both 32- and 64-bit kernels. A PPC64 project was started but never completed due to us not having a PPC64 machine. It would be easy to complete, though. HiPE also supports XScale, Intel's ARM processor. > I've read that the internal RLT for HiPE looks a lot like the MIPS > instruction set. > > Is it just a matter of defining (or re-using) the ABI for the platform, > and then writing the 'glue' for plugging the binary, or is it much, much > more complex that that? I had a look at supporting MIPS in HiPE last year, and from what I remember, it would be straightforward except for a few issues: - MIPS has no condition codes. This makes overflow in arithmetic difficult to detect. I'm not sure if this can be hidden completely in the backend or if it will need some hooks in RTL. - MIPS partitions the memory into 256MB regions, and direct branches can only reach targets in the same region. The consequence is that branches between regions must be routed via trampolines containing indirect jumps. HiPE already uses trampolines on PPC32 and ARM, so this is doable. It does add complexity to the runtime system and the code loader, however. - If hardware floating-point is to be used, then you'll need to first port the base BEAM runtime system to use floating-point exceptions. > Yes, this is with an Octeon chipset in-mind (16 cores, discussed on-list > last August), seems like an ideal 1U Erlang box to me. > > Also, why no SPARC-on-Intel support for HiPE? s/SPARC/Solaris/ HiPE worked just fine on Solaris/x86 and Solaris/amd64 last time I checked. /Mikael From jim@REDACTED Tue May 1 15:09:50 2007 From: jim@REDACTED (Jim Thompson) Date: Tue, 01 May 2007 03:09:50 -1000 Subject: [erlang-questions] HiPE on MIPS/MIPS-64 In-Reply-To: <200705011138.l41BceOO006020@harpo.it.uu.se> References: <200705011138.l41BceOO006020@harpo.it.uu.se> Message-ID: <46373C1E.80406@netgate.com> Mikael Pettersson wrote: > I had a look at supporting MIPS in HiPE last year, and from what I remember, > it would be straightforward except for a few issues: > - MIPS has no condition codes. This makes overflow in arithmetic difficult > to detect. I'm not sure if this can be hidden completely in the backend > or if it will need some hooks in RTL. Well, 'addu' is silent on overflow, but 'add' will cause a trap on overflow. The same applies for 'addiu' .vs 'addi', etc, but traps are expensive. However, I think the code is straight-forward. For add: addu t0, t1, t2 /* compute sum */ xor t3, t1, t2 /* if operands have opposite signs */ bltz t3, no_ovf /* then overflow is not possible /* operands have same sign */ xor t3, t0, t1 /* if sum does not have same sign */ bltz t3, do_sat /* then add overflowed */ nop no_ovf: ret do_sat: /* we know overflow has occurred, and we know both operands have the same sign, so we look at the sign of an operand. If its positive, we limit (saturate) to positive full scale. If its negative, we saturate negative full-scale */ li v0, 0x7fffffff /* positive full scale */ li t8, 0x80000000 /* negative full scale */ slt $1, $0, t1 /* check sign of operand */ movn v0, t8, $1 /* saturate */ ret signaling this to the back-end is still 'mystery meat' to me, since I don't know that much about HiPE. You don't need to worry about (integer) multiplies/divides on MIPS, because all multiplies are 32 bits x 32 bits and the destination register is always a special-purpose 64 bit register. > - MIPS partitions the memory into 256MB regions, and direct branches can > only reach targets in the same region. The consequence is that branches > between regions must be routed via trampolines containing indirect jumps. The branch instructions can only access 18 bits of offset (+/- 128KB). The jump instructions are limited to a given 256MB region. The jump-register instructions are how you get around this limitation, given my understanding. > HiPE already uses trampolines on PPC32 and ARM, so this is doable. It > does add complexity to the runtime system and the code loader, however. > - If hardware floating-point is to be used, then you'll need to first > port the base BEAM runtime system to use floating-point exceptions. > HiPE worked just fine on Solaris/x86 and Solaris/amd64 > last time I checked. My mistake. From Martin.Logan@REDACTED Tue May 1 16:29:00 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Tue, 1 May 2007 09:29:00 -0500 Subject: [erlang-questions] Edoc Error Message-ID: %% @spec install(Repos, AppName, AppVsn, InstallationPath) -> ok | {error, Reason} %% where %% Repos = string() %% AppName = string() %% AppVsn = string() | 'LATEST' | "LATEST" The "LATEST" string causes the following error. /home/martinjlogan/work/faxien/lib/faxien/src/fax_install.erl, function install/5: at line 37: syntax error before: "LATEST" edoc: skipping source file '/home/martinjlogan/work/faxien/lib/faxien/src/fax_install.erl': {'EXIT',error}. Looks like a bug. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From pat.eyler@REDACTED Tue May 1 17:10:32 2007 From: pat.eyler@REDACTED (pat eyler) Date: Tue, 1 May 2007 09:10:32 -0600 Subject: [erlang-questions] Erlounge in Provo, Utah May 8th Message-ID: <6fd0654b0705010810w74b4a8d6p2aa1057e97daba67@mail.gmail.com> The UtahValley.rb and BYU-RUG are trying something new. In place of our regular May 8th meeting, we're going to be hosting an 'erlounge' (an Erlang-centered meeting) Hopefully this will be the first of many monthly erlounges. (No, this doesn't mean we're giving up Ruby -- plan on seeing our regular Ruby meetings for a long time to come.) We'll meet at 7 PM in the large conference room at the Open Source Technology Center in Building A on the Novell Campus in Provo. During the meeting, we'll look at the first 6 chapters of 'Programming Erlang' by Joe Armstrong. Erlang is a highly concurrent, functional language. It was initially developed over 10 years ago for programming cell phone switches. Today, it is used for a variety of applications where stability, performance, and concurrency are essential. In his forward to 'Programming Erlang' Joe Armstrong writes "I had fun writing this book. I hope you have fun reading it. Now go read the book, write some code, and have fun." Let's take his advice and have some fun reading and hacking erlang together. (please feel free to forward this message to anyone you think might be interested) -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com From mogorman@REDACTED Tue May 1 17:34:47 2007 From: mogorman@REDACTED (Matthew O'Gorman) Date: Tue, 1 May 2007 10:34:47 -0500 Subject: [erlang-questions] Any erlang users in Northern Alabama? Message-ID: Seeing how quickly a group of people came together for a Utah meeting, I wanted to see if anyone was interested in a meeting in Huntsville, Alabama. Mog From richardc@REDACTED Tue May 1 18:12:27 2007 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 01 May 2007 18:12:27 +0200 Subject: [erlang-questions] Edoc Error In-Reply-To: References: Message-ID: <463766EB.4010507@it.uu.se> Logan, Martin wrote: > %% AppVsn = string() | 'LATEST' | "LATEST" > > The ?LATEST? string causes the following error. > > /home/martinjlogan/work/faxien/lib/faxien/src/fax_install.erl, function > install/5: at line 37: syntax error before: "LATEST" > > Looks like a bug. It's not. You can't specify particular strings; that's like saying "the list [76,65,84,69,83,84], but no other list". This is a limitation found in pretty much every type system out there. Anyway, you already specify that AppVsn can be a string; you'll just have to explain in the doc text that it can have the particular value "LATEST". /Richard From jim.menard@REDACTED Tue May 1 20:04:46 2007 From: jim.menard@REDACTED (Jim Menard) Date: Tue, 1 May 2007 14:04:46 -0400 Subject: [erlang-questions] Design question Message-ID: I'm a newcomer to Erlang, working my way through Programming Erlang. To help me learn, I'm porting a small Web application to Erlang/Erlyweb. Since I am new to Erlang, I have a design question. In this app, calendar objects are created on the fly, one for each set of users. The calendars will only live for a short while (ten minutes after the last recorded use, which gets refreshed if somebody uses it in that time). The first request for calendar X will create a calendar with that id. My first thought is "one spawned process per calendar". Does that make sense? If so, should I use the process dictionary in the main process to map a calendar's identifier to the Pid for that calendar's process? I'm thinking that each calendar process will send a message back to the main process when it is going to kill itself so the main process can erase that entry from the process dictionary. Another question: if I do use the process dictionary to store the calendar id-to-Pid mapping, isn't that a possible multi-threading danger zone? If two users ask to create the same calendar at the same time, I have a possible race condition. This tells me that what I'm thinking of doing is very, very, wrong. Any suggestions? Jim -- Jim Menard, jimm@REDACTED, jim.menard@REDACTED http://www.io.com/~jimm/ From anders.nygren@REDACTED Tue May 1 20:50:26 2007 From: anders.nygren@REDACTED (Anders Nygren) Date: Tue, 1 May 2007 13:50:26 -0500 Subject: [erlang-questions] Design question In-Reply-To: References: Message-ID: On 5/1/07, Jim Menard wrote: > I'm a newcomer to Erlang, working my way through Programming Erlang. > To help me learn, I'm porting a small Web application to > Erlang/Erlyweb. Since I am new to Erlang, I have a design question. > > In this app, calendar objects are created on the fly, one for each set > of users. The calendars will only live for a short while (ten minutes > after the last recorded use, which gets refreshed if somebody uses it > in that time). The first request for calendar X will create a calendar > with that id. > > My first thought is "one spawned process per calendar". Does that make > sense? If so, should I use the process dictionary in the main process > to map a calendar's identifier to the Pid for that calendar's process? > Since I don't know what the calendar process is supposed to do it is a little difficult to say if it is the correct way or not. But generally in Erlang it is the correct answer. I think it would be better to use an ETS table instead of the process dictionary. > I'm thinking that each calendar process will send a message back to > the main process when it is going to kill itself so the main process > can erase that entry from the process dictionary. If You create a link from the main process to the calendar processes the main process will receive a message whenever a calendar process terminates, without the calendar process having to send a message on its own. > > Another question: if I do use the process dictionary to store the > calendar id-to-Pid mapping, isn't that a possible multi-threading > danger zone? If two users ask to create the same calendar at the same > time, I have a possible race condition. This tells me that what I'm > thinking of doing is very, very, wrong. Any suggestions? Who is it that create the calendar id-to-pid mapping? The main process? In that case it is no problem since the main process handles one request at a time. If it is the calendar process that registers the id-to-pid it would be a problem. /Anders From jim.menard@REDACTED Tue May 1 21:04:39 2007 From: jim.menard@REDACTED (Jim Menard) Date: Tue, 1 May 2007 15:04:39 -0400 Subject: [erlang-questions] Design question In-Reply-To: References: Message-ID: Anders, On 5/1/07, Anders Nygren wrote: > On 5/1/07, Jim Menard wrote: [snip] > > My first thought is "one spawned process per calendar". Does that make > > sense? If so, should I use the process dictionary in the main process > > to map a calendar's identifier to the Pid for that calendar's process? > > > Since I don't know what the calendar process is supposed to do it is a > little difficult to say if it is the correct way or not. But generally in Erlang > it is the correct answer. Each calendar records time slots coming from each user, and on request reports back all of the slots from all users back to each user. It's a temporary shared calendar. > I think it would be better to use an ETS table instead of the process > dictionary. Why do you recommend that? For persistence (in case the main process dies)? In this application, persistence is not important. If everything is lost, that's ok. These calendars are throw-away. [snip] > If You create a link from the main process to the calendar processes > the main process will receive a message whenever a calendar process > terminates, without the calendar process having to send a message on its own. Aah, right. I remember reading that now. > > > > > Another question: if I do use the process dictionary to store the > > calendar id-to-Pid mapping, isn't that a possible multi-threading > > danger zone? If two users ask to create the same calendar at the same > > time, I have a possible race condition. This tells me that what I'm > > thinking of doing is very, very, wrong. Any suggestions? > > Who is it that create the calendar id-to-pid mapping? The main process? > In that case it is no problem since the main process handles one request > at a time. Yes, the main process would create them. As a newbie, I had not yet internalized the serial nature of incoming messages. (Actually, that's a question I have about Erlang's design: it seems to me that inboxes are the only place in Erlang's internals that has to worry about mutex locking, because incoming messages have to be added to the inbox safely. Am I correct?) Thanks for your advice. Jim -- Jim Menard, jimm@REDACTED, jim.menard@REDACTED http://www.io.com/~jimm/ From brian@REDACTED Tue May 1 21:53:27 2007 From: brian@REDACTED (Brian Olsen) Date: Tue, 1 May 2007 15:53:27 -0400 Subject: [erlang-questions] NYC Erlangers? Message-ID: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> The ones who did a search for people who use Erlang in Utah and Alabama got me interested in seeing if there are any people using Erlang that are in New York City. Are there? Maybe we can discuss starting a NYC Erlang users group if there is a sufficient number. Brian From ulf@REDACTED Tue May 1 22:34:02 2007 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 1 May 2007 22:34:02 +0200 Subject: [erlang-questions] Design question In-Reply-To: References: Message-ID: <8209f740705011334r6c37c1a9rea9948ed4964eb29@mail.gmail.com> 2007/5/1, Jim Menard : > > > (Actually, that's a question I have about Erlang's design: it seems to > me that inboxes are the only place in Erlang's internals that has to > worry about mutex locking, because incoming messages have to be added > to the inbox safely. Am I correct?) No, actually, there are lots of places where mutexes are needed. For example, it is possible to call process_info(Pid), and extract meta data on a process. The information includes the contents of the process dictionary, the reduction counter (used by the scheduler), the heap size, message queue, etc. Of course, all of these items need to be protected by mutexes, then. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From vijay@REDACTED Tue May 1 22:40:52 2007 From: vijay@REDACTED (vijay chakravarthy) Date: Tue, 1 May 2007 13:40:52 -0700 Subject: [erlang-questions] NYC Erlangers? In-Reply-To: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> References: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> Message-ID: <3c2535310705011340l2d825e02h5e62a2bf2a41033f@mail.gmail.com> I'm in NY pretty often, so can meet up here if the timing works.... We are based out of SF, and I know there are some erlangers/people with interest in erlang in the bay area, so that might be another place to get some people together. We can come and share our experiences/war stories building SlideAware stuff with Erlang. Regards, Vijay On 5/1/07, Brian Olsen wrote: > > The ones who did a search for people who use Erlang in Utah and > Alabama got me interested in seeing if there are any people using > Erlang that are in New York City. Are there? Maybe we can discuss > starting a NYC Erlang users group if there is a sufficient number. > > 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 james.hague@REDACTED Tue May 1 22:44:49 2007 From: james.hague@REDACTED (James Hague) Date: Tue, 1 May 2007 15:44:49 -0500 Subject: [erlang-questions] per function/process locals In-Reply-To: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> Message-ID: > Speaking only for myself, I find that it is a rare algorithm where > I need more than a handful of "variables" in a loop, I actually do this quite a bit. Sometimes problems have bunch of related variables, but records are awkward. Even just having 5 values getting passed around and "updated" in a loop bugs me. Editing that kind of code feels like busy work. I think the Erlangyest solution is to implement Joe's structs proposed a few years ago, then have the compiler recognize situations where structs are created and modified in a loop. > I'd rather have the let-for-then construct. Could you give an example? From ulf@REDACTED Tue May 1 22:53:48 2007 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 1 May 2007 22:53:48 +0200 Subject: [erlang-questions] error with systools._make_script : File not Found In-Reply-To: <20070430142540.E896A5A510@mail.erlangsystems.com> References: <20070430142540.E896A5A510@mail.erlangsystems.com> Message-ID: <8209f740705011353j5522a358rceb3c25be0fbe8a2@mail.gmail.com> 2007/4/30, norbertk : > > > > 4> systools:make_script("example",[{path,Path},{variables,[Var]}]). > File not found: "example.rel" > error > 5> file:get_cwd(). > {ok,"e:/projekte/lm2/erlang/releases/1.0"} > 6> > > make_scricpt shall create the script, so how can it complain that it does > not exist. Or is this a strange CYGWIN related problem, Prompt Nr 5 seems > suspicious. The file that is reported missing is example.rel. This is the release file, and it is used as input to make_script(). The resulting script will be called example.script. Check if you have a file called example.rel in that location. You might want to include the return value of file:list_dir(".") next time. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From fpierfed@REDACTED Wed May 2 02:09:01 2007 From: fpierfed@REDACTED (Francesco Pierfederici) Date: Tue, 1 May 2007 17:09:01 -0700 Subject: [erlang-questions] Binaries problem Message-ID: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> Hi, I have encountered a problem with handling binaries and I do not know what the cause might be. In a nutshell, I seem to be unable to assemble binaries larger than 2097149 bytes: -module(test). -export([test/2]). test(FileName, NumBytes) -> {ok, Fd} = file:open(FileName, [raw, binary]), {ok, Data} = file:read(Fd, NumBytes), file:close(Fd), NumRestBits = NumBytes * 8 - 1, <> = Data, NewData = <>, ok. And then inanna> erl Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> c(test). ./test.erl:11: Warning: variable 'Bit' is unused ./test.erl:13: Warning: variable 'NewData' is unused {ok,test} 2> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', 2097148). ok 3> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', 2097149). =ERROR REPORT==== 1-May-2007::16:33:57 === Error in process <0.37.0> with exit value: {badarg,[{test,test,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {badarg,[{test,test,2}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Is this a bug? Am I doing something wrong? Thank you! Francesco P.S. I am running this on a Mac OS X box using both R11B-4 and the latest snapshot (R11B_2007-05-01) with identical results. P.P.S. I get the same results with different files so there seems to be nothing peculiar about the 900+ MB XCode file. From aidankane@REDACTED Wed May 2 02:26:42 2007 From: aidankane@REDACTED (Aidan Kane) Date: Wed, 2 May 2007 01:26:42 +0100 Subject: [erlang-questions] design desicions Message-ID: I'm another newcomer to Erlang that's having a few difficulties understanding how one goes about designing a system from scratch. I've been trying to think about it in terms of rebuilding the system I currently work on which allows users to purchase vehicles via a web interface. At any one time there can easily be 30,000+ vehicles available for sale within the system. obviously the standard rules like two people can't purchase a vehicle at the same time apply. should each vehicle be a process (seems like a lot of processes - very few of whom would ever be active at the same time)? if so, how would the processes be created? would a process run at system start up to create them all? would each active user be a process as well? Sorry that the question is so general. I'm just having a lot of trouble understanding where to start with all this. Thanks. Aidan. From jeffm@REDACTED Wed May 2 02:48:58 2007 From: jeffm@REDACTED (jm) Date: Wed, 02 May 2007 10:48:58 +1000 Subject: [erlang-questions] design desicions In-Reply-To: References: Message-ID: <4637DFFA.9030904@ghostgun.com> If you are coming from an OOP background an idea that may help is to ask the question "should this be a process?" when you would normally create a new instance of an object. In this case, I'd guess that each active user session would be a process and that there would be one process minding the cars database in an initial cut of the software. Jeff. Aidan Kane wrote: > I'm another newcomer to Erlang that's having a few difficulties > understanding how one goes about designing a system from scratch. > > I've been trying to think about it in terms of rebuilding the system I > currently work on which allows users to purchase vehicles via a web > interface. At any one time there can easily be 30,000+ vehicles > available for sale within the system. obviously the standard rules > like two people can't purchase a vehicle at the same time apply. > > should each vehicle be a process (seems like a lot of processes - very > few of whom would ever be active at the same time)? if so, how would > the processes be created? would a process run at system start up to > create them all? > > would each active user be a process as well? > > Sorry that the question is so general. I'm just having a lot of > trouble understanding where to start with all this. > > Thanks. > Aidan. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Wed May 2 03:36:44 2007 From: ok@REDACTED (ok) Date: Wed, 2 May 2007 13:36:44 +1200 Subject: [erlang-questions] per function/process locals In-Reply-To: References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> Message-ID: <734D37BF-40EC-4C5B-989E-4D5675A3C7A7@cs.otago.ac.nz> On 2 May 2007, at 8:44 am, James Hague wrote, about tail recursive loops with many arguments simulating simple imperative variables: > I actually do this quite a bit. Why? Is there an example you can provide? > Even just having 5 values > getting passed around and "updated" in a loop bugs me. Updating 5 variables in a C loop would bug me, most of the time. > I think the Erlangyest solution is to implement Joe's structs proposed > a few years ago, then have the compiler recognize situations where > structs are created and modified in a loop. If the compiler recognised and special-cased similar code involving tuples, then the existing records would do the job just as well. There are reasons to expect this optimisation to be easier than the other. >> I'd rather have the let-for-then construct. > Could you give an example? A quick search for 'let then for in fold' in the Erlang mailing list archive found this: ... we had a thread about looping not so very long ago. By the end of it, there was a concrete proposal for a construct looking like (let p1 = i1 then s1, ..., pk = ik then sk for generators-and-filters in final-result ) [Added in May 2007: "p" suggests "pattern", "i" suggests "initial value", "s" suggests "step", generators-and-filters is whatever can currently follow "||" in a list comprehension, final-result is an expression.] As a trivial example, let's compute the mean of the positive elements of a list: (let N = 0 then N+1, S = 0 then S+X for X <- List, X > 0 in S/N ) It's pretty much what you get if you hybridise Scheme DO loops with list comprehension, and it's as pure as anyone could wish for. [Added in May 2007: best of all, it doesn't add a new kind of "variable" to the language. Nor does it require heavy-duty optimisation to recover the intended structure. The only tricky thing is the rebinding of the pattern variables.] From yarivvv@REDACTED Wed May 2 03:45:14 2007 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 1 May 2007 21:45:14 -0400 Subject: [erlang-questions] NYC Erlangers? In-Reply-To: <3c2535310705011340l2d825e02h5e62a2bf2a41033f@mail.gmail.com> References: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> <3c2535310705011340l2d825e02h5e62a2bf2a41033f@mail.gmail.com> Message-ID: <17244f480705011845k1ab28f45rcf665fb6b492592f@mail.gmail.com> I'm moving to the Bay Area in the next month or two. It would be great to start an Erlang group out there. Best, Yariv On 5/1/07, vijay chakravarthy wrote: > I'm in NY pretty often, so can meet up here if the timing works.... We are > based out of SF, and I know there are some erlangers/people with interest in > erlang in the bay area, so that might be another place to get some people > together. We can come and share our experiences/war stories building > SlideAware stuff with Erlang. > Regards, > Vijay > > > On 5/1/07, Brian Olsen wrote: > > The ones who did a search for people who use Erlang in Utah and > > Alabama got me interested in seeing if there are any people using > > Erlang that are in New York City. Are there? Maybe we can discuss > > starting a NYC Erlang users group if there is a sufficient number. > > > > 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 > > From bob@REDACTED Wed May 2 03:57:14 2007 From: bob@REDACTED (Bob Ippolito) Date: Tue, 1 May 2007 18:57:14 -0700 Subject: [erlang-questions] NYC Erlangers? In-Reply-To: <17244f480705011845k1ab28f45rcf665fb6b492592f@mail.gmail.com> References: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> <3c2535310705011340l2d825e02h5e62a2bf2a41033f@mail.gmail.com> <17244f480705011845k1ab28f45rcf665fb6b492592f@mail.gmail.com> Message-ID: <6a36e7290705011857m44b84e35x894da927842a35f0@mail.gmail.com> Good to hear that you've seen the light ;) There's probably enough of us in SF to start something. -bob On 5/1/07, Yariv Sadan wrote: > I'm moving to the Bay Area in the next month or two. It would be great > to start an Erlang group out there. > > Best, > Yariv > > On 5/1/07, vijay chakravarthy wrote: > > I'm in NY pretty often, so can meet up here if the timing works.... We are > > based out of SF, and I know there are some erlangers/people with interest in > > erlang in the bay area, so that might be another place to get some people > > together. We can come and share our experiences/war stories building > > SlideAware stuff with Erlang. > > Regards, > > Vijay > > > > > > On 5/1/07, Brian Olsen wrote: > > > The ones who did a search for people who use Erlang in Utah and > > > Alabama got me interested in seeing if there are any people using > > > Erlang that are in New York City. Are there? Maybe we can discuss > > > starting a NYC Erlang users group if there is a sufficient number. > > > > > > 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 > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kevin.clark@REDACTED Wed May 2 04:33:59 2007 From: kevin.clark@REDACTED (Kevin Clark) Date: Tue, 1 May 2007 19:33:59 -0700 Subject: [erlang-questions] NYC Erlangers? In-Reply-To: <6a36e7290705011857m44b84e35x894da927842a35f0@mail.gmail.com> References: <301fd58b0705011253o580ef0edub3cf2e39badad2d3@mail.gmail.com> <3c2535310705011340l2d825e02h5e62a2bf2a41033f@mail.gmail.com> <17244f480705011845k1ab28f45rcf665fb6b492592f@mail.gmail.com> <6a36e7290705011857m44b84e35x894da927842a35f0@mail.gmail.com> Message-ID: There's 3 of us at Powerset (we're known as rubyists, but we're really just language enthusiasts) playing with erlang and interested in learning more. We also may have a place to make available (with projector) if we wanted to do some sort of user group. Kev On 5/1/07, Bob Ippolito wrote: > Good to hear that you've seen the light ;) > > There's probably enough of us in SF to start something. > > -bob > > On 5/1/07, Yariv Sadan wrote: > > I'm moving to the Bay Area in the next month or two. It would be great > > to start an Erlang group out there. > > > > Best, > > Yariv > > > > On 5/1/07, vijay chakravarthy wrote: > > > I'm in NY pretty often, so can meet up here if the timing works.... We are > > > based out of SF, and I know there are some erlangers/people with interest in > > > erlang in the bay area, so that might be another place to get some people > > > together. We can come and share our experiences/war stories building > > > SlideAware stuff with Erlang. > > > Regards, > > > Vijay > > > > > > > > > On 5/1/07, Brian Olsen wrote: > > > > The ones who did a search for people who use Erlang in Utah and > > > > Alabama got me interested in seeing if there are any people using > > > > Erlang that are in New York City. Are there? Maybe we can discuss > > > > starting a NYC Erlang users group if there is a sufficient number. > > > > > > > > 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 > > > > > > > > _______________________________________________ > > 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 > -- Kevin Clark http://glu.ttono.us From jim@REDACTED Wed May 2 05:54:05 2007 From: jim@REDACTED (Jim Thompson) Date: Tue, 01 May 2007 17:54:05 -1000 Subject: [erlang-questions] Aloha Erlang? Message-ID: <46380B5D.9070604@netgate.com> Given the recent stream of Utah, Alabama, NYC, SF, ... erlang hackers trying to meetup, I thought I'd stick my hand up and ask, "Are there any other Hawaii-based Erlang folks on-list?" Oahu preferred (and most likely), though with the cheap flights these days, I'm not above going to Kauai, Maui or the 'Big Island' for a day of Erlang fun. Jim From codeslinger@REDACTED Wed May 2 06:25:06 2007 From: codeslinger@REDACTED (Toby DiPasquale) Date: Wed, 2 May 2007 00:25:06 -0400 Subject: [erlang-questions] eh yo, Erlang Message-ID: <7968AA6A-FC6B-4BBB-AC03-3032E729FFFF@gmail.com> Er-body, In the spirit of the recent interest in local Erlang action, I'm giving an intro talk on Erlang to the Philadelphia Linux Users Group on June 6th. If anyone's going to be around for that, come on down. The info is here: http://www.phillylinux.org/ Most of it will be coming from the new Armstrong book, but I'm going to do a small SMTP proxy before the talk so I can pepper it with some real- world dev experience for the mostly non-FP audience. If there's anyone interested in/using Erlang around Philly, hit this list up and we can make some moves from there. -- Toby DiPasquale From hans.bolinder@REDACTED Wed May 2 08:37:44 2007 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 2 May 2007 08:37:44 +0200 Subject: [erlang-questions] Escript and spawn In-Reply-To: <17970.63098.73627.146841@antilipe.corelatus.se> References: <20070428110553.c00a3e30.mle+erlang@mega-nerd.com> <17970.63098.73627.146841@antilipe.corelatus.se> Message-ID: <17976.12728.842475.731357@gargle.gargle.HOWL> [Matthias Lang:] > The erl_eval manpage in R11B-4 claims that receive "cannot be handled > properly". A basic test of receive, both in escript and using erl_eval > directly, suggests that it works. Are the problems, or is it just an > out of date manpage? erl_eval removes messages from the queue and puts them back if they don't match any clause. If a new message arrives while old messages are put back, the order of the message queue will no longer be correct. Best regards, Hans Bolinder, Erlang/OTP team From ingela@REDACTED Wed May 2 09:12:22 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Wed, 02 May 2007 09:12:22 +0200 Subject: [erlang-questions] Reading a big text file from a web In-Reply-To: References: Message-ID: <463839D6.8020907@erix.ericsson.se> erlang-questions-request@REDACTED wrote: [...] >> Right now my, very naive, implementation is reading the result of >> http:request("http://example.com/file.txt") and split it by new lines. >> The file is several megabytes long so the memory consumption increases >> considerably. >> >> What do you recommend to implement this functionality? >> > > Check to see if the inets http client has an option to save the > response to a file. It does have an option to save it to a file. http:request(get, {URL, []}, [], [{stream, FilePath}]). > Once the file is downloaded, you can then parse it in chunks. > Better up the inets http-client lets you stream the result to a process directly so you do not have to wait for the whole response to be saved to a file to then read it in chunks. {ok, RequestId} = http:request(get, {URL, []}, [], [{sync, false}, {stream, self}]). Then your process can receive the messages {http, {RequestId, stream_start, Headers}, {http, {RequestId, stream, BinBodyPart}, {http, {RequestId, stream_end, Headers}. Regards Ingela - OTP team From adam@REDACTED Wed May 2 09:27:38 2007 From: adam@REDACTED (Adam Lindberg) Date: Wed, 2 May 2007 09:27:38 +0200 Subject: [erlang-questions] design desicions In-Reply-To: <4637DFFA.9030904@ghostgun.com> References: <4637DFFA.9030904@ghostgun.com> Message-ID: <6344005f0705020027i7baa710dye7f37e0f28529a71@mail.gmail.com> On 5/2/07, jm wrote: > If you are coming from an OOP background an idea that may help is to ask > the question "should this be a process?" when you would normally create > a new instance of an object. Also, another difference is usually that processes are actors, and objects data containers (generally speaking). Especially in your case. The individual vehicle processes wouldn't actually do anything _simultaneously_ (the need for concurrency, thus using processes). The vehicle implementation should really only contain data (price, model, and whatnot). Then, as Jeff suggested, you would only need one process to manage them all (store them in a database such as Mnesia or ETS) to make sure they are accessed in an orderly fashion, avoiding double booking etc. > In this case, I'd guess that each active user session would be a process > and that there would be one process minding the cars database in an > initial cut of the software. > > Jeff. > > Aidan Kane wrote: > > I'm another newcomer to Erlang that's having a few difficulties > > understanding how one goes about designing a system from scratch. > > > > I've been trying to think about it in terms of rebuilding the system I > > currently work on which allows users to purchase vehicles via a web > > interface. At any one time there can easily be 30,000+ vehicles > > available for sale within the system. obviously the standard rules > > like two people can't purchase a vehicle at the same time apply. > > > > should each vehicle be a process (seems like a lot of processes - very > > few of whom would ever be active at the same time)? if so, how would > > the processes be created? would a process run at system start up to > > create them all? > > > > would each active user be a process as well? > > > > Sorry that the question is so general. I'm just having a lot of > > trouble understanding where to start with all this. > > > > Thanks. > > Aidan. > > _______________________________________________ > > 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 > Cheers! Adam -- Adam Lindberg Software Developer Erlang Training and Consulting Ltd 401 Fruit and Wool Exchange, Brushfield Street, London, E1 6EL, United Kingdom Company Registration 3893360 VAT Number GB 752 1091 57 Tel +44 207 456 1020 Fax +44 870 1390 779 Mobile +44 7960 726 016 Email adam@REDACTED From mats.cronqvist@REDACTED Wed May 2 10:17:17 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 02 May 2007 10:17:17 +0200 Subject: [erlang-questions] Generic interface for c-nodes In-Reply-To: <46353230.6090600@ballen.fastmail.fm> References: <52097BE7-03B4-4CA5-92FA-87B6854B32E5@valornet.com> <0T421opfIvjjNv8%stesch@parsec.no-spoon.de> <46353230.6090600@ballen.fastmail.fm> Message-ID: <4638490D.5010800@ericsson.com> Bill Allen wrote: > I remember reading some time ago in a post by the authors of GtkNode > that they had used an automatic tool to build some of the boilerplate > for interfacing erlang using the c headers of gtk. My question is did > they write a special toold for that or is there a general tool that can > do that. it's a special-purpose erlang program, geared towards the GTK/Glib type system. mats From mats.cronqvist@REDACTED Wed May 2 10:45:39 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 02 May 2007 10:45:39 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <46351ADA.4080201@telia.com> References: <6616D98C65DD514BA2E1DDC5F922315501B25685@esealmw115.eemea.ericsson.se> <462D585D.5060707@telia.com> <462DB2B2.3000108@ericsson.com> <46351ADA.4080201@telia.com> Message-ID: <46384FB3.90503@ericsson.com> Robert Virding wrote: > Mats Cronqvist wrote: >> Robert Virding wrote: >>> Trouble is that it breaks the functional part of the language. Now >>> that is only really done in process dictionary, processes/message, >>> ports and ets. >> >> so erlang is functional, except for the process dictionary, >> messages, ports and ets? then perhaps it's time to stop pretending >> it's functional? >> > > Strange viewpoint! what i find strange is the viewpoint that no features should be added unless they are functional. with that line of reasoning message passing should never have been added either, which would somewhat limit the usefulness of the language. > We might as well then just add erlang like processes to Java and be done with. i'm convinced that soon enough a java-like language (javascript?) will incorporate erlang-style processes/message passing. and then erlang will, i fear, indeed be done. C.f. http://steve-yegge.blogspot.com/2007/02/next-big-language.html mats From vladdu55@REDACTED Wed May 2 11:10:23 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 2 May 2007 11:10:23 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <46384FB3.90503@ericsson.com> References: <6616D98C65DD514BA2E1DDC5F922315501B25685@esealmw115.eemea.ericsson.se> <462D585D.5060707@telia.com> <462DB2B2.3000108@ericsson.com> <46351ADA.4080201@telia.com> <46384FB3.90503@ericsson.com> Message-ID: <95be1d3b0705020210q50f417dbk960ee32d21ec2cc9@mail.gmail.com> On 5/2/07, Mats Cronqvist wrote: > > We might as well then just add erlang like processes to Java and be done with. > > i'm convinced that soon enough a java-like language (javascript?) will > incorporate erlang-style processes/message passing. and then erlang will, i > fear, indeed be done. > C.f. http://steve-yegge.blogspot.com/2007/02/next-big-language.html Scala almost does - their actors library is actually modeled after Erlang's processes. The "only" missing part is a runtime to actually give the same characteristics as the beam runtime. [the quotes are meaning that I am aware that it would be a huge undertaking; but given the increasing incentives to deliver such a beast, I'd say it may not be too far away in the future] I wonder what would be easier: to port the Erlang runtime to the JVM, or to write a compiler for a Java-like language targeting the beam runtime? regards, Vlad From forsyth@REDACTED Wed May 2 12:48:58 2007 From: forsyth@REDACTED (Charles Forsyth) Date: Wed, 2 May 2007 11:48:58 +0100 Subject: [erlang-questions] process dictionary, anyone? Message-ID: <0a9878c593d79beb44235f076f9eee64@terzarima.net> > i'm convinced that soon enough a java-like language (javascript?) will > incorporate erlang-style processes/message passing. and then erlang will, i > fear, indeed be done. > C.f. http://steve-yegge.blogspot.com/2007/02/next-big-language.html >I wonder what would be easier: to port the Erlang runtime to the JVM, >or to write a compiler for a Java-like language targeting the beam >runtime? that's only if design and notation don't matter, and they do. to start with, is any form of concurrency compatible with an object-oriented language? or again: Erlang is a little gem; Java is a dung heap. why hide the one inside the other? i just don't get it. it's not even as though (as with C, say) you'd thereby be getting access to a great set of run-time libraries. From vladdu55@REDACTED Wed May 2 13:18:27 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 2 May 2007 13:18:27 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> Message-ID: <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> Hi, On 5/2/07, Charles Forsyth wrote: > >I wonder what would be easier: to port the Erlang runtime to the JVM, > >or to write a compiler for a Java-like language targeting the beam > >runtime? > > that's only if design and notation don't matter, and they do. > to start with, is any form of concurrency compatible with an object-oriented language? I don't see any incompatibility here. Of course, I assume we're not talking about today's OO languages, but ones that take steps towards the concurrency oriented paradigm. I mean, everything is evolving. in other words, I think the "object as process" metaphor holds very nicely. > or again: Erlang is a little gem; Java is a dung heap. why hide the one inside the other? > i just don't get it. it's not even as though (as with C, say) you'd thereby be getting > access to a great set of run-time libraries. Java is just an example. It seems like a probable candidate just by the sheer mass of users and libraries (of which BTW I assume most will be reusable on the improved platform). IMHO, the not so distant future will give us "erlang processes" at the OS level and later on at the hardware level. I have trouble imagining that there will only be a single programming language in use and I think it is a safe bet that one of them will be a C extension. My natural curiosity is pushing me into exploring alternative ways to do things. Some are dead-ends, but some will lead forward. How else to progress? best regards, Vlad From ulf.wiger@REDACTED Wed May 2 13:21:41 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 2 May 2007 13:21:41 +0200 Subject: [erlang-questions] per function/process locals In-Reply-To: References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> I haven't followed the details of this thread, but when dealing with records, this pattern appears quite often. As it's not a great idea to export records in an API, I often prefer to take a property list as input. If I then still want to use a record internally for efficient random access, I end up having to traverse the property list and build a record. There are different ways to do this: init_state(L) -> lists:foldl( fun({a, A}, S) -> S#st{a = A}; ({b, B}, S) -> S#st{b = B}; ... end, #st{}, L). I tend to to the following, for convenience: [A, B, C, D] = [proplists:get_value(K,L) || K <- [a, b, c, d]], #st{a = A, b = B, c = C, d = D} BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of James Hague > Sent: den 1 maj 2007 22:45 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] per function/process locals > > > Speaking only for myself, I find that it is a rare > algorithm where I > > need more than a handful of "variables" in a loop, > > I actually do this quite a bit. Sometimes problems have > bunch of related variables, but records are awkward. Even > just having 5 values getting passed around and "updated" in a > loop bugs me. Editing that kind of code feels like busy work. > > I think the Erlangyest solution is to implement Joe's structs > proposed a few years ago, then have the compiler recognize > situations where structs are created and modified in a loop. > > > I'd rather have the let-for-then construct. > > Could you give an example? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jerith@REDACTED Wed May 2 13:25:54 2007 From: jerith@REDACTED (Jeremy Thurgood) Date: Wed, 02 May 2007 13:25:54 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> Message-ID: <46387542.4000805@jerith.za.net> Vlad Dumitrescu wrote: > Java is just an example. It seems like a probable candidate just by > the sheer mass of users and libraries (of which BTW I assume most will > be reusable on the improved platform). Given the number of Java libraries that aren't threadsafe and the magnitude of the paradigm shift required to get the benefits of Erlang in any language, I don't think that's going to be the case. --J From vladdu55@REDACTED Wed May 2 14:35:21 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 2 May 2007 14:35:21 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <46387542.4000805@jerith.za.net> References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> <46387542.4000805@jerith.za.net> Message-ID: <95be1d3b0705020535x21497be9wcd36501e99fa791a@mail.gmail.com> On 5/2/07, Jeremy Thurgood wrote: > Vlad Dumitrescu wrote: > > Java is just an example. It seems like a probable candidate just by > > the sheer mass of users and libraries (of which BTW I assume most will > > be reusable on the improved platform). > > Given the number of Java libraries that aren't threadsafe and the > magnitude of the paradigm shift required to get the benefits of Erlang > in any language, I don't think that's going to be the case. The latter is a valid argument, although IMHO the paradigm shift will have to happen anyway, sooner or later. Whether it's going to be towards Erlang's paradigm or some other, that's another issue. The former I can't agree with -- the beauty of the "object as process with no shared data and communication by message passing" model is that thread safety as we know it is mostly irrelevant. best regards, Vlad From pat.eyler@REDACTED Wed May 2 14:44:06 2007 From: pat.eyler@REDACTED (pat eyler) Date: Wed, 2 May 2007 06:44:06 -0600 Subject: [erlang-questions] Aloha Erlang? In-Reply-To: <46380B5D.9070604@netgate.com> References: <46380B5D.9070604@netgate.com> Message-ID: <6fd0654b0705020544m54e952b2h6656dffc3658e9e9@mail.gmail.com> On 5/1/07, Jim Thompson wrote: > > Given the recent stream of Utah, Alabama, NYC, SF, ... erlang hackers > trying to meetup, I thought I'd stick my hand up and ask, > > "Are there any other Hawaii-based Erlang folks on-list?" > > Oahu preferred (and most likely), though with the cheap flights these > days, I'm not above going to Kauai, Maui or the 'Big Island' for a day > of Erlang fun. I wish flights were cheaper, I wouldn't mind going to Oahu, Kauai, Maui, or the 'Big Island' for some Erlang (and beach) time. ;^) > > Jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com From richardc@REDACTED Wed May 2 15:41:51 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 02 May 2007 15:41:51 +0200 Subject: [erlang-questions] Testing with EUnit In-Reply-To: <46370026.6080606@bates.id.au> References: <17972.61171.982277.549789@antilipe.corelatus.se> <46370026.6080606@bates.id.au> Message-ID: <4638951F.3050104@it.uu.se> Tim Bates wrote: > EUnit also has other problems when run from Escript, as detailed in my > earlier mail which nobody has replied to. Can I please draw people's > attention to it again? Sorry that I did not reply before. I did note your mail, but I have not had time to try your example yet. Meanwhile, the more help I can get with narrowing down the problem, the better. /Richard From james.hague@REDACTED Wed May 2 16:12:12 2007 From: james.hague@REDACTED (James Hague) Date: Wed, 2 May 2007 09:12:12 -0500 Subject: [erlang-questions] per function/process locals In-Reply-To: <734D37BF-40EC-4C5B-989E-4D5675A3C7A7@cs.otago.ac.nz> References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> <734D37BF-40EC-4C5B-989E-4D5675A3C7A7@cs.otago.ac.nz> Message-ID: On 5/1/07, ok wrote: > > > I actually do this quite a bit. > > Why? Is there an example you can provide? Sure. I wrote a Forth interpreter that had a data stack, floating point stack, dictionary, tree simulating memory...and one more thing that's escaping me. Most of the words in my interpreter took these 5 parameters as inputs. I could have put them in a record, but that was uglier in my opinion. I've also written a scripting system where I have ~10 state variables that change often during execution. The preprocessed version is ~50% faster than the record version, and the BEAM files were ~50% smaller. The code is prettier, too. > > Even just having 5 values > > getting passed around and "updated" in a loop bugs me. > > Updating 5 variables in a C loop would bug me, most of the time. It happens. I've written enough production C/C++ to realize I'd drive myself crazy if I had to keep all code beautiful. (And updating 5 variables in a loop doesn't qualify is ugly, not by a long shot!) James From per.gustafsson@REDACTED Wed May 2 17:34:33 2007 From: per.gustafsson@REDACTED (Per Gustafsson) Date: Wed, 02 May 2007 17:34:33 +0200 Subject: [erlang-questions] Binaries problem In-Reply-To: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> Message-ID: <4638AF89.1000106@it.uu.se> Francesco Pierfederici wrote: > Hi, > > I have encountered a problem with handling binaries and I do not know > what the cause might be. In a nutshell, I seem to be unable to > assemble binaries larger than 2097149 bytes: > > -module(test). > -export([test/2]). > > > test(FileName, NumBytes) -> > {ok, Fd} = file:open(FileName, [raw, binary]), > {ok, Data} = file:read(Fd, NumBytes), > file:close(Fd), > > NumRestBits = NumBytes * 8 - 1, > <> = Data, > > NewData = <>, > ok. > > > And then > > inanna> erl > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.4 (abort with ^G) > 1> c(test). > ./test.erl:11: Warning: variable 'Bit' is unused > ./test.erl:13: Warning: variable 'NewData' is unused > {ok,test} > 2> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', > 2097148). > ok > 3> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', > 2097149). > > =ERROR REPORT==== 1-May-2007::16:33:57 === > Error in process <0.37.0> with exit value: > {badarg,[{test,test,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {badarg,[{test,test,2}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > > Is this a bug? Am I doing something wrong? > > Thank you! > Francesco > > P.S. I am running this on a Mac OS X box using both R11B-4 and the > latest snapshot (R11B_2007-05-01) with identical results. > P.P.S. I get the same results with different files so there seems to > be nothing peculiar about the 900+ MB XCode file. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions I think that the problem you are running in to is that you are creating an integer that is too big for the erlang runtime system. I'm not sure exactly where this limit is but it should be in the order of what you are creating. You can sidestep this problem (and have a much more efficient implementation by writing: test(FileName, NumBytes) -> {ok, Fd} = file:open(FileName, [raw, binary]), {ok, Data} = file:read(Fd, NumBytes), file:close(Fd), <> = Data, NewData = <>, ok. Or if you use the following compiler option: [bitlevel_binaries] test(FileName, NumBytes) -> {ok, Fd} = file:open(FileName, [raw, binary]), {ok, Data} = file:read(Fd, NumBytes), file:close(Fd), <> = Data, NewData = <>, ok. Of course this syntax is only experimental. Per From chandrashekhar.mullaparthi@REDACTED Wed May 2 19:35:42 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 2 May 2007 18:35:42 +0100 Subject: [erlang-questions] Reading a big text file from a web In-Reply-To: <463839D6.8020907@erix.ericsson.se> References: <463839D6.8020907@erix.ericsson.se> Message-ID: On 02/05/07, Ingela Anderton Andin wrote: > > erlang-questions-request@REDACTED wrote: > [...] > >> Right now my, very naive, implementation is reading the result of > >> http:request("http://example.com/file.txt") and split it by new lines. > >> The file is several megabytes long so the memory consumption increases > >> considerably. > >> > >> What do you recommend to implement this functionality? > >> > > > > Check to see if the inets http client has an option to save the > > response to a file. > It does have an option to save it to a file. > > http:request(get, {URL, []}, [], [{stream, FilePath}]). > > Once the file is downloaded, you can then parse it in chunks. > > > Better up the inets http-client lets you stream the result to a process > directly so you do not have to wait for the > whole response to be saved to a file to then read it in chunks. I wouldn't recommend doing this for large files. Depending on the size of the file and the complexity of the parsing, you could end up overloading the process which is receiving these messages. And as the size of the message queue of a process increases, it becomes slower as I think the runtime system penalises processes with large message queues. Message passing is a double edged sword. It is very nice, but it can kill your system if you don't use it wisely. From jim@REDACTED Wed May 2 22:16:59 2007 From: jim@REDACTED (Jim Thompson) Date: Wed, 02 May 2007 10:16:59 -1000 Subject: [erlang-questions] Binaries problem In-Reply-To: <4638AF89.1000106@it.uu.se> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> <4638AF89.1000106@it.uu.se> Message-ID: <4638F1BB.4000908@netgate.com> Francesco Pierfederici wrote: > > Hi, > > > > I have encountered a problem with handling binaries and I do not know > > what the cause might be. In a nutshell, I seem to be unable to > > assemble binaries larger than 2097149 bytes: > > Per Gustafsson wrote: > I think that the problem you are running in to is that you are creating > an integer that is too big for the erlang runtime system. I'm not sure > exactly where this limit is but it should be in the order of what you > are creating. jim@REDACTED:~$ erl Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1> round(math:pow(2,21))-3. 2097149 2> halt(). From Martin.Logan@REDACTED Wed May 2 22:32:46 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Wed, 2 May 2007 15:32:46 -0500 Subject: [erlang-questions] Edoc Error In-Reply-To: <463766EB.4010507@it.uu.se> References: <463766EB.4010507@it.uu.se> Message-ID: -----Original Message----- From: Richard Carlsson [mailto:richardc@REDACTED] Sent: Tuesday, May 01, 2007 11:12 AM To: Logan, Martin Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Edoc Error Logan, Martin wrote: > %% AppVsn = string() | 'LATEST' | "LATEST" > > The "LATEST" string causes the following error. > > /home/martinjlogan/work/faxien/lib/faxien/src/fax_install.erl, function > install/5: at line 37: syntax error before: "LATEST" > > Looks like a bug. It's not. You can't specify particular strings; that's like saying "the list [76,65,84,69,83,84], but no other list". This is a limitation found in pretty much every type system out there. Anyway, you already specify that AppVsn can be a string; you'll just have to explain in the doc text that it can have the particular value "LATEST". Fair enough. I will use an explanation. Thanks for the clarification. Cheers, Martin From kostis@REDACTED Wed May 2 22:52:19 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 02 May 2007 22:52:19 +0200 Subject: [erlang-questions] Arithmetic expressions [WAS: Re: Binaries problem] In-Reply-To: <4638F1BB.4000908@netgate.com> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> <4638AF89.1000106@it.uu.se> <4638F1BB.4000908@netgate.com> Message-ID: <4638FA03.6080602@cs.ntua.gr> Jim Thompson wrote: > Francesco Pierfederici wrote: > > > Hi, > > > > > > I have encountered a problem with handling binaries and I do not know > > > what the cause might be. In a nutshell, I seem to be unable to > > > assemble binaries larger than 2097149 bytes: > > > > > Per Gustafsson wrote: > >> I think that the problem you are running in to is that you are creating >> an integer that is too big for the erlang runtime system. I'm not sure >> exactly where this limit is but it should be in the order of what you >> are creating. > > jim@REDACTED:~$ erl > Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] > [kernel-poll:false] > > Eshell V5.5.2 (abort with ^G) > 1> round(math:pow(2,21))-3. > 2097149 Unrelated to the topic, but we had weird cases where the HiPE compiler was crashing when compiling binaries in R11B-3. They were all related to use of an expression that was similar to the one Jim is using: round(math:pow(2,N)) - K. In examining the problem, we realized that this was a very stupid way of denoting this quantity. We solved the problem (in R11B-4) by adopting a much better (and significantly faster) way of writing the same expression in Erlang: (2 bsl (N-1)) - K I suspect this "round + math:pow(2)" combination is not so uncommon after all ... although there is really no reason to use it. Kostis From jim@REDACTED Wed May 2 23:20:29 2007 From: jim@REDACTED (Jim Thompson) Date: Wed, 02 May 2007 11:20:29 -1000 Subject: [erlang-questions] Arithmetic expressions [WAS: Re: Binaries problem] In-Reply-To: <4638FA03.6080602@cs.ntua.gr> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> <4638AF89.1000106@it.uu.se> <4638F1BB.4000908@netgate.com> <4638FA03.6080602@cs.ntua.gr> Message-ID: <4639009D.7010509@netgate.com> Kostis Sagonas wrote: > Jim Thompson wrote: >> Eshell V5.5.2 (abort with ^G) >> 1> round(math:pow(2,21))-3. >> 2097149 > > Unrelated to the topic, but we had weird cases where the HiPE compiler > was crashing when compiling binaries in R11B-3. They were all related > to use of an expression that was similar to the one Jim is using: > > round(math:pow(2,N)) - K. > > In examining the problem, we realized that this was a very stupid way of > denoting this quantity. We solved the problem (in R11B-4) by adopting a > much better (and significantly faster) way of writing the same > expression in Erlang: > > (2 bsl (N-1)) - K > > I suspect this "round + math:pow(2)" combination is not so uncommon > after all ... although there is really no reason to use it. I am an Erlang newbie, and therefore stupid. Ignore what I say, or type. From kostis@REDACTED Wed May 2 23:30:31 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 02 May 2007 23:30:31 +0200 Subject: [erlang-questions] Arithmetic expressions [WAS: Re: Binaries problem] In-Reply-To: <4639009D.7010509@netgate.com> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> <4638AF89.1000106@it.uu.se> <4638F1BB.4000908@netgate.com> <4638FA03.6080602@cs.ntua.gr> <4639009D.7010509@netgate.com> Message-ID: <463902F7.4040708@cs.ntua.gr> Jim Thompson wrote: > Kostis Sagonas wrote: >> Jim Thompson wrote: > >>> Eshell V5.5.2 (abort with ^G) >>> 1> round(math:pow(2,21))-3. >>> 2097149 >> >> Unrelated to the topic, but we had weird cases where the HiPE compiler >> was crashing when compiling binaries in R11B-3. They were all related >> to use of an expression that was similar to the one Jim is using: >> >> round(math:pow(2,N)) - K. >> >> In examining the problem, we realized that this was a very stupid way of >> denoting this quantity. We solved the problem (in R11B-4) by adopting >> a much better (and significantly faster) way of writing the same >> expression in Erlang: >> >> (2 bsl (N-1)) - K >> >> I suspect this "round + math:pow(2)" combination is not so uncommon >> after all ... although there is really no reason to use it. > > I am an Erlang newbie, and therefore stupid. Ignore what I say, or type. But this is exactly the opposite of my point! My point was that even very seasoned Erlang programmers instinctively write the expression "round + math:pow(2)" instead of that with 'bsl' first. No idea why this is so, but I found it extremely interesting that I've run across this expression twice in such a short period of time. I am sure you and us (the HiPE group) are not its only users. Cheers, Kostis From ckerr@REDACTED Wed May 2 23:41:33 2007 From: ckerr@REDACTED (Cameron Kerr) Date: Thu, 3 May 2007 09:41:33 +1200 Subject: [erlang-questions] Speed of communication with external processes In-Reply-To: References: Message-ID: <07117C93-297D-41A2-92E4-6EF66FC56910@cs.otago.ac.nz> Can you show us your code please? On 14/04/2007, at 10:02 AM, James Hague wrote: > I wrote an Erlang program that uses a local TCP socket (with nodelay) > to communicate with a tiny external program (which I wrote). I was > curious what the turnaround time was on sending data to the external > program and getting back a result, so I wrote a little test function. > > Under Windows XP, I'm getting ~3500 round trips per second. I was > surprised at how hight that number was. > > Under OS X, I'm getting ~90 round trips per second. 90? Wow, that's > low! I'm sure something is wrong, but I haven't found it yet. > > Anyone else ever run tests like this? I'd be curious what kind of > numbers you got. > > Thanks! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- ? Cameron Kerr ? ? ckerr@REDACTED ? ? ? ? Telecommunications Teaching Fellow & SysAdmin ? ? ? http://humbledown.org/blog/ ? ? 021 02 333 294 ? From toby@REDACTED Thu May 3 00:24:21 2007 From: toby@REDACTED (Toby Thain) Date: Wed, 2 May 2007 19:24:21 -0300 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> Message-ID: On 2-May-07, at 8:18 AM, Vlad Dumitrescu wrote: > Hi, > ... > > IMHO, the not so distant future will give us "erlang processes" at the > OS level and later on at the hardware level. Truly "back to the future": The Inmos Transputer did this in the 1980s. --T From paul@REDACTED Thu May 3 01:08:38 2007 From: paul@REDACTED (Paul) Date: Thu, 03 May 2007 11:08:38 +1200 Subject: [erlang-questions] eh yo, Erlang In-Reply-To: <7968AA6A-FC6B-4BBB-AC03-3032E729FFFF@gmail.com> References: <7968AA6A-FC6B-4BBB-AC03-3032E729FFFF@gmail.com> Message-ID: <463919F6.1000602@domains.textdriven.com> Hi Toby, Could you please post your slides online. I would be very interested in having a look. Regards, Paul Toby DiPasquale wrote: > Er-body, > > In the spirit of the recent interest in local Erlang action, I'm > giving an > intro talk on Erlang to the Philadelphia Linux Users Group on June > 6th. If > anyone's going to be around for that, come on down. The info is here: > > http://www.phillylinux.org/ > > Most of it will be coming from the new Armstrong book, but I'm going > to do > a small SMTP proxy before the talk so I can pepper it with some real- > world > dev experience for the mostly non-FP audience. > > If there's anyone interested in/using Erlang around Philly, hit this > list > up and we can make some moves from there. > > -- > Toby DiPasquale > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From robert.virding@REDACTED Thu May 3 02:35:28 2007 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 03 May 2007 02:35:28 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> Message-ID: <46392E50.9040306@telia.com> There is nothing new under the sun. Robert Toby Thain wrote: > On 2-May-07, at 8:18 AM, Vlad Dumitrescu wrote: > >> Hi, >> ... >> >> IMHO, the not so distant future will give us "erlang processes" at the >> OS level and later on at the hardware level. > > Truly "back to the future": The Inmos Transputer did this in the 1980s. > > --T > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Thu May 3 02:55:33 2007 From: ok@REDACTED (ok) Date: Thu, 3 May 2007 12:55:33 +1200 Subject: [erlang-questions] per function/process locals In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> Message-ID: <86E23A60-4527-4A23-905D-4452C817E660@cs.otago.ac.nz> On 2 May 2007, at 11:21 pm, Ulf Wiger (TN/EAB) wrote [that instead of doing] > init_state(L) -> > lists:foldl( > fun({a, A}, S) -> S#st{a = A}; > ({b, B}, S) -> S#st{b = B}; > ... > end, #st{}, L). [he tends to do] > [A, B, C, D] = > [proplists:get_value(K,L) || > K <- [a, b, c, d]], > #st{a = A, b = B, c = C, d = D} This is a rather interesting example, because it shows a clear trade- off. Suppose there are V "variables". We expect that the list will contain each at most once; the worst case is when they all appear. The first algorithm does one pass -- O(V) work for traversal -- building a new record (memory size V+2 words at least) on each iteration, for a total of O(V**2) time and O(V**2) space turned over. The second algorithm does V passes -- O(V**2) work for traversal -- but each pass builds only a single cons cell -- O(V) space --. For large V, it is better to sort the list L -- O(V.lg V) time and space -- and then do a merge -- O(V) time and space --. This is basically what list_to_frame/1 does in my "frames" proposal (which is not entirely unlike Joe Armstrong's "proper structs"). See http://www.cs.otago.ac.nz/staffpriv/ok/frames.pdf for details. It would be interesting to see more examples where people want "many" "variables" in a loop, to discover whether they could be handled in the source language by multiple loops each working with fewer variables. If so, compiler support for loop fusion (which would be a very nice thing to have anyway) might do more for us than special syntax. From kg9020@REDACTED Thu May 3 04:48:24 2007 From: kg9020@REDACTED (kgi9020) Date: Wed, 2 May 2007 21:48:24 -0500 Subject: [erlang-questions] any OK erlangers Message-ID: <03D8AE1F-D968-410E-9F06-8E042C2A8EAA@valornet.com> Hello are there any erlangs in Tulsa OK art From bengt.kleberg@REDACTED Thu May 3 08:39:35 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 03 May 2007 08:39:35 +0200 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <46392E50.9040306@telia.com> References: <4f78589c8fde530c6b42e5ff3bdc47ca@terzarima.net> <95be1d3b0705020418v7b154653v1481d1a674f27339@mail.gmail.com> <46392E50.9040306@telia.com> Message-ID: <463983A7.1070800@ericsson.com> On 2007-05-03 02:35, Robert Virding wrote: > There is nothing new under the sun. there was a first time for everything :-) bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From ulf.wiger@REDACTED Thu May 3 08:44:55 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 3 May 2007 08:44:55 +0200 Subject: [erlang-questions] per function/process locals In-Reply-To: <86E23A60-4527-4A23-905D-4452C817E660@cs.otago.ac.nz> References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz><6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> <86E23A60-4527-4A23-905D-4452C817E660@cs.otago.ac.nz> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501C248A7@esealmw115.eemea.ericsson.se> I could have mentioned, for completeness, that the two alternatives are not semantically equivalent, if the list holds more than one instance of any given key. Using proplists, you take the first instance of K, whereas with the foldl version, you will keep the last. It can often be useful to allow shadowing of options, and with proplists, this is done by prepending to the list. I will read your frames proposal. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of ok > Sent: den 3 maj 2007 02:56 > To: Erlang (E-mail) > Subject: Re: [erlang-questions] per function/process locals > > On 2 May 2007, at 11:21 pm, Ulf Wiger (TN/EAB) wrote [that > instead of doing] > > init_state(L) -> > > lists:foldl( > > fun({a, A}, S) -> S#st{a = A}; > > ({b, B}, S) -> S#st{b = B}; > > ... > > end, #st{}, L). > [he tends to do] > > [A, B, C, D] = > > [proplists:get_value(K,L) || > > K <- [a, b, c, d]], > > #st{a = A, b = B, c = C, d = D} > > This is a rather interesting example, because it shows a > clear trade- off. > Suppose there are V "variables". We expect that the list > will contain each at most once; the worst case is when they > all appear. > > The first algorithm does one pass -- O(V) work for traversal > -- building a new record (memory size V+2 words at least) on > each iteration, for a total of O(V**2) time and O(V**2) space > turned over. > The second algorithm does V passes -- O(V**2) work for > traversal -- but each pass builds only a single cons cell -- > O(V) space --. For large V, it is better to sort the list L > -- O(V.lg V) time and space -- and then do a merge -- O(V) > time and space --. This is basically what > list_to_frame/1 does in my "frames" proposal (which is not > entirely unlike Joe Armstrong's "proper structs"). See > http://www.cs.otago.ac.nz/staffpriv/ok/frames.pdf > for details. > > It would be interesting to see more examples where people want "many" > "variables" in a loop, to discover whether they could be > handled in the source language by multiple loops each working > with fewer variables. > If so, compiler support for loop fusion (which would be a > very nice thing to have anyway) might do more for us than > special syntax. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ingela@REDACTED Thu May 3 10:19:31 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Thu, 03 May 2007 10:19:31 +0200 Subject: [erlang-questions] Reading a big text file from a web In-Reply-To: References: <463839D6.8020907@erix.ericsson.se> Message-ID: <46399B13.20807@erix.ericsson.se> Chandru wrote: > On 02/05/07, Ingela Anderton Andin wrote: >> >> erlang-questions-request@REDACTED wrote: >> [...] >> >> Right now my, very naive, implementation is reading the result of >> >> http:request("http://example.com/file.txt") and split it by new >> lines. >> >> The file is several megabytes long so the memory consumption >> increases >> >> considerably. >> >> >> >> What do you recommend to implement this functionality? >> >> >> > >> > Check to see if the inets http client has an option to save the >> > response to a file. >> It does have an option to save it to a file. >> >> http:request(get, {URL, []}, [], [{stream, FilePath}]). >> > Once the file is downloaded, you can then parse it in chunks. >> > >> Better up the inets http-client lets you stream the result to a process >> directly so you do not have to wait for the >> whole response to be saved to a file to then read it in chunks. > > I wouldn't recommend doing this for large files. Depending on the size > of the file and the complexity of the parsing, you could end up > overloading the process which is receiving these messages. And as the > size of the message queue of a process increases, it becomes slower as > I think the runtime system penalises processes with large message > queues. The process that gets penalized is not the processes with the long queue but the process sending to the process with the long queue in order to if possible prevent congestion. > Message passing is a double edged sword. It is very nice, but it can > kill your system if you don't use it wisely. I think streaming to a process is the most intuitive solution, but there might be a trade off here that would make streaming to a file and then parsing the file a good alternative. I think the best thing is to test both and then decide. Regards - Ingela OTP team From casper2000a@REDACTED Thu May 3 11:43:00 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Thu, 3 May 2007 15:13:00 +0530 Subject: [erlang-questions] HIPE Native compile error In-Reply-To: <46399B13.20807@erix.ericsson.se> Message-ID: <20070503094356.CEC3519DC143@mail.wavenet.lk> Hi, When I try to compile a module using +native and -smp options in command line, I get the below error. I use Erlang 11B-4 in Solaris 10. When I compile the module without +native, it compiles successfully. Also I tried the same in Linux, and it compiles successfully too. It seems like a problem in HiPE in Solaris. Thanks, - Eranga EXITED with reason {function_clause,[{gb_trees,get_1,[{rtl_reg,123,false},nil]},{hipe_rtl_ssa,u pdateStatementUses,3},{hipe_rtl_ssa,renameVars,3},{hipe_rtl_ssa,rename,4},{h ipe_rtl_ssa,childrenRename,4},{hipe_rtl_ssa,convert,1},{hipe_main,rtl_ssa_co nvert,2},{hipe_main,rtl_ssa,2}]} @hipe:835 =ERROR REPORT==== 3-May-2007::17:29:42 === Error: [hipe:834]: ERROR: {function_clause, [{gb_trees, get_1, [{rtl_reg,123,false},nil]}, {hipe_rtl_ssa, updateStatementUses, 3}, {hipe_rtl_ssa,renameVars,3}, {hipe_rtl_ssa,rename,4}, {hipe_rtl_ssa,childrenRename,4}, {hipe_rtl_ssa,convert,1}, {hipe_main,rtl_ssa_convert,2}, {hipe_main,rtl_ssa,2}]} ../src/test.erl:none: internal error in native_compile; crash reason: {{hipe, 835, {function_clause, [{gb_trees,get_1,[{rtl_reg,123,false},nil]}, {hipe_rtl_ssa,updateStatementUses,3}, {hipe_rtl_ssa,renameVars,3}, {hipe_rtl_ssa,rename,4}, {hipe_rtl_ssa,childrenRename,4}, {hipe_rtl_ssa,convert,1}, {hipe_main,rtl_ssa_convert,2}, {hipe_main,rtl_ssa,2}]}}, [{hipe,finalize_fun_sequential,2}, {hipe,'-finalize_fun/2-lc$^0/1-0-',2}, {hipe,'-finalize_fun/2-lc$^0/1-0-',2}, {hipe,finalize,5}, {hipe,compile_finish,3}, {hipe,'-run_compiler_1/3-fun-0-',4}]} =ERROR REPORT==== 3-May-2007::17:29:42 === Error in process <0.34.0> with exit value: {{hipe,835,{function_clause,[{gb_trees,get_1,[{rtl_reg,123,false},nil]},{hip e_rtl_ssa,updateStatementUses,3},{hipe_rtl_ssa,renameVars,3},{hipe_rtl_ssa,r ename,4},{hipe_rtl_ssa,childrenRename,4},{hipe_rtl_ssa,convert,1},{... From mazen@REDACTED Thu May 3 12:06:00 2007 From: mazen@REDACTED (Mazen) Date: Thu, 03 May 2007 11:06:00 +0100 Subject: [erlang-questions] any OK erlangers References: Message-ID: <20070503100600.43B025A06A@mail.erlangsystems.com> Imagine if there was a website where Erlang users could register themselves and you could read about eachother and present yourself and what you do etc, discuss on forums and dump your knowledge on to a wiki for others to absorb... Kindof a meeting place. Oh wait... there is! :) Ideally you would all register at http://www.frappr.com/erlang/ , The more that register the more that can connect easily :) Then come to www.trapexit.org and register there :) The trapexit site is expected another overhaul this summer so drop by everyone who hasn't and check it out :) I would be more then happy to take ALL your suggestions about the site! PS: be sure to check out or User Contributions section :) kevin wrote: Hello are there any erlangs in Tulsa OK art _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions Post recived from mailinglist (end of quote) _________________________________________________________ Post sent from http://www.trapexit.org From kostis@REDACTED Thu May 3 12:15:47 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 03 May 2007 13:15:47 +0300 Subject: [erlang-questions] HIPE Native compile error In-Reply-To: <20070503094356.CEC3519DC143@mail.wavenet.lk> References: <20070503094356.CEC3519DC143@mail.wavenet.lk> Message-ID: <4639B653.2040400@cs.ntua.gr> Eranga Udesh wrote: > Hi, > > When I try to compile a module using +native and -smp options in command > line, I get the below error. I use Erlang 11B-4 in Solaris 10. When I > compile the module without +native, it compiles successfully. Also I tried > the same in Linux, and it compiles successfully too. It seems like a problem > in HiPE in Solaris. > It's difficult for us to debug a compiler crash without a file that shows the problem. Please send it if you want this fixed. Kostis From casper2000a@REDACTED Thu May 3 12:46:58 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Thu, 3 May 2007 16:16:58 +0530 Subject: [erlang-questions] HIPE Native compile error In-Reply-To: <4639B653.2040400@cs.ntua.gr> Message-ID: <20070503104709.8D4A019DC14F@mail.wavenet.lk> Thanks. Attached is a cut down version of the module. Compile it as, erlc +native -smp test.erl - Eranga -----Original Message----- From: Kostis Sagonas [mailto:kostis@REDACTED] Sent: Thursday, May 03, 2007 3:46 PM To: Eranga Udesh; Erlang Subject: Re: [erlang-questions] HIPE Native compile error Eranga Udesh wrote: > Hi, > > When I try to compile a module using +native and -smp options in command > line, I get the below error. I use Erlang 11B-4 in Solaris 10. When I > compile the module without +native, it compiles successfully. Also I tried > the same in Linux, and it compiles successfully too. It seems like a problem > in HiPE in Solaris. > It's difficult for us to debug a compiler crash without a file that shows the problem. Please send it if you want this fixed. Kostis -------------- next part -------------- A non-text attachment was scrubbed... Name: test.erl Type: application/octet-stream Size: 692 bytes Desc: not available URL: From rvg@REDACTED Thu May 3 13:19:36 2007 From: rvg@REDACTED (Rudolph van Graan) Date: Thu, 3 May 2007 13:19:36 +0200 Subject: [erlang-questions] Help! How do get test_server to show SASL and/or Crash reports Message-ID: <15FEC507-800A-40DE-B111-1DBB00113152@patternmatched.com> Hi there, I'm desperately trying to find a solution to get the OTP test_server to capture SASL and/or Crash/Error logs. It does intercept stdout, but not error reports. Regards, Rudolph van Graan From kostis@REDACTED Thu May 3 15:38:31 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 03 May 2007 16:38:31 +0300 Subject: [erlang-questions] HIPE Native compile error In-Reply-To: <20070503104709.8D4A019DC14F@mail.wavenet.lk> References: <20070503104709.8D4A019DC14F@mail.wavenet.lk> Message-ID: <4639E5D7.7080403@cs.ntua.gr> Eranga Udesh wrote: > Thanks. Attached is a cut down version of the module. Compile it as, > erlc +native -smp test.erl > With the attached file that you sent, I cannot reproduce the crash, neither in our current version nor in using Erlang/OTP R11B-4 (as distributed in its source version from erlang.org). One thing that's different is that I am running on Solaris 9 (not 10) since I only have access to such a machine and that the gcc version that was used to build OTP is Using built-in specs. Target: sparc-sun-solaris2.9 Configured with: /tmp/mikpe/gcc-4.1.2/configure --prefix=/home/mikpe/pkgs/sol2-sparc64/gcc-4.1.2 --disable-shared --enable-threads --disable-nls --enable-version-specific-runtime-libs --with-system-zlib --enable-languages=c Thread model: posix gcc version 4.1.2 Are you sure the stripped down version that you sent makes the HiPE compiler crash? What happens if you specify only +native but no -smp? Kostis From fpierfed@REDACTED Thu May 3 19:25:16 2007 From: fpierfed@REDACTED (Francesco Pierfederici) Date: Thu, 3 May 2007 10:25:16 -0700 Subject: [erlang-questions] Binaries problem In-Reply-To: <4638AF89.1000106@it.uu.se> References: <1d7144ea0705011709p1998de50jdb32bd6e3359dcdf@mail.gmail.com> <4638AF89.1000106@it.uu.se> Message-ID: <1d7144ea0705031025r7ebc1462q92c72d6e72cb14e0@mail.gmail.com> Hi Per, Thank you for your help: now everything works and I am happy again :-) Cheers, Francesco On 5/2/07, Per Gustafsson wrote: > Francesco Pierfederici wrote: > > Hi, > > > > I have encountered a problem with handling binaries and I do not know > > what the cause might be. In a nutshell, I seem to be unable to > > assemble binaries larger than 2097149 bytes: > > > > -module(test). > > -export([test/2]). > > > > > > test(FileName, NumBytes) -> > > {ok, Fd} = file:open(FileName, [raw, binary]), > > {ok, Data} = file:read(Fd, NumBytes), > > file:close(Fd), > > > > NumRestBits = NumBytes * 8 - 1, > > <> = Data, > > > > NewData = <>, > > ok. > > > > > > And then > > > > inanna> erl > > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] > > [kernel-poll:false] > > > > Eshell V5.5.4 (abort with ^G) > > 1> c(test). > > ./test.erl:11: Warning: variable 'Bit' is unused > > ./test.erl:13: Warning: variable 'NewData' is unused > > {ok,test} > > 2> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', > > 2097148). > > ok > > 3> test:test('/Users/fpierfed/Desktop/software/xcode_2.4.1_8m1910_6936315.dmg', > > 2097149). > > > > =ERROR REPORT==== 1-May-2007::16:33:57 === > > Error in process <0.37.0> with exit value: > > {badarg,[{test,test,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > > > ** exited: {badarg,[{test,test,2}, > > {erl_eval,do_apply,5}, > > {shell,exprs,6}, > > {shell,eval_loop,3}]} ** > > > > > > Is this a bug? Am I doing something wrong? > > > > Thank you! > > Francesco > > > > P.S. I am running this on a Mac OS X box using both R11B-4 and the > > latest snapshot (R11B_2007-05-01) with identical results. > > P.P.S. I get the same results with different files so there seems to > > be nothing peculiar about the 900+ MB XCode file. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > I think that the problem you are running in to is that you are creating > an integer that is too big for the erlang runtime system. I'm not sure > exactly where this limit is but it should be in the order of what you > are creating. > > You can sidestep this problem (and have a much more efficient > implementation by writing: > > > test(FileName, NumBytes) -> > {ok, Fd} = file:open(FileName, [raw, binary]), > {ok, Data} = file:read(Fd, NumBytes), > file:close(Fd), > > <> = Data, > > NewData = <>, > ok. > > Or if you use the following compiler option: [bitlevel_binaries] > > test(FileName, NumBytes) -> > {ok, Fd} = file:open(FileName, [raw, binary]), > {ok, Data} = file:read(Fd, NumBytes), > file:close(Fd), > > <> = Data, > > NewData = <>, > ok. > > Of course this syntax is only experimental. > > Per > From Martin.Logan@REDACTED Thu May 3 21:30:17 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Thu, 3 May 2007 14:30:17 -0500 Subject: [erlang-questions] Escript include Message-ID: Perhaps I have missed something but I did not see a way to include other libraries in an escript script. There is no -pz option as far as I can see. Anyone know how to accomplish this? Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Thu May 3 23:30:32 2007 From: mihai@REDACTED (Mihai Balea) Date: Thu, 3 May 2007 17:30:32 -0400 Subject: [erlang-questions] Building R11B-4 fails on Kubuntu 7.04 Feisty Fawn Message-ID: <00F11EC6-702E-4406-A53C-7706BC34328F@hates.ms> I trying to build OTP R11B-4 on a freshly installed Kubuntu 7.04 Feisty Fawn. I am getting the following build error: mihai@REDACTED:~/dld/otp_src_R11B-4$ make cd erts/emulator && ERL_TOP=/home/mihai/dld/otp_src_R11B-4 make generate depend make[1]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ emulator' make -f i686-pc-linux-gnu/Makefile generate make[2]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ emulator' gcc -g -O3 -I/home/mihai/dld/otp_src_R11B-4/erts/i686-pc-linux-gnu - D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT - D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict- prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE - D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/ common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib - Ihipe -I../include/internal -I../include/internal/i686-pc-linux-gnu - c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/ hipe_mkliterals.o hipe/hipe_mkliterals.c:351: error: ?X86_LEAF_WORDS? undeclared here (not in a function) hipe/hipe_mkliterals.c:352: error: ?X86_NR_ARG_REGS? undeclared here (not in a function) make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] Error 1 make[2]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ emulator' make[1]: *** [generate] Error 2 make[1]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ emulator' make: *** [depend] Error 2 I used the following configure command: ./configure --enable-smp-support --enable-threads --disable-hipe I tried first with --enable-hipe but got the same result. Any suggestions on how to fix this? Thanks in advance Mihai PS: R11B-4 used to build just fine on Kubuntu 6.10 Edgy From tony@REDACTED Fri May 4 01:55:02 2007 From: tony@REDACTED (Tony Perrie) Date: Thu, 3 May 2007 16:55:02 -0700 Subject: [erlang-questions] Erlyweb Problem Message-ID: I'm attempting to run the Erlyweb example, but I'm getting the following error: sudo yaws -i --conf yaws.conf Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> =INFO REPORT==== 3-May-2007::16:43:47 === Yaws: Using config file yaws.conf yaws:Add path "/usr/local/lib/yaws/examples/ebin" yaws:Running with id=default Running with debug checks turned on (slower server) Logging to directory "." =INFO REPORT==== 3-May-2007::16:43:47 === Yaws: Listening to 127.0.0.1:8000 for servers - http://127.0.0.1:8000 under /Users/jperrie/erlapps/music/www 1> 1> erlyweb:compile("/Users/jperrie/erlapps/music", [{erlydb_driver, mysql}]). debug:erlyweb_compile:340: Compiling Erlang file "music_app_controller" debug:erlyweb_compile:340: Compiling Erlang file "musician_view" debug:erlyweb_compile:340: Compiling Erlang file "musician_controller" debug:erlyweb_compile:340: Compiling Erlang file "musician" debug:erlyweb_compile:335: Compiling ErlTL file "html_container_view" debug:erlyweb_compile:340: Compiling Erlang file "html_container_controller" debug:erlyweb_compile:104: Generating ErlyDB code for models: "musician.erl " ** exited: {noproc,{gen_server,call, [mysql_dispatcher, {fetch,erlydb_mysql,<<"show tables">>}]}} ** 2> 2> erlydb:start(mysql, [{hostname, "localhost"}, {username, "jperrie"}, {password, "password"}, {database, "music"}]). mysql_conn:612: greeting version "5.0.27-standard" (protocol 10) salt "cM:wm>salt2 "iE[zu\\LG]!+S" mysql_auth:187: mysql_auth send packet 1: <<5,162,0,0,64,66,15,0,8,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 106,112,101,114,114,105,101,0,20, 88,147,69,92,86,192,94,46,151,64, 185,17,142,240,222,193,75,187,204,62>> mysql_conn:418: fetch <<"use music">> (id <0.82.0>) {ok,<0.80.0>} 3> erlyweb:compile("/Users/jperrie/erlapps/music", [{erlydb_driver, mysql}]). debug:erlyweb_compile:340: Compiling Erlang file "music_app_controller" debug:erlyweb_compile:340: Compiling Erlang file "musician_view" debug:erlyweb_compile:340: Compiling Erlang file "musician_controller" debug:erlyweb_compile:340: Compiling Erlang file "musician" debug:erlyweb_compile:335: Compiling ErlTL file "html_container_view" debug:erlyweb_compile:340: Compiling Erlang file "html_container_controller" debug:erlyweb_compile:104: Generating ErlyDB code for models: "musician.erl " mysql_conn:418: fetch <<"show tables">> (id <0.82.0>) mysql_conn:418: fetch <<"describe musician">> (id <0.82.0>) {ok,{{2007,5,3},{16,45,22}}} 4> =ERROR REPORT==== 3-May-2007::16:45:43 === ERROR erlang code crashed: File: appmod:0 Reason: {no_such_function,{"musician", "index", 1, "You tried to invoke a controller function that doesn't exist or that isn't exported"}} Req: {http_request,'GET',{abs_path,"/music/musician"},{1,1}} The following files exist: /Users/jperrie/erlapps/music/ /Users/jperrie/erlapps/music//ebin /Users/jperrie/erlapps/music//ebin/html_container_controller.beam /Users/jperrie/erlapps/music//ebin/html_container_view.beam /Users/jperrie/erlapps/music//ebin/music_app_controller.beam /Users/jperrie/erlapps/music//ebin/music_erlyweb_data.beam /Users/jperrie/erlapps/music//ebin/musician.beam /Users/jperrie/erlapps/music//ebin/musician_controller.beam /Users/jperrie/erlapps/music//ebin/musician_view.beam /Users/jperrie/erlapps/music//src /Users/jperrie/erlapps/music//src/components /Users/jperrie/erlapps/music//src/components/ebin /Users/jperrie/erlapps/music//src/components/html_container_controller.erl /Users/jperrie/erlapps/music//src/components/html_container_view.et /Users/jperrie/erlapps/music//src/components/musician.erl /Users/jperrie/erlapps/music//src/components/musician_controller.erl /Users/jperrie/erlapps/music//src/components/musician_view.erl /Users/jperrie/erlapps/music//src/music_app_controller.erl /Users/jperrie/erlapps/music//www /Users/jperrie/erlapps/music//www/index.html /Users/jperrie/erlapps/music//www/style.css The database is accessible with the password, and the data is there. I tried adding a "-pa /Users/jperrie/erlapps/music/src/components" to the command-line as well. I'm not really sure how to debug this though. I feel like the "musician" component isn't getting loaded, but I'm not sure how to load it. Any help would be appreciated, Tony From bengt.kleberg@REDACTED Fri May 4 08:40:41 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 04 May 2007 08:40:41 +0200 Subject: [erlang-questions] Escript include In-Reply-To: References: Message-ID: <463AD569.20605@ericsson.com> On 2007-05-03 21:30, Logan, Martin wrote: > Perhaps I have missed something but I did not see a way to include other > libraries in an escript script. There is no -pz option as far as I can > see. Anyone know how to accomplish this? if it is for your own use you can use code:add_pathz/1 in the script with a hardcoded path. if it is for somebody elses use i would expect (not tested) that an argument to the script would work. (you do an add_pathz() with the argument in the script) bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From mikpe@REDACTED Fri May 4 09:11:47 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 4 May 2007 09:11:47 +0200 (MEST) Subject: [erlang-questions] Building R11B-4 fails on Kubuntu 7.04 Feisty Fawn Message-ID: <200705040711.l447BlTm026944@harpo.it.uu.se> On Thu, 3 May 2007 17:30:32 -0400, Mihai Balea wrote: > I trying to build OTP R11B-4 on a freshly installed Kubuntu 7.04 = > > Feisty Fawn. I am getting the following build error: > > mihai@REDACTED:~/dld/otp_src_R11B-4$ make > cd erts/emulator && ERL_TOP=3D/home/mihai/dld/otp_src_R11B-4 make = > > generate depend > make[1]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ = > > emulator' > make -f i686-pc-linux-gnu/Makefile generate > make[2]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ = > > emulator' > gcc -g -O3 -I/home/mihai/dld/otp_src_R11B-4/erts/i686-pc-linux-gnu - = > > D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_GNU_SOURCE - = > > DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT - = > > D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict- = > > prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE - = > > D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/ = > > common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib - = > > Ihipe -I../include/internal -I../include/internal/i686-pc-linux-gnu - = > > c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/ = > > hipe_mkliterals.o > hipe/hipe_mkliterals.c:351: error: =91X86_LEAF_WORDS=92 undeclared here = > > (not in a function) > hipe/hipe_mkliterals.c:352: error: =91X86_NR_ARG_REGS=92 undeclared here = > > (not in a function) > make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] Error 1 > make[2]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ = > > emulator' > make[1]: *** [generate] Error 2 > make[1]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ = > > emulator' > make: *** [depend] Error 2 > > I used the following configure command: > > ./configure --enable-smp-support --enable-threads --disable-hipe > > I tried first with --enable-hipe but got the same result. > > Any suggestions on how to fix this? Show the complete `make' log (make 2>&1 | tee logfile or something). Does it mention the `m4' program? /Mikael From martin.ankerl@REDACTED Fri May 4 09:20:01 2007 From: martin.ankerl@REDACTED (Martin Ankerl) Date: Fri, 4 May 2007 09:20:01 +0200 Subject: [erlang-questions] learning Erlang: factoring primes Message-ID: Hello everybody, I have just started learning Erlang and wrote one of my first programs. It is a very simple prime factoring program, but it works. I would appreciate comments about the programming style, is this how Erlang code should be written? Any way to make it simpler? Here is the code: -module(factor). -export([fact/1]). % c('factor'). % factor:fact(123456723456789). fact(1) -> []; fact(N) -> % io:format("~w\n", [N]), M = next_factor(N, 2, N rem 2), [ M | fact(N div M) ]. % find the next factor next_factor(_, M, 0) -> M; next_factor(N, N, _) -> N; next_factor(N, M, _) -> next_factor(N, M+1, N rem (M+1)). -- Martin Ankerl | http://martin.ankerl.com From matthias@REDACTED Fri May 4 09:50:43 2007 From: matthias@REDACTED (Matthias Lang) Date: Fri, 4 May 2007 09:50:43 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: Message-ID: <17978.58835.365627.41516@antilipe.corelatus.se> The programming style is fine. I only see trivial things which are hardly worth mentioning: - You don't need to quote atoms like 'factor' (in your compile comment) - The program currently hangs for negative numbers It can be simplified a bit, though it's already pretty good. You can rewrite next_factor in two clauses like this: first_factor(N, M) when N rem M == 0 -> M; first_factor(N, M) -> first_factor(N, M+1). Matthias Martin Ankerl writes: > Hello everybody, I have just started learning Erlang and wrote one of > my first programs. It is a very simple prime factoring program, but it > works. I would appreciate comments about the programming style, is > this how Erlang code should be written? Any way to make it simpler? > > Here is the code: > > -module(factor). > -export([fact/1]). > > % c('factor'). > % factor:fact(123456723456789). > fact(1) -> > []; > fact(N) -> > % io:format("~w\n", [N]), > M = next_factor(N, 2, N rem 2), > [ M | fact(N div M) ]. > > % find the next factor > next_factor(_, M, 0) -> > M; > next_factor(N, N, _) -> > N; > next_factor(N, M, _) -> > next_factor(N, M+1, N rem (M+1)). > > -- > Martin Ankerl | http://martin.ankerl.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kostis@REDACTED Fri May 4 10:07:31 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 04 May 2007 10:07:31 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <17978.58835.365627.41516@antilipe.corelatus.se> References: <17978.58835.365627.41516@antilipe.corelatus.se> Message-ID: <463AE9C3.4050207@cs.ntua.gr> Matthias Lang wrote: > The programming style is fine. I only see trivial things which are > hardly worth mentioning: > > - You don't need to quote atoms like 'factor' (in your compile comment) > - The program currently hangs for negative numbers > > It can be simplified a bit, though it's already pretty good. You can > rewrite next_factor in two clauses like this: > > first_factor(N, M) when N rem M == 0 -> > M; > first_factor(N, M) -> > first_factor(N, M+1). Please, do not use == for arithmetic comparisons with integers (*). It's brain damage from C. Learn to use =:= instead. It's more kosher. Kostis (*) Unless you really mean it. But even in those cases think again. From lcoquelle@REDACTED Fri May 4 10:24:21 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Fri, 4 May 2007 16:24:21 +0800 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <17978.58835.365627.41516@antilipe.corelatus.se> References: <17978.58835.365627.41516@antilipe.corelatus.se> Message-ID: Not sure this is useful here, but fact could be made tail-recursive: fact(N) -> fact(N, []). fact(1, Factors) -> Factors; fact(N, Factors) -> M = next_factor(N, 2), % using definition of Matthias fact(N div M, [M|Factors]). (haven't tested this code ...) On 5/4/07, Matthias Lang wrote: > > > The programming style is fine. I only see trivial things which are > hardly worth mentioning: > > - You don't need to quote atoms like 'factor' (in your compile comment) > - The program currently hangs for negative numbers > > It can be simplified a bit, though it's already pretty good. You can > rewrite next_factor in two clauses like this: > > first_factor(N, M) when N rem M == 0 -> > M; > first_factor(N, M) -> > first_factor(N, M+1). > > Matthias > > > Martin Ankerl writes: > > Hello everybody, I have just started learning Erlang and wrote one of > > my first programs. It is a very simple prime factoring program, but it > > works. I would appreciate comments about the programming style, is > > this how Erlang code should be written? Any way to make it simpler? > > > > Here is the code: > > > > -module(factor). > > -export([fact/1]). > > > > % c('factor'). > > % factor:fact(123456723456789). > > fact(1) -> > > []; > > fact(N) -> > > % io:format("~w\n", [N]), > > M = next_factor(N, 2, N rem 2), > > [ M | fact(N div M) ]. > > > > % find the next factor > > next_factor(_, M, 0) -> > > M; > > next_factor(N, N, _) -> > > N; > > next_factor(N, M, _) -> > > next_factor(N, M+1, N rem (M+1)). > > > > -- > > Martin Ankerl | http://martin.ankerl.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 als@REDACTED Fri May 4 10:39:43 2007 From: als@REDACTED (Anthony Shipman) Date: Fri, 4 May 2007 18:39:43 +1000 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <463AE9C3.4050207@cs.ntua.gr> References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> Message-ID: <200705041839.43127.als@iinet.net.au> On Friday 04 May 2007 18:07, Kostis Sagonas wrote: > > Please, do not use == for arithmetic comparisons with integers (*). > It's brain damage from C. > > Learn to use =:= instead. It's more kosher. Is there a performance difference? -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From kostis@REDACTED Fri May 4 10:59:26 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 04 May 2007 10:59:26 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <200705041839.43127.als@iinet.net.au> References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <200705041839.43127.als@iinet.net.au> Message-ID: <463AF5EE.1050202@cs.ntua.gr> Anthony Shipman wrote: > On Friday 04 May 2007 18:07, Kostis Sagonas wrote: > >> Please, do not use == for arithmetic comparisons with integers (*). >> It's brain damage from C. >> >> Learn to use =:= instead. It's more kosher. > > Is there a performance difference? > In emulated code, the performance difference, if any, it is quite small. In native code, the performance difference is currently also small, although this might change soon (if we partly inline =:=). But is it not an issue of performance; it's a problem in the semantics of the == operator. Kostis From lcoquelle@REDACTED Fri May 4 11:03:37 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Fri, 4 May 2007 17:03:37 +0800 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: <17978.58835.365627.41516@antilipe.corelatus.se> Message-ID: Kind of ... I'm not sure about stack-overflow, but yes idea is that: in your code, Erlang needs as many function-call contexts as factors in the number. In this case I guess this is not a very big number of contexts. But this kind of consideration have to be made when programming in Erlang. On 5/4/07, Martin Ankerl wrote: > > On 5/4/07, Ludovic Coquelle wrote: > > Not sure this is useful here, but fact could be made tail-recursive: > > Does that mean that my code could (at least theoretically) produce a > stack overflow, and when tail-recursion is possible this is save? > > -- > Martin Ankerl | http://martin.ankerl.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From als@REDACTED Fri May 4 11:32:20 2007 From: als@REDACTED (Anthony Shipman) Date: Fri, 4 May 2007 19:32:20 +1000 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <463AF5EE.1050202@cs.ntua.gr> References: <200705041839.43127.als@iinet.net.au> <463AF5EE.1050202@cs.ntua.gr> Message-ID: <200705041932.20715.als@iinet.net.au> On Friday 04 May 2007 18:59, Kostis Sagonas wrote: > Anthony Shipman wrote: > > On Friday 04 May 2007 18:07, Kostis Sagonas wrote: > >> Please, do not use == for arithmetic comparisons with integers (*). > >> It's brain damage from C. > >> > >> Learn to use =:= instead. It's more kosher. > > > > Is there a performance difference? > > In emulated code, the performance difference, if any, it is quite small. > In native code, the performance difference is currently also small, > although this might change soon (if we partly inline =:=). > > But is it not an issue of performance; it's a problem in the semantics > of the == operator. Please elaborate. The erlang manual is terse. For integer arguments I can see no difference in semantics between the two. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From dot@REDACTED Fri May 4 12:39:33 2007 From: dot@REDACTED (Tony Finch) Date: Fri, 4 May 2007 11:39:33 +0100 Subject: [erlang-questions] process dictionary, anyone? In-Reply-To: <0a9878c593d79beb44235f076f9eee64@terzarima.net> References: <0a9878c593d79beb44235f076f9eee64@terzarima.net> Message-ID: On Wed, 2 May 2007, Charles Forsyth wrote: > > to start with, is any form of concurrency compatible with an object-oriented language? Have a look at E, which is a distributed message-passing OO language. http://www.erights.org/#2levels Tony. -- f.a.n.finch http://dotat.at/ ROCKALL: NORTHEAST VEERING SOUTHEAST 3 OR 4, OCCASIONALLY 5 IN NORTH AT FIRST. SLIGHT OR MODERATE. MAINLY FAIR, WITH FOG PATCHES. MODERATE OR GOOD, OCCASIONALLY VERY POOR. From xpdoka@REDACTED Fri May 4 13:42:32 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Fri, 4 May 2007 13:42:32 +0200 (CEST) Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <200705041932.20715.als@iinet.net.au> References: <200705041839.43127.als@iinet.net.au> <463AF5EE.1050202@cs.ntua.gr> <200705041932.20715.als@iinet.net.au> Message-ID: <64969.194.206.248.205.1178278952.squirrel@www.geekisp.com> Hello Anthony, >> Learn to use =:= instead. It's more kosher. >> [...] >> But is it not an issue of performance; it's a problem in the >> semantics of the == operator. > > Please elaborate. The erlang manual is terse. For integer > arguments I can see no difference in semantics between the two. The manual is actually quite explicit on the subject. == performs implicit casts, unlike =:= and =/=. In particular: 1> 1.0 == 1. true 2> 1.0 =:= 1. false Regards, Dominic Williams http://www.dominicwilliams.net ---- From kostis@REDACTED Fri May 4 13:58:30 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 04 May 2007 13:58:30 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <17979.7139.696045.965491@antilipe.corelatus.se> References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> Message-ID: <463B1FE6.9040909@cs.ntua.gr> Matthias Lang asked me: > Is there something here I've missed, or are you just being AR? > > AFAIK, == doesn't do any coercing if both arguments are integers, > i.e. there is no danger at all in using == in the example below. Admittedly, because your example uses 'rem' it makes no difference. A sufficiently clever compiler could know out that 'rem'/2 returns an integer and change this to '=:='/2 automatically. However, BEAM does not do anything like that or takes advantage of type information. More generally, in an expression of the form X == 0, the compiler is only allowed to infer (and take advantage of this information by avoiding tests on tags) that X will be a number in the success branch. In an expression of the form X =:= 0, the compiler can easily infer that in the success branch X will be an integer. This is much better information, not only for optimization, but also for other tools (e.g. for Dialyzer). I've seen tons of places in Erlang code where people mean =:=/2 and they use ==/2. In my opinion this bad practice should change. Also, it is really a pity that Erlang does not have proper integer comparison operators and all of them (e.g. '>'/2) are overloaded for numbers. Kostis From rrerlang@REDACTED Fri May 4 16:02:19 2007 From: rrerlang@REDACTED (Robert Raschke) Date: Fri, 4 May 2007 15:02:19 +0100 Subject: [erlang-questions] included_application vs. application vs. ensure_started() Message-ID: <664f679b680782a6013c91dc15e3fb32@tombob.com> Hi, I'm looking into creating myself a release of a little Erlang program. This uses Yaws to expose a web interface. What are the recommendations on how to assemble the applications? Also what are the tradeoffs between these three approaches? 1. Use completely separate applications for yaws and myapp and have myapp call something like myapp:ensure_yaws_started/0 (which starts and configure yaws if needed) when it starts. 2. Use the applications entry in the myapp.app file to list yaws and that "just" call yaws_api:setconf/2 in myapp. 3. Use the included_applications in the myapp.app file to list yaws and then call yaws:start_embedded/3 inside myapp_supervisor. Thanks for any advice, Robby -- r dot raschke at tombob dot com From tobbe@REDACTED Fri May 4 16:43:54 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 04 May 2007 16:43:54 +0200 Subject: [erlang-questions] included_application vs. application vs. ensure_started() In-Reply-To: <664f679b680782a6013c91dc15e3fb32@tombob.com> References: <664f679b680782a6013c91dc15e3fb32@tombob.com> Message-ID: Hi, For my personal project I usually have a pretty straight-forward approach. I'm using autoconf and a nice start script. You can download an example if you'd like here: http://tpl.tornkvist.org/ Cheers, Tobbe Robert Raschke wrote: > Hi, > > I'm looking into creating myself a release of a little Erlang program. > This uses Yaws to expose a web interface. What are the > recommendations on how to assemble the applications? Also what are > the tradeoffs between these three approaches? > > 1. Use completely separate applications for yaws and myapp and have > myapp call something like myapp:ensure_yaws_started/0 (which > starts and configure yaws if needed) when it starts. > > 2. Use the applications entry in the myapp.app file to list yaws and > that "just" call yaws_api:setconf/2 in myapp. > > 3. Use the included_applications in the myapp.app file to list yaws > and then call yaws:start_embedded/3 inside myapp_supervisor. > > Thanks for any advice, > Robby > > -- > r dot raschke at tombob dot com > > From darius@REDACTED Fri May 4 18:33:48 2007 From: darius@REDACTED (Darius Bacon) Date: Fri, 4 May 2007 09:33:48 -0700 (PDT) Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: (martin.ankerl@gmail.com) References: Message-ID: <200705041633.l44GXmda093433@shell.accesscom.com> I had trouble following that code; next_factor/1 doesn't have a simple cohesive specification, it's more like just a label of a program point in a loop. Here's how I would write it. (My Erlang experience is limited, too.) -module(factor). -export([factor/1]). % Return a list of the prime factors of N in arbitrary order. factor(N) when is_integer(N), 1 < N -> factor(N, 2, []). % Return FD ++ Factors, where FD is the prime factors of N >= the test % divisor D. factor(N, D, Factors) -> if N < D*D -> [N|Factors]; 0 =:= N rem D -> factor(N div D, D, [D|Factors]); true -> factor(N, D + 1, Factors) end. > From: "Martin Ankerl" > > Hello everybody, I have just started learning Erlang and wrote one of > my first programs. It is a very simple prime factoring program, but it > works. I would appreciate comments about the programming style, is > this how Erlang code should be written? Any way to make it simpler? > > Here is the code: > > -module(factor). > -export([fact/1]). > > % c('factor'). > % factor:fact(123456723456789). > fact(1) -> > []; > fact(N) -> > % io:format("~w\n", [N]), > M = next_factor(N, 2, N rem 2), > [ M | fact(N div M) ]. > > % find the next factor > next_factor(_, M, 0) -> > M; > next_factor(N, N, _) -> > N; > next_factor(N, M, _) -> > next_factor(N, M+1, N rem (M+1)). > > -- > Martin Ankerl | http://martin.ankerl.com From rsaccon@REDACTED Fri May 4 19:02:15 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Fri, 4 May 2007 14:02:15 -0300 Subject: [erlang-questions] included_application vs. application vs. ensure_started() In-Reply-To: <664f679b680782a6013c91dc15e3fb32@tombob.com> References: <664f679b680782a6013c91dc15e3fb32@tombob.com> Message-ID: for having all the control and configuration at the same place i do in myapp : application:start(yaws); yaws_api:setconf/2 On 5/4/07, Robert Raschke wrote: > > Hi, > > I'm looking into creating myself a release of a little Erlang program. > This uses Yaws to expose a web interface. What are the > recommendations on how to assemble the applications? Also what are > the tradeoffs between these three approaches? > > 1. Use completely separate applications for yaws and myapp and have > myapp call something like myapp:ensure_yaws_started/0 (which > starts and configure yaws if needed) when it starts. > > 2. Use the applications entry in the myapp.app file to list yaws and > that "just" call yaws_api:setconf/2 in myapp. > > 3. Use the included_applications in the myapp.app file to list yaws > and then call yaws:start_embedded/3 inside myapp_supervisor. > > Thanks for any advice, > Robby > > -- > r dot raschke at tombob dot com > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Roberto Saccon -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Fri May 4 21:26:27 2007 From: anders.nygren@REDACTED (Anders Nygren) Date: Fri, 4 May 2007 14:26:27 -0500 Subject: [erlang-questions] mnesia:restore Message-ID: Hi In the mnesia documentation it says about restore/2, "If the database is huge, it may not be possible to restore it online. In such cases, the old database must be restored by installing a fallback and then restart." Does anyone have any guidelines for what huge means in this context? /Anders From jla415@REDACTED Sat May 5 01:11:24 2007 From: jla415@REDACTED (jla415) Date: Fri, 4 May 2007 16:11:24 -0700 (PDT) Subject: [erlang-questions] Building R11B-4 fails on Kubuntu 7.04 Feisty Fawn In-Reply-To: <00F11EC6-702E-4406-A53C-7706BC34328F@hates.ms> References: <00F11EC6-702E-4406-A53C-7706BC34328F@hates.ms> Message-ID: <10331833.post@talk.nabble.com> I've had this happen before, it happens when you try to compile otp without having m4 installed. the build process leaves around the empty file that was supposed to generated with m4 so you need to remove this file and start the build over after you install m4. the easiest way to do this is just to remove the entire otp source directory and re-extract the source archive and do the configure && make dance all over again. Mihai Balea wrote: > > I trying to build OTP R11B-4 on a freshly installed Kubuntu 7.04 > Feisty Fawn. I am getting the following build error: > > mihai@REDACTED:~/dld/otp_src_R11B-4$ make > cd erts/emulator && ERL_TOP=/home/mihai/dld/otp_src_R11B-4 make > generate depend > make[1]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ > emulator' > make -f i686-pc-linux-gnu/Makefile generate > make[2]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ > emulator' > gcc -g -O3 -I/home/mihai/dld/otp_src_R11B-4/erts/i686-pc-linux-gnu - > D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - > DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT - > D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict- > prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE - > D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/ > common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib - > Ihipe -I../include/internal -I../include/internal/i686-pc-linux-gnu - > c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/ > hipe_mkliterals.o > hipe/hipe_mkliterals.c:351: error: ?X86_LEAF_WORDS? undeclared here > (not in a function) > hipe/hipe_mkliterals.c:352: error: ?X86_NR_ARG_REGS? undeclared here > (not in a function) > make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] Error 1 > make[2]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ > emulator' > make[1]: *** [generate] Error 2 > make[1]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ > emulator' > make: *** [depend] Error 2 > > I used the following configure command: > > ./configure --enable-smp-support --enable-threads --disable-hipe > > I tried first with --enable-hipe but got the same result. > > Any suggestions on how to fix this? > > Thanks in advance > Mihai > > PS: R11B-4 used to build just fine on Kubuntu 6.10 Edgy > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Building-R11B-4-fails-on-Kubuntu-7.04-Feisty-Fawn-tf3689122.html#a10331833 Sent from the Erlang Questions mailing list archive at Nabble.com. From toby@REDACTED Sat May 5 02:46:04 2007 From: toby@REDACTED (Toby Thain) Date: Fri, 4 May 2007 21:46:04 -0300 Subject: [erlang-questions] Building R11B-4 fails on Kubuntu 7.04 Feisty Fawn In-Reply-To: <10331833.post@talk.nabble.com> References: <00F11EC6-702E-4406-A53C-7706BC34328F@hates.ms> <10331833.post@talk.nabble.com> Message-ID: <220D1571-6565-4BCB-A23D-CEFBB1113028@smartgames.ca> On 4-May-07, at 8:11 PM, jla415 wrote: > > I've had this happen before, it happens when you try to compile otp > without > having m4 installed. the build process leaves around the empty > file that > was supposed to generated with m4 so you need to remove this file > and start > the build over after you install m4. the easiest way to do this is > just to > remove the entire otp source directory and re-extract Yes, 'make clean' used to be broken. I wonder if it's fixed yet. --Toby > the source archive and > do the configure && make dance all over again. > > > Mihai Balea wrote: >> >> I trying to build OTP R11B-4 on a freshly installed Kubuntu 7.04 >> Feisty Fawn. I am getting the following build error: >> >> mihai@REDACTED:~/dld/otp_src_R11B-4$ make >> cd erts/emulator && ERL_TOP=/home/mihai/dld/otp_src_R11B-4 make >> generate depend >> make[1]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ >> emulator' >> make -f i686-pc-linux-gnu/Makefile generate >> make[2]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ >> emulator' >> gcc -g -O3 -I/home/mihai/dld/otp_src_R11B-4/erts/i686-pc-linux- >> gnu - >> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - >> DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT - >> D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict- >> prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE - >> D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/ >> common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib - >> Ihipe -I../include/internal -I../include/internal/i686-pc-linux-gnu - >> c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/ >> hipe_mkliterals.o >> hipe/hipe_mkliterals.c:351: error: ?X86_LEAF_WORDS? undeclared here >> (not in a function) >> hipe/hipe_mkliterals.c:352: error: ?X86_NR_ARG_REGS? undeclared here >> (not in a function) >> make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] >> Error 1 >> make[2]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ >> emulator' >> make[1]: *** [generate] Error 2 >> make[1]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ >> emulator' >> make: *** [depend] Error 2 >> >> I used the following configure command: >> >> ./configure --enable-smp-support --enable-threads --disable-hipe >> >> I tried first with --enable-hipe but got the same result. >> >> Any suggestions on how to fix this? >> >> Thanks in advance >> Mihai >> >> PS: R11B-4 used to build just fine on Kubuntu 6.10 Edgy >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > -- > View this message in context: http://www.nabble.com/Building-R11B-4- > fails-on-Kubuntu-7.04-Feisty-Fawn-tf3689122.html#a10331833 > 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 diginux@REDACTED Sat May 5 17:30:12 2007 From: diginux@REDACTED (Jordan Wilberding) Date: Sat, 05 May 2007 10:30:12 -0500 Subject: [erlang-questions] : Deleting last line in the Erlang Shell In-Reply-To: <46310E47.1000706@it.uu.se> References: <20070425145042.499715A1FC@mail.erlangsystems.com> <462F6DC8.60104@erlang-consulting.com> <462F944F.5030701@diginux.net> <462FC5F9.2040801@diginux.net> <20070426071415.GB28408@erix.ericsson.se> <4630D778.6030801@diginux.net> <46310E47.1000706@it.uu.se> Message-ID: <463CA304.4080202@diginux.net> After messing around with it some more, it appears you are right. Any pointers or tips on how to go about writing a separate terminal driver? Thanks! Jordan Wilberding Richard Carlsson wrote: > Jordan Wilberding wrote: > >> That idea does not seem to work either. Once enter has been hit, it >> seems like it can't go back to erase that line. >> >> Maybe there is a way to catch the enter key? >> > > You're not likely to be able to achieve what you are trying to do as > long as you are reading buffered input from a terminal. Somebody who > knows more about the terminal driver in Erlang might be able to tell us > if it is at all possible without writing a separate driver. Anyone? > > /Richard > From mihai@REDACTED Sat May 5 17:34:15 2007 From: mihai@REDACTED (Mihai Balea) Date: Sat, 5 May 2007 11:34:15 -0400 Subject: [erlang-questions] Building R11B-4 fails on Kubuntu 7.04 Feisty Fawn In-Reply-To: <220D1571-6565-4BCB-A23D-CEFBB1113028@smartgames.ca> References: <00F11EC6-702E-4406-A53C-7706BC34328F@hates.ms> <10331833.post@talk.nabble.com> <220D1571-6565-4BCB-A23D-CEFBB1113028@smartgames.ca> Message-ID: Hi all, I would like to thank everybody that answered this thread. I managed to build it by doing a configure without any parameters. I did have m4 installed on my system before, so I don't think the problem was related to that. So it seems that everything worked out in the end. Mihai On May 4, 2007, at 8:46 PM, Toby Thain wrote: > > On 4-May-07, at 8:11 PM, jla415 wrote: > >> >> I've had this happen before, it happens when you try to compile otp >> without >> having m4 installed. the build process leaves around the empty >> file that >> was supposed to generated with m4 so you need to remove this file >> and start >> the build over after you install m4. the easiest way to do this is >> just to >> remove the entire otp source directory and re-extract > > Yes, 'make clean' used to be broken. I wonder if it's fixed yet. > > --Toby > >> the source archive and >> do the configure && make dance all over again. >> >> >> Mihai Balea wrote: >>> >>> I trying to build OTP R11B-4 on a freshly installed Kubuntu 7.04 >>> Feisty Fawn. I am getting the following build error: >>> >>> mihai@REDACTED:~/dld/otp_src_R11B-4$ make >>> cd erts/emulator && ERL_TOP=/home/mihai/dld/otp_src_R11B-4 make >>> generate depend >>> make[1]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ >>> emulator' >>> make -f i686-pc-linux-gnu/Makefile generate >>> make[2]: Entering directory `/home/mihai/dld/otp_src_R11B-4/erts/ >>> emulator' >>> gcc -g -O3 -I/home/mihai/dld/otp_src_R11B-4/erts/i686-pc-linux- >>> gnu - >>> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - >>> DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT - >>> D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict- >>> prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE - >>> D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/ >>> common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib - >>> Ihipe -I../include/internal -I../include/internal/i686-pc-linux- >>> gnu - >>> c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/ >>> hipe_mkliterals.o >>> hipe/hipe_mkliterals.c:351: error: ?X86_LEAF_WORDS? undeclared here >>> (not in a function) >>> hipe/hipe_mkliterals.c:352: error: ?X86_NR_ARG_REGS? undeclared here >>> (not in a function) >>> make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] >>> Error 1 >>> make[2]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ >>> emulator' >>> make[1]: *** [generate] Error 2 >>> make[1]: Leaving directory `/home/mihai/dld/otp_src_R11B-4/erts/ >>> emulator' >>> make: *** [depend] Error 2 >>> >>> I used the following configure command: >>> >>> ./configure --enable-smp-support --enable-threads --disable-hipe >>> >>> I tried first with --enable-hipe but got the same result. >>> >>> Any suggestions on how to fix this? >>> >>> Thanks in advance >>> Mihai >>> >>> PS: R11B-4 used to build just fine on Kubuntu 6.10 Edgy >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> -- >> View this message in context: http://www.nabble.com/Building-R11B-4- >> fails-on-Kubuntu-7.04-Feisty-Fawn-tf3689122.html#a10331833 >> 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 > From paul-trapexit@REDACTED Sat May 5 21:40:06 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sat, 5 May 2007 12:40:06 -0700 (PDT) Subject: [erlang-questions] qlc dirty tables Message-ID: Hi. I'd like to do dirty reads with qlc. The dirty analog to mnesia:table was straightforward to implement. Therefore the fact that it is not there gives me pause. Is there a deep reason why mnesia:dirty_table doesn't exist? -- p Many parts of Iraq are stable now. But of course what we see on television is the one bombing a day that discourages everybody. -- First Lady Laura Bush From ulf.wiger@REDACTED Sat May 5 21:48:36 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sat, 5 May 2007 21:48:36 +0200 Subject: [erlang-questions] qlc dirty tables In-Reply-To: References: Message-ID: <6616D98C65DD514BA2E1DDC5F922315501C81652@esealmw115.eemea.ericsson.se> Try using mnesia:activity(async_dirty, Fun). You use a fun just as you would with mnesia:transaction/1, but mnesia will map all ops to corresponding dirty ops. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Paul Mineiro > Sent: den 5 maj 2007 21:40 > To: erlang-questions@REDACTED > Subject: [erlang-questions] qlc dirty tables > > Hi. > > I'd like to do dirty reads with qlc. The dirty analog to > mnesia:table was straightforward to implement. Therefore the > fact that it is not there gives me pause. > > Is there a deep reason why mnesia:dirty_table doesn't exist? > > -- p > > Many parts of Iraq are stable now. But of course what we see > on television is the one bombing a day that discourages everybody. > > -- First Lady Laura Bush > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From paul-trapexit@REDACTED Sat May 5 23:31:53 2007 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sat, 5 May 2007 14:31:53 -0700 (PDT) Subject: [erlang-questions] qlc parse error (?) Message-ID: This might be a bug; if so, i'll repost to erlang-bugs. The following ----------- Q = qlc:q ([ C || C <- mnesia:table (campaign), C#campaign.id =:= Id, C#campaign.status =:= online, A <- mnesia:table (account), A#account.id =:= C#campaign.account_id, A#account.status =:= C#campaign.status ]), ----------- results in ----------- Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.4 (abort with ^G) 1> { ok, offerdb_2 } = c (offerdb_2), offerdb_2:test (). ./offerdb_2.erl:none: error in parse transform 'qlc': {{badarg,{var,0,'Id'}}, [{erl_parse,normalise,1}, {qlc_pt,'-qcon/1-lc$^1/1-1-',1}, {qlc_pt,'-qcon/1-lc$^0/1-0-',1}, {qlc_pt,qcon,1}, {qlc_pt,qdata,2}, {qlc_pt,qdata,2}, {qlc_pt,qdata,2}, {qlc_pt,qdata,2}]} ----------- although the following does not ----------- Q = qlc:q ([ C || C <- qlc:q ([ C || C <- mnesia:table (campaign), C#campaign.id =:= Id, C#campaign.status =:= online ]), A <- mnesia:table (account), A#account.id =:= C#campaign.account_id, A#account.status =:= C#campaign.status ]), ----------- Is this expected or a known problem? Attached is a complete file. Thanks in advance, -- p Many parts of Iraq are stable now. But of course what we see on television is the one bombing a day that discourages everybody. -- First Lady Laura Bush -------------- next part -------------- -module (offerdb_2). -include_lib("stdlib/include/qlc.hrl"). -include_lib("eunit/include/eunit.hrl"). -compile (export_all). -record (account, { id, status }). -record (campaign, { id, status, account_id }). start () -> mnesia:create_schema ([node ()]), mnesia:start (). stop () -> mnesia:stop (), mnesia:delete_schema ([node ()]). init () -> mnesia:create_table (account, [ { attributes, record_info (fields, account) } ]), mnesia:create_table (campaign, [ { attributes, record_info (fields, campaign) } ]). insert_account (Acc=#account{ }) -> mnesia:transaction (fun () -> mnesia:write (Acc) end). insert_campaign (Campaign=#campaign{ }) -> mnesia:transaction (fun () -> mnesia:write (Campaign) end). update_account_status (Id, Status) -> mnesia:transaction (fun () -> [ Acc ] = mnesia:read ({ account, Id }), mnesia:write (Acc#account{ status = Status}) end). update_campaign_status (Id, Status) -> mnesia:transaction (fun () -> [ Campaign ] = mnesia:read ({ campaign, Id }), mnesia:write (Campaign#campaign{ status = Status }) end). select_campaign (Id) -> % this doesn't Q = qlc:q ([ C || C <- mnesia:table (campaign), C#campaign.id =:= Id, C#campaign.status =:= online, A <- mnesia:table (account), A#account.id =:= C#campaign.account_id, A#account.status =:= C#campaign.status ]), % this works % % Q = qlc:q ([ C || % C <- qlc:q ([ C || % C <- mnesia:table (campaign), % C#campaign.id =:= Id, % C#campaign.status =:= online ]), % A <- mnesia:table (account), % A#account.id =:= C#campaign.account_id, % A#account.status =:= C#campaign.status ]), io:format (user, "~s~n", [ qlc:info (Q) ]), mnesia:async_dirty (fun () -> qlc:e (Q) end). basic_test_ () -> { setup, fun start/0, fun (_) -> stop () end, fun () -> init (), insert_account (#account{ id = 36#kfed, status = online }), insert_account (#account{ id = 36#brittney, status = offline }), insert_campaign (#campaign{ id = 36#playingwithfire, status = online, account_id = 36#kfed }), insert_campaign (#campaign{ id = 36#chaoticthedvd, status = offline, account_id = 36#kfed }), insert_campaign (#campaign{ id = 36#hitmebabyonemoretime, status = online, account_id = 36#brittney }), [ X ] = select_campaign (36#playingwithfire), ?assert (X#campaign.id =:= 36#playingwithfire), ?assert (X#campaign.status =:= online), ?assert (X#campaign.account_id =:= 36#kfed), Y = select_campaign (36#chaoticthedvd), ?assert (Y =:= []), Z = select_campaign (36#hitmebabyonemoretime), ?assert (Z =:= []) end }. From andrew@REDACTED Sun May 6 00:22:53 2007 From: andrew@REDACTED (andrew cooke) Date: Sat, 5 May 2007 18:22:53 -0400 (CLT) Subject: [erlang-questions] svn read access to some utilities (mainly url parsing). Message-ID: <5629.127.0.0.1.1178403773.squirrel@localhost> in case this is useful/interesting to anyone - https://acooke.dyndns.org:4443/repos/default/src/erlang/lib/trunk/README https://acooke.dyndns.org:4443/repos/default/src/erlang/lib/trunk feedback welcome. thanks, andrew From richardc@REDACTED Sun May 6 12:05:41 2007 From: richardc@REDACTED (Richard Carlsson) Date: Sun, 06 May 2007 12:05:41 +0200 Subject: [erlang-questions] : Deleting last line in the Erlang Shell In-Reply-To: <463CA304.4080202@diginux.net> References: <20070425145042.499715A1FC@mail.erlangsystems.com> <462F6DC8.60104@erlang-consulting.com> <462F944F.5030701@diginux.net> <462FC5F9.2040801@diginux.net> <20070426071415.GB28408@erix.ericsson.se> <4630D778.6030801@diginux.net> <46310E47.1000706@it.uu.se> <463CA304.4080202@diginux.net> Message-ID: <463DA875.9050104@it.uu.se> Jordan Wilberding wrote: > After messing around with it some more, it appears you are right. > > Any pointers or tips on how to go about writing a separate terminal driver? Not really my area. This might be what you need: http://forum.trapexit.org/viewtopic.php?t=6416&highlight=ncurses http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/slang/ /Richard > Richard Carlsson wrote: >> You're not likely to be able to achieve what you are trying to do as >> long as you are reading buffered input from a terminal. Somebody who >> knows more about the terminal driver in Erlang might be able to tell us >> if it is at all possible without writing a separate driver. Anyone? >> >> /Richard From ulf.wiger@REDACTED Sun May 6 15:04:20 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sun, 6 May 2007 15:04:20 +0200 Subject: [erlang-questions] atomic ets access sequences Message-ID: <6616D98C65DD514BA2E1DDC5F922315501C816E1@esealmw115.eemea.ericsson.se> After bashing ets, I will now venture to try to make it even dirtier than it already is. (: I've put together a BIF in erl_db.c (the ets "module"), called seq/3. Rather than posting the C code (which is certainly horrific, as I am no C programmer; it is also pretty bulky), I've written a reasonably equivalent Erlang function (attached). The main difference between the two, except for the C version being faster, is that the C version is atomic. It allows for some rudimentary lookups and selects, followed by updates (insert <> and delete), provided that the preconditions are met. I've so far only written one simple example: increment(Tab,Key,Incr), which increments a counter object if it exists, or creates it with a reasonable default (Incr), if it doesn't. This is what it looks like - ugly, but I think the main ugliness lies in the unavoidable select patterns: increment(Tab, Key, Incr) -> Pat = [{ {Key, '$1'}, [], [{{ Key, {'+','$1',Incr} }}] }], seq(Tab, [{1, bind, Pat}], [{foreach, 1, insert}, {if_nil, 1, [{insert, {Key, Incr}}]}]). (Explanation: The call is seq(Tab, Preconditions, Actions) The {1, bind, Pat} calls ets:select(Tab, Pat) and saves the result in a numbered slot (there are 10 of them). The foreach instruction takes each object in slot 1 and - in this case - calls ets:insert(Tab, Obj); the if_nil instruction is run if slot 1 contains []. It then initializes the counter object.) Here's where you get to provide feedback, shout heresy!! or perhaps ask to get the C code an help whip it into shape. Some of you may have good suggestions on how to make it more intuitive. I've tried to limit myself to actions that are unlikely to crash, once the preconditions are met. The biggest gripe of my own is that the function cannot be made to return anything other than true or false, but I've saturated my quota for prototyping in C for now. One use I had in mind is the extended process registry, which is currently dependent on sending all registrations to a gen_server. Using this function, registering a unique name could look like this: reg(Name) -> Pat = [{{{Name,rn,'_'}}, [], [true]}]}] seq(?REG, [{0, select_count, Pat], [{insert, [{{Name,rn,self()}}, {{self(),n,Name}}]). (The select_count pattern returns 1 if there is a reverse mapping of the name Name to any pid. We perform the insert action only if the select_count result is 0.) In a simple test, this turned out to be less than twice as fast as my Jungerl version (proc). This is a bit disappointing, but latency should be much improved, and a registry basically needs to be as lightweight as it can possibly be. Another obvious use would be a sort of transaction memory, where an object is first read, then modified, and later committed, assuming that the stored object hasn't been changed by someone else: commit(Tab, NewObj, OldObj) -> Pat = [{OldObj,[],[true]}], seq(Tab, [{0,select_count,Pat}], [{insert, NewObj}]). Anyway, there it is. Comments? BR, Ulf W -------------- next part -------------- A non-text attachment was scrubbed... Name: eets.erl Type: application/octet-stream Size: 4002 bytes Desc: eets.erl URL: From juneaftn@REDACTED Sun May 6 15:51:27 2007 From: juneaftn@REDACTED (June Kim) Date: Sun, 6 May 2007 22:51:27 +0900 Subject: [erlang-questions] running inets httpd on windows Message-ID: <6f80c1520705060651ve28e1dfs19af6db474c686e6@mail.gmail.com> I followed the steps in http://www.erlang.org/doc/doc-5.5.3/lib/inets-4.7.8/doc/html/part_frame.html I first created a server_root path as: C:\> mkdir \var\tmp\server_root and then created a file called "inets.config" at the path: [{inets, [{services, [{httpd, [{file,"/var/tmp/server_root/conf/8888.conf"}]}, {httpd, [{file,"/var/tmp/server_root/conf/8080.conf"}]}] } ] } ]. Now I copied the examples/server_root/* to C:\var\tmp\server_root\* as: C:\var\tmp\server_root>xcopy "c:\Program Files\erl5.5.3\lib\inets-4.7.8\examples \server_root" . /s Now run the erl shell as: C:\var\tmp\server_root>erl -config inets.config Eshell V5.5.3 (abort with ^G) 1> application:start(inets). =ERROR REPORT==== 6-May-2007::22:41:11 === failed to create child spec for [{file,"/var/tmp/server_root/conf/8888.conf"}] due to: "mod_auth: Server configuration missed AuthDBType directive" =ERROR REPORT==== 6-May-2007::22:41:11 === failed to create child spec for [{file,"/var/tmp/server_root/conf/8080.conf"}] due to: "httpd_conf: server_name must be specified in the config file" ok 2> If I comment out the ServerName line and remove mod_auth from Modules directive, it runs without any error report. It was a temporary makeshift, though. (What is the proper way to remove the errors?) I can go to http://localhost:8080 and visit some links there. However, http://localhost:8080/config.shtml and http://localhost:8080/exec.shtml didn't work. From juneaftn@REDACTED Sun May 6 15:58:34 2007 From: juneaftn@REDACTED (June Kim) Date: Sun, 6 May 2007 22:58:34 +0900 Subject: [erlang-questions] running inets httpd on windows In-Reply-To: <6f80c1520705060651ve28e1dfs19af6db474c686e6@mail.gmail.com> References: <6f80c1520705060651ve28e1dfs19af6db474c686e6@mail.gmail.com> Message-ID: <6f80c1520705060658r3d6c79cfm8d00b04b64fa6363@mail.gmail.com> > http://localhost:8080/config.shtml > http://localhost:8080/exec.shtml The reason that the two links above didn't work was, there was some *nixism in the file, such as:


The ERROR REPORT thing still remains though. 2007/5/6, June Kim : > I followed the steps in > http://www.erlang.org/doc/doc-5.5.3/lib/inets-4.7.8/doc/html/part_frame.html > > I first created a server_root path as: > > C:\> mkdir \var\tmp\server_root > > and then created a file called "inets.config" at the path: > > [{inets, > [{services, [{httpd, [{file,"/var/tmp/server_root/conf/8888.conf"}]}, > {httpd, [{file,"/var/tmp/server_root/conf/8080.conf"}]}] > } > ] > } > ]. > > Now I copied the examples/server_root/* to C:\var\tmp\server_root\* as: > > C:\var\tmp\server_root>xcopy "c:\Program Files\erl5.5.3\lib\inets-4.7.8\examples > \server_root" . /s > > Now run the erl shell as: > > C:\var\tmp\server_root>erl -config inets.config > Eshell V5.5.3 (abort with ^G) > 1> application:start(inets). > > =ERROR REPORT==== 6-May-2007::22:41:11 === > failed to create child spec for > [{file,"/var/tmp/server_root/conf/8888.conf"}] > due to: "mod_auth: Server configuration missed AuthDBType directive" > > =ERROR REPORT==== 6-May-2007::22:41:11 === > failed to create child spec for > [{file,"/var/tmp/server_root/conf/8080.conf"}] > due to: "httpd_conf: server_name must be specified in the config file" > ok > 2> > > If I comment out the ServerName line and remove mod_auth from Modules > directive, it runs without any error report. It was a temporary > makeshift, though. (What is the proper way to remove the errors?) > > I can go to http://localhost:8080 and visit some links there. However, > http://localhost:8080/config.shtml and > http://localhost:8080/exec.shtml didn't work. > From martin.ankerl@REDACTED Sun May 6 21:00:41 2007 From: martin.ankerl@REDACTED (Martin Ankerl) Date: Sun, 6 May 2007 21:00:41 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit Message-ID: Hi all, I am not sure if this is the correct place to post this, but anyway: I have written a syntax highlighting definition file for my favourite editor gedit (a Linux editor, this uses gtksourceview which means other editors that use this component should work too). You can get it here: http://martin.ankerl.com/2007/05/06/erlang-syntax-highlighting/ have fun, Martin From jcarrascal@REDACTED Mon May 7 01:29:11 2007 From: jcarrascal@REDACTED (=?UTF-8?Q?Julio_C=C3=A9sar_Carrascal_Urquijo_(MCTS)?=) Date: Sun, 6 May 2007 18:29:11 -0500 Subject: [erlang-questions] UTF-8 support. Message-ID: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> Does OTP supports Unicode strings? I was looking for UTF-8 support in the module list but couldn't find anything like it. Thanks. -- Julio C?sar Carrascal Urquijo Microsoft Certified Technology Specialist http://jcesar.3stecnoinformatica.com/ From vances@REDACTED Mon May 7 01:46:40 2007 From: vances@REDACTED (Vance Shipley) Date: Sun, 6 May 2007 19:46:40 -0400 Subject: [erlang-questions] per function/process locals In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> Message-ID: <20070506234640.GA51101@frogman.motivity.ca> On Wed, May 02, 2007 at 01:21:41PM +0200, Ulf Wiger (TN/EAB) wrote: } } As it's not a great idea to export records in an API, } I often prefer to take a property list as input. Ulf, Can you elaborate on why using a record in an API is a bad thing? -Vance From hokan.stenholm@REDACTED Mon May 7 02:03:37 2007 From: hokan.stenholm@REDACTED (=?UTF-8?B?SMOla2FuIFN0ZW5ob2xt?=) Date: Mon, 07 May 2007 02:03:37 +0200 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> Message-ID: <463E6CD9.5000909@bredband.net> Julio C?sar Carrascal Urquijo (MCTS) wrote: > Does OTP supports Unicode strings? I was looking for UTF-8 support in > the module list but couldn't find anything like it. > No not really, string operations (e.g. case conversion) usually assume that strings are lists of latin-1 character codes no bigger than 255. xmerl can produce lists of unicode code points, when parsing xml containing various forms of UTF encodings - so there is some support for getting unicode data. Note to other readers: unicode code points don't always match a single letter, the letter '?' can for example be represented by the unicode code point for the letter 'a' and the code point for the o-ring. If you don't need to do string comparisons (which may require various forms of unicode normalizations - as certain letters like '?' have more than one representation), is probably easiest to store the unicode data either as a utf-8 string (byte string / binary) or as a list of unicode code points. xmerl has some functions (you may need to look at the source code) to convert unicode codepoints to/from various UTF encodings. ps: does anyone know if there are any other useful unicode related tools that can be used with erlang ? > Thanks. > > From ok@REDACTED Mon May 7 03:44:05 2007 From: ok@REDACTED (ok) Date: Mon, 7 May 2007 13:44:05 +1200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: Message-ID: On 4 May 2007, at 7:20 pm, Martin Ankerl wrote: > Hello everybody, I have just started learning Erlang and wrote one of > my first programs. It is a very simple prime factoring program which examines a whole lot of trial divisors that are not primes. Not only that, after it has found a successful divisor M, on the next iteration it will try 2..M-1 unsuccessfully all over again. The second clause of next_factor/3 is useless; any calls that might have matched it will match the first clause instead (because N rem N is 0). It is rather unpleasant the way the caller does the remainder instead of next_factor/3 itself. So let's try this: factors(N) when integer(N), N >= 1 -> search(2, N, []). search(M, N, L) when M*N > N -> lists:reverse(case N of 1 -> L ; _ -> [N|L] end); search(M, N, L) when N rem M == 0 -> search(M, N div N, [M|L]); search(M, N, L) -> search(M+1, N, L). Note that I've replaced the "N = 1" termination test by an "M*M > N" termination test. For the reason, consider what happens when N is a large prime number. The main ideas behind these changes are entirely language-independent. From ok@REDACTED Mon May 7 04:02:44 2007 From: ok@REDACTED (ok) Date: Mon, 7 May 2007 14:02:44 +1200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <463B1FE6.9040909@cs.ntua.gr> References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> <463B1FE6.9040909@cs.ntua.gr> Message-ID: On 4 May 2007, at 11:58 pm, Kostis Sagonas wrote: > I've seen tons of places in Erlang code where people mean =:=/2 and > they use ==/2. In my opinion this bad practice should change. Also, > it is really a pity that Erlang does not have proper integer > comparison > operators and all of them (e.g. '>'/2) are overloaded for numbers. In fact I just made this "mistake" in the improved factorising code I posted. My excuse is that Erlang, which came *after* Prolog and which uses Prolog-based syntax, gets =:= and == completely back-to-front from the way Prolog has them. In Prolog, == means "exact identity" and =:= means "numerically equal after evaluation". I cannot imagine why Erlang swapped them. I keep on tripping up over this. From jeffm@REDACTED Mon May 7 07:23:51 2007 From: jeffm@REDACTED (jm) Date: Mon, 07 May 2007 15:23:51 +1000 Subject: [erlang-questions] crazy thoughts: inittab and erl node Message-ID: <463EB7E7.7010708@ghostgun.com> Has anyone attempted to start an erlang node from inittab? For example, something like n0:2345:/usr/sbin/erl -noshell or for the more crazy out there doing embedded systems: Replacing /sbin/init with an erlang node? Now I've have no idea what the advantage or disadvantages of such a set up would be. It's just a random thought that occured to me and I was interested to know if anyone had tried it. Jeff. From ulf@REDACTED Mon May 7 08:16:12 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 7 May 2007 08:16:12 +0200 Subject: [erlang-questions] per function/process locals In-Reply-To: <20070506234640.GA51101@frogman.motivity.ca> References: <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> <20070506234640.GA51101@frogman.motivity.ca> Message-ID: <8209f740705062316i32940a73mdda86633ec26d6be@mail.gmail.com> 2007/5/7, Vance Shipley : > > On Wed, May 02, 2007 at 01:21:41PM +0200, Ulf Wiger (TN/EAB) wrote: > } > } As it's not a great idea to export records in an API, > } I often prefer to take a property list as input. > > Ulf, > > Can you elaborate on why using a record in an API is a bad thing? > > -Vance Records depend on the preprocessor, and therefore introduce a compile-time dependency between modules. When using e.g. property lists, which are admittedly slower than records, adding a new property is easy. If you use a record, the users of the API must recompile in order to be compatible, even if they don't use the new option. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.bolinder@REDACTED Mon May 7 08:48:54 2007 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Mon, 7 May 2007 08:48:54 +0200 Subject: [erlang-questions] qlc parse error (?) In-Reply-To: References: Message-ID: <17982.52182.676154.42930@gargle.gargle.HOWL> [Paul Mineiro:] > The following > > ----------- > Q = qlc:q ([ C || > C <- mnesia:table (campaign), > C#campaign.id =:= Id, > C#campaign.status =:= online, > A <- mnesia:table (account), > A#account.id =:= C#campaign.account_id, > A#account.status =:= C#campaign.status ]), > ----------- > > results in > > ----------- > Erlang (BEAM) emulator version 5.5.4 [source] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.5.4 (abort with ^G) > > 1> { ok, offerdb_2 } = c (offerdb_2), offerdb_2:test (). > ./offerdb_2.erl:none: error in parse transform 'qlc': {{badarg,{var,0,'Id'}}, > [{erl_parse,normalise,1}, > {qlc_pt,'-qcon/1-lc$^1/1-1-',1}, > {qlc_pt,'-qcon/1-lc$^0/1-0-',1}, > {qlc_pt,qcon,1}, > {qlc_pt,qdata,2}, > {qlc_pt,qdata,2}, > {qlc_pt,qdata,2}, > {qlc_pt,qdata,2}]} Thanks! The attached patch will be part of R11B-5. Best regards, Hans Bolinder, Erlang/OTP team *** qlc_pt.erl Mon Apr 2 15:43:21 2007 --- /usr/local/otp/releases/otp_beam_solaris8_r11b_patched/lib/stdlib-1.14.4/src/qlc_pt.erl Tue Mar 27 21:11:38 2007 *************** *** 1705,1711 **** {nil,L}. qcon(Cs) -> ! list2cons([{tuple,0,[{integer,0,C},list2cons(Vs)]} || {C,Vs} <- Cs]). %% The original code (in Source) is used for filters and the template %% since the translated code can have QLC expressions and we don't --- 1705,1711 ---- {nil,L}. qcon(Cs) -> ! abstr([{C,[erl_parse:normalise(V) || V <- Vs]} || {C,Vs} <- Cs], 0). %% The original code (in Source) is used for filters and the template %% since the translated code can have QLC expressions and we don't From nm@REDACTED Mon May 7 09:33:33 2007 From: nm@REDACTED (Gaspar Chilingarov) Date: Mon, 07 May 2007 12:33:33 +0500 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <463E6CD9.5000909@bredband.net> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> Message-ID: <463ED64D.3080100@web.am> > xmerl has some functions (you may need to look at the source code) to > convert unicode codepoints to/from various UTF encodings. > > look in xmerl_ucs module functions like xmerl_ucs:from_utf8, xmerl_ucs:to_utf8 and etc ;) -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From ingela@REDACTED Mon May 7 09:41:01 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 07 May 2007 09:41:01 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 10, Issue 15 In-Reply-To: References: Message-ID: <463ED80D.8080100@erix.ericsson.se> erlang-questions-request@REDACTED wrote: [...] > C:\var\tmp\server_root>erl -config inets.config > Eshell V5.5.3 (abort with ^G) > 1> application:start(inets). > > =ERROR REPORT==== 6-May-2007::22:41:11 === > failed to create child spec for > [{file,"/var/tmp/server_root/conf/8888.conf"}] > due to: "mod_auth: Server configuration missed AuthDBType directive" > You need to define the directive AuthDBType for that configuration. (As it is done in the 8080.conf) This example was created very long ago and probably has not been kept up to date over the years. It is currently on the todo list for improvements of inets. > =ERROR REPORT==== 6-May-2007::22:41:11 === > failed to create child spec for > [{file,"/var/tmp/server_root/conf/8080.conf"}] > due to: "httpd_conf: server_name must be specified in the config file" > ok > Server name is a mandatory directive. It is commented out in the example files but should be uncommented and given an appropriate value. Regards Ingela - OTP team From headspin@REDACTED Mon May 7 11:13:47 2007 From: headspin@REDACTED (dda) Date: Mon, 7 May 2007 11:13:47 +0200 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <463E6CD9.5000909@bredband.net> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> Message-ID: I have a module that manages strings and different encodings ? not only utf-8 but also exotic encodings found and used in Asia. It is not complete, but is more or less functional. I have mentioned before on this list but didn't seem to attract interest. Should some people be interested in such a tool, please contact me offlist, as I would be more than willing to give it away to the community. My current job prevents me to do much coding anyway. -- Didier On 5/7/07, H?kan Stenholm wrote: > Note to other readers: unicode code points don't always match a single > letter, the letter '?' can for example be represented by the unicode > code point for the letter 'a' and the code point for the o-ring. > > ps: does anyone know if there are any other useful unicode related tools > that can be used with erlang ? From dmitriid@REDACTED Mon May 7 11:22:11 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Mon, 07 May 2007 12:22:11 +0300 Subject: [erlang-questions] UTF-8 support. In-Reply-To: References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> Message-ID: <463EEFC3.6010105@gmail.com> dda wrote: > I have a module that manages strings and different encodings ? not > only utf-8 but also exotic encodings found and used in Asia. It is not > complete, but is more or less functional. I have mentioned before on > this list but didn't seem to attract interest. Should some people be > interested in such a tool, please contact me offlist, as I would be > more than willing to give it away to the community. My current job > prevents me to do much coding anyway. > > You could post it to Google Code, for example... From richardc@REDACTED Mon May 7 11:29:41 2007 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 07 May 2007 11:29:41 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> <463B1FE6.9040909@cs.ntua.gr> Message-ID: <463EF185.2030007@it.uu.se> ok wrote: > In Prolog, == means "exact identity" and > =:= means "numerically equal after evaluation". I cannot imagine why > Erlang swapped them. I keep on tripping up over this. Probably so that the shorter symbol represents the term order, which is probably what the authors considered the more important equality. (I'm not taking a stand here, just making a guess.) For two terms X and Y, one of X < Y, X == Y, or X > Y is always true. If you substitute =:= for ==, none of them is true if e.g. X is 0 and Y is 0.0. I haven't programmed in Prolog in a long time, so I don't recall how this is handled there. Isn't there a :< and :> or somesuch? Here's a mistake I've seen in code that partitions elements: if X > Y -> ...; X =:= Y -> ...; X < Y -> ... end this actually throws an if_clause error if X is 0 and Y is 0.0. In fact, for this kind of code, the explicit test for equality is redundant and should be skipped in order to avoid problems: if X > Y -> ...; X < Y -> ...; true -> ... end now, in the last case, we know that X==Y. (Removing the extra test also makes the code more efficient.) But this is when you want to compare elements in the term order (arithmetic equivalence); when you want exact equality, use =:=. /Richard From bjorn@REDACTED Mon May 7 11:29:43 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 07 May 2007 11:29:43 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> <463B1FE6.9040909@cs.ntua.gr> Message-ID: ok writes: > In fact I just made this "mistake" in the improved factorising code I > posted. My excuse is that Erlang, which came *after* Prolog and which > uses Prolog-based syntax, gets =:= and == completely back-to-front from > the way Prolog has them. In Prolog, == means "exact identity" and > =:= means "numerically equal after evaluation". I cannot imagine why > Erlang swapped them. I keep on tripping up over this. I think that the reason is that floats was not originally in the Erlang language, but was added later. /Bj?rn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From tobbe@REDACTED Mon May 7 11:48:37 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Mon, 07 May 2007 11:48:37 +0200 Subject: [erlang-questions] UTF-8 support. In-Reply-To: References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> Message-ID: dda wrote: > I have a module that manages strings and different encodings ? not > only utf-8 but also exotic encodings found and used in Asia. It is not > complete, but is more or less functional. I have mentioned before on > this list but didn't seem to attract interest. Should some people be > interested in such a tool, please contact me offlist, as I would be > more than willing to give it away to the community. My current job > prevents me to do much coding anyway. > You can post it on www.trapexit.org in the User Contributions forum. Cheers, Tobbe From xpdoka@REDACTED Mon May 7 12:34:10 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Mon, 7 May 2007 12:34:10 +0200 (CEST) Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: References: Message-ID: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> Hi Martin, > I have written a syntax highlighting definition file for my > favourite editor gedit [...] Thanks, that's useful. If you care to improve it, you might want to handle the following code properly (which confuses the emacs mode too, BTW. How about erlide, and vim ?). ascii_values() -> [$a, $\n, $", $1, $2]. multi_line() -> " This is a multi-line string ". Regards, Dominic Williams http://www.dominicwilliams.net ---- From vladdu55@REDACTED Mon May 7 13:23:34 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 7 May 2007 13:23:34 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> Message-ID: <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> Hi, These work just fine in erlide. /Vlad On 5/7/07, Dominic Williams wrote: > Thanks, that's useful. If you care to improve it, you might want > to handle the following code properly (which confuses the > emacs mode too, BTW. How about erlide, and vim ?). > > ascii_values() -> > [$a, $\n, $", $1, $2]. > > multi_line() -> > " > This > is a > multi-line string > ". From martin.ankerl@REDACTED Mon May 7 16:30:35 2007 From: martin.ankerl@REDACTED (Martin Ankerl) Date: Mon, 7 May 2007 16:30:35 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> Message-ID: > ascii_values() -> > [$a, $\n, $", $1, $2]. The problem is that for $" and $' gedit thinks that you start a string, I could not find a way to format this correctly. A workaround is to write $\" and $\' . I have already posted this problem to the gtksourceview's bugzilla. I have already fixed the multiline comment, this should work with the current version. -- Martin Ankerl | http://martin.ankerl.com From adam@REDACTED Mon May 7 16:58:06 2007 From: adam@REDACTED (Adam Lindberg) Date: Mon, 7 May 2007 16:58:06 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> Message-ID: <6344005f0705070758i2329eb1re9a74266a9f65d57@mail.gmail.com> It would be cool if you could submit this to be included by default in Gedit. Would be nice when you startup for example Ubuntu for the first time and .erl files highlight by default. ;-) Cheers! Adam On 5/7/07, Martin Ankerl wrote: > > ascii_values() -> > > [$a, $\n, $", $1, $2]. > > The problem is that for $" and $' gedit thinks that you start a > string, I could not find a way to format this correctly. A workaround > is to write $\" and $\' . I have already posted this problem to the > gtksourceview's bugzilla. > > I have already fixed the multiline comment, this should work with the > current version. > > -- > Martin Ankerl | http://martin.ankerl.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From martin.ankerl@REDACTED Mon May 7 17:01:33 2007 From: martin.ankerl@REDACTED (Martin Ankerl) Date: Mon, 7 May 2007 17:01:33 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <6344005f0705070758i2329eb1re9a74266a9f65d57@mail.gmail.com> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> <6344005f0705070758i2329eb1re9a74266a9f65d57@mail.gmail.com> Message-ID: On 5/7/07, Adam Lindberg wrote: > It would be cool if you could submit this to be included by default in > Gedit. Would be nice when you startup for example Ubuntu for the first > time and .erl files highlight by default. ;-) Ive submitted a bugzilla entry to gtksourceview with the language file, but the write that their policy is to only include language files when freedesktop can detect the mime type correctly, so Ive written a bugreport there too. So in theory it is only a matter of time until it is included :-) -- Martin Ankerl | http://martin.ankerl.com From jim@REDACTED Mon May 7 20:39:06 2007 From: jim@REDACTED (Jim Thompson) Date: Mon, 07 May 2007 08:39:06 -1000 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <463EB7E7.7010708@ghostgun.com> References: <463EB7E7.7010708@ghostgun.com> Message-ID: <463F724A.1030101@netgate.com> jm wrote: > Has anyone attempted to start an erlang node from inittab? For example, > something like > > n0:2345:/usr/sbin/erl -noshell > > or for the more crazy out there doing embedded systems: Replacing > /sbin/init with an erlang node? Now I've have no idea what the advantage > or disadvantages of such a set up would be. It's just a random thought > that occured to me and I was interested to know if anyone had tried it. If you did this, how would you configure networking, perform filesystem checks, etc? From sean.hinde@REDACTED Mon May 7 21:34:45 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Mon, 7 May 2007 20:34:45 +0100 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <463EB7E7.7010708@ghostgun.com> References: <463EB7E7.7010708@ghostgun.com> Message-ID: On 7 May 2007, at 06:23, jm wrote: > Has anyone attempted to start an erlang node from inittab? For > example, > something like > > n0:2345:/usr/sbin/erl -noshell > > or for the more crazy out there doing embedded systems: Replacing > /sbin/init with an erlang node? Now I've have no idea what the > advantage > or disadvantages of such a set up would be. It's just a random thought > that occured to me and I was interested to know if anyone had tried > it. This post thread refers to one such project started: http://forum.trapexit.org/viewtopic.php?t=2440 I'm not sure if it ever ran, but Tony probably has the code filed away somewhere ;-) Sean From yerl@REDACTED Mon May 7 22:29:42 2007 From: yerl@REDACTED (Yerl) Date: Mon, 07 May 2007 22:29:42 +0200 Subject: [erlang-questions] xmerl tutorial Message-ID: <463F8C36.2060301@club-internet.fr> Hi! Is there any good tutorial about xmerl? (not the current doc please) cheers Youn?s From vladdu55@REDACTED Mon May 7 22:32:05 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 7 May 2007 20:32:05 +0000 Subject: [erlang-questions] Service platform (longish rant) Message-ID: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> Hello everyone! Let's see if I can express some ideas in an understandable way: Chapter 1 -------------- There have been discussions about how to implement in Erlang something like Haskell's monads. For example http://www.erlang.org/ml-archive/erlang-questions/200503/msg00029.html or http://www.erlang.org/ml-archive/erlang-questions/200302/msg00499.html. Now, monads are rather abstract things that don't really feel at home in Erlang (at least not in my eyes), not even if they were called "warm fuzzy things" instead :-) What I think is interesting in the first discussion thread mentioned, is the problem of chaining together function calls in a way that is easy to make changes, without using temporary variables whose names may create confusion or errors. Ulf Wiger had in the first message above implemented a solution in a nice way, but he admits later that he tried to use macros to get rid of writing all the "fun()->" wrappers, but gave up. The example was with(Dict, Actions) -> lists:foldl(fun(F,D) -> F(D) end, Dict, Actions). Dict = with(Dict0, [fun(D) -> read_options_file(D) end, fun(D) -> store_options(Options, D) end, fun(D) -> post_process_options(D) end, fun(D) -> {Path, [App, Vsn]} = get_app(D), store_options([{app_name, list_to_atom(App)}, {app_vsn, Vsn}], D) end, ................... I agree, not very friendly, but it works. Chapter 2 -------------- One of the keys of Unix' success is its toolkit of utilities whose functionality can be composed through the use of pipes and redirection. These utilities can also be seen as services provided by the platform. Erlang processes are also service providers. Even function calls can be regarded as such. But compared to the Unix ones, they are not as easily composeable. Compare ls | grep "*.erl" | sort | head -n 1 with hd(sort(grep(ls(), "*.erl"))) In the first case, the dataflow is clear, left to right. In the other it is reversed and slightly encumbered by helper arguments. It is easier to see what is going on if writing Files = grep(ls(), "*.erl), hd(sort(Files)) but this is much more verbose. If message sending and receiving would be involved, then we either have to wrap them with function calls, accept an even more verbose and difficult to compose syntax or use Joe's proposed !! operator. I like the latter idea best, then the example would look like (assuming all operations above are implemented as processes) Files = grep !! {ls(), "*.erl"}, hd(sort !! Files) or on a single line, hd(sort !! (grep !! {ls(), "*.erl"})) A bit disturbing, in my opinion. The with/2 function from Chapter 1 would work nicely to solve this issue, if reimplemented as with(Dict, Actions) -> lists:foldl(fun(F,D) when is_function(F) -> F(D); (F, D) -> F !! D end, Dict, Actions). Grand finale ----------------- I would like to suggest a syntax addition that would allow an even nicer looking source code (if I may say that myself :). ls() => grep(_?_, "*.erl") %% _?_ is a reserved variable, %% meaning "the current intermediate value" => sort %% this is a process name, could be a pid => hd/1 The operator would be semantically equivalent to with(ls(), [fun(X) -> grep(X, "*.erl") end, sort, fun hd/1]) If intermediate values need to be saved, writing Term => UnboundVariable => Next would bind UnboundVariable to the current result value and UnboundVariable will be accessible in the subsequent scope. This operator could also serve as a kind of extended currying operator: Term => f(Var, atom, _?_, 3.14) where the currying isn't restricted to the last of the formal parameters. The exact syntax is of course provisional, but I hope you get the idea. IMHO, this might be a case where the syntactic change brings enough benefit that might outweigh the downside of having extra syntactic constructs. Suggestions for better syntax are most welcome and so is criticism. best regards, Vlad From robert.virding@REDACTED Mon May 7 23:28:36 2007 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 07 May 2007 23:28:36 +0200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> <463B1FE6.9040909@cs.ntua.gr> Message-ID: <463F9A04.9070807@telia.com> Bjorn Gustavsson wrote: > ok writes: > >> In fact I just made this "mistake" in the improved factorising code I >> posted. My excuse is that Erlang, which came *after* Prolog and which >> uses Prolog-based syntax, gets =:= and == completely back-to-front from >> the way Prolog has them. In Prolog, == means "exact identity" and >> =:= means "numerically equal after evaluation". I cannot imagine why >> Erlang swapped them. I keep on tripping up over this. > > I think that the reason is that floats was not originally in the Erlang > language, but was added later. > Originally it was that. When floats were introduced we had a LONG discussion on whether to have automatic type conversion of numbers for numerical operators or not. Eventually we decided to do this and then it was natural to do that in comparisons as well. Then we found we needed the exact comparison to use in matching so it was added as an operator available to users. In retrospect we should have added the whole spectrum of term comparison operators and given them a uniform appearance. Perhaps something like @==, @/=, @<, @=<, @>, @>=. We took alot from Prolog so why did we not use '\' in operators but use '/'. Good question, next question. I am still not 100% certain that having automatic type conversion of numbers was a Good Thing. I know everyone else (or at least most) do it and that it is usually convenient, but still .... At least that is how I remember it. Robert > /Bj?rn From alex.arnon@REDACTED Tue May 8 00:10:51 2007 From: alex.arnon@REDACTED (Alex Arnon) Date: Tue, 8 May 2007 01:10:51 +0300 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <463EB7E7.7010708@ghostgun.com> References: <463EB7E7.7010708@ghostgun.com> Message-ID: <944da41d0705071510n64dcffd2hcb959c8009d1e220@mail.gmail.com> On 5/7/07, jm wrote: > > Has anyone attempted to start an erlang node from inittab? For example, > something like > > n0:2345:/usr/sbin/erl -noshell > > or for the more crazy out there doing embedded systems: Replacing > /sbin/init with an erlang node? Now I've have no idea what the advantage > or disadvantages of such a set up would be. It's just a random thought > that occured to me and I was interested to know if anyone had tried it. > > > Jeff. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > The simplest would be to run it as an S script at the appropriate runlevel. Why bother with inittab, even? Unix's init cannot be trivially replaced, as it spawns several critical kernel threads, and manages runlevels as well. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim@REDACTED Tue May 8 00:43:16 2007 From: jim@REDACTED (Jim Thompson) Date: Mon, 07 May 2007 12:43:16 -1000 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <944da41d0705071510n64dcffd2hcb959c8009d1e220@mail.gmail.com> References: <463EB7E7.7010708@ghostgun.com> <944da41d0705071510n64dcffd2hcb959c8009d1e220@mail.gmail.com> Message-ID: <463FAB84.6000501@netgate.com> Alex Arnon wrote: > Unix's init cannot be trivially replaced, as it spawns several critical > kernel threads, and manages runlevels as well. untrue. Many embedded systems use /bin/sh as a replacement for init, and, in fact, on linux (at least) you can pass "init=/bin/sh" to the kernel, and init won't be invoked at all, you'll be left at a rudimentary '#' prompt, and will need to check/mount non-root filesystems, etc. The runlevels stuff is just you telling init what to do, plus a bit of processing to interpret things like 'power is failing'. Having "init" start kernel threads would involve init loading modules into the kernel, (see: http://www.scs.ch/~frey/linux/kernelthreads.html) No such thing happens (on an otherwise 'stock' system, anyway.) But you are correct, that starting an erlang system from a boot script is likely the 'right thing', though if you've got two (or more) erlang "processes" protecting each other, you might have a difficult time killing them on shutdown. Jim From alex.arnon@REDACTED Tue May 8 00:59:00 2007 From: alex.arnon@REDACTED (Alex Arnon) Date: Tue, 8 May 2007 01:59:00 +0300 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <463FAB84.6000501@netgate.com> References: <463EB7E7.7010708@ghostgun.com> <944da41d0705071510n64dcffd2hcb959c8009d1e220@mail.gmail.com> <463FAB84.6000501@netgate.com> Message-ID: <944da41d0705071559k7c80c86fh6b84fedd79945696@mail.gmail.com> On 5/8/07, Jim Thompson wrote: > > Alex Arnon wrote: > > > Unix's init cannot be trivially replaced, as it spawns several critical > > kernel threads, and manages runlevels as well. > > untrue. Many embedded systems use /bin/sh as a replacement for init, > and, in fact, on linux (at least) you can pass "init=/bin/sh" to the > kernel, and init won't be invoked at all, you'll be left at a > rudimentary '#' prompt, and will need to check/mount non-root > filesystems, etc. > > The runlevels stuff is just you telling init what to do, plus a bit of > processing to interpret things like 'power is failing'. > > Having "init" start kernel threads would involve init loading modules > into the kernel, (see: http://www.scs.ch/~frey/linux/kernelthreads.html) > No such thing happens (on an otherwise 'stock' system, anyway.) > > But you are correct, that starting an erlang system from a boot script > is likely the 'right thing', though if you've got two (or more) erlang > "processes" protecting each other, you might have a difficult time > killing them on shutdown. > > Jim > > Indeed, 'init' is replaceable, and runlevels are a kind of convenience (which some Unix-like systems, such as some of the BSDs, do without). The kernel threads I was speaking of are usually privileged processes such as the swapper/pager, which are different between systems. On embedded systems with no HD, of course, these can be discarded as well. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roger.larsson@REDACTED Tue May 8 01:18:35 2007 From: roger.larsson@REDACTED (Roger Larsson) Date: Tue, 8 May 2007 01:18:35 +0200 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> Message-ID: <200705080118.36018.roger.larsson@norran.net> On Monday 07 May 2007 22:32, Vlad Dumitrescu wrote: > The example was > > with(Dict, Actions) -> > lists:foldl(fun(F,D) -> > F(D) > end, Dict, Actions). > > Dict = with(Dict0, > [fun(D) -> read_options_file(D) end, > fun(D) -> store_options(Options, D) end, > fun(D) -> post_process_options(D) end, > fun(D) -> > {Path, [App, Vsn]} = get_app(D), > store_options([{app_name, list_to_atom(App)}, > {app_vsn, Vsn}], D) > end, > ................... > > I agree, not very friendly, but it works. But it can be simplified to Dict = with(Dict0, [fun read_options_file/1, fun(D) -> store_options(Options, D) end, fun post_process_options/1, fun(D) -> {Path, [App, Vsn]}=get_app(D), store_options(([{app_name, list_to_atom(App)}, {app_vsn, Vsn}], D) end, ... ]). An alternative definition of 'with' could be with(Dict, []) -> Dict; with(Dict, [A|LaterA]) when is_function(A,1) -> with(A(Dict), LaterA). In both cases functions in current module with one argument can be listed like: fun name/1 external functions with one argument can be listed like: fun module:name/1 or even {module, name} But I guess it all boils down to Dict1=read_options_file(Dict0), Dict2=store_options(Options, Dict1), Dict3=post_process_options(Dict2), {Path, [App, Vsn]}=get_app(Dict3), Dict4=store_options( [{app_name, list_to_atom(App)}, {app_vsn, Vsn}]) beeing kind of ugly and hard to update - add a line (Basic anyone)... But on the other hand here you can notice some strange looking things - is the store_options really expected to return a modified Dict - if not why doesn't post_process_options get Dict1 - and if store_options does not return a Dict why is it feed to post_process_options - ... Note that all versions but your process based lacks one component from the Unix pipes - concurrency! The 'ls' is not required to finish before the final 'head', rather when head is finished the pipe is terminated. > Grand finale > ----------------- > I would like to suggest a syntax addition that would allow an even > nicer looking source code (if I may say that myself :). > > ls() => grep(_?_, "*.erl") %% _?_ is a reserved variable, > %% meaning "the current > intermediate value" > => sort %% this is a process name, could be a > pid => hd/1 But what is the output from ls()? Complete listing? One line? One char? ls() => sort => hd/1 Same issue for sort, and hd/1... (sort would not like one char at the time...) > > The operator would be semantically equivalent to > > with(ls(), > [fun(X) -> grep(X, "*.erl") end, > sort, > fun hd/1]) > > If intermediate values need to be saved, writing > Term => UnboundVariable => Next > would bind UnboundVariable to the current result value and > UnboundVariable will be accessible in the subsequent scope. This would require the complete result to be passed in each step... /RogerL From jeffm@REDACTED Tue May 8 01:53:20 2007 From: jeffm@REDACTED (jm) Date: Tue, 08 May 2007 09:53:20 +1000 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: References: <463EB7E7.7010708@ghostgun.com> Message-ID: <463FBBF0.6080100@ghostgun.com> Sean Hinde wrote: > > On 7 May 2007, at 06:23, jm wrote: > >> Has anyone attempted to start an erlang node from inittab? For example, >> something like >> >> n0:2345:/usr/sbin/erl -noshell >> >> or for the more crazy out there doing embedded systems: Replacing >> /sbin/init with an erlang node? Now I've have no idea what the advantage >> or disadvantages of such a set up would be. It's just a random thought >> that occured to me and I was interested to know if anyone had tried it. > > This post thread refers to one such project started: > > http://forum.trapexit.org/viewtopic.php?t=2440 > > I'm not sure if it ever ran, but Tony probably has the code filed away > somewhere ;-) > Interesting thread. Do you know how far the project got? I started on this train of thought by thinking about how cut down a system could get and still be useful. One of the problems with embedded linux is the tendency to have a root shell to use linux as a normal unix system rather than a fully customised system. (Think the CLI on a router or similar device). While this is not always a major problem and can get you out of the occasional tight corner, it makes the product look a little unpolished. I read else where that ericsson was using a base OS plus one (possibly more) erlang nodes on top which lead me to thinking about this. Anyone there with experience with such systems care to comment on how these units are set up? As to the question Jim raised in another email about setting up networking, etc. I'd imagine using a port based around something like busy box. Jeff. From ok@REDACTED Tue May 8 04:27:09 2007 From: ok@REDACTED (ok) Date: Tue, 8 May 2007 14:27:09 +1200 Subject: [erlang-questions] learning Erlang: factoring primes In-Reply-To: <463EF185.2030007@it.uu.se> References: <17978.58835.365627.41516@antilipe.corelatus.se> <463AE9C3.4050207@cs.ntua.gr> <17979.7139.696045.965491@antilipe.corelatus.se> <463B1FE6.9040909@cs.ntua.gr> <463EF185.2030007@it.uu.se> Message-ID: <529EF825-9FAF-437B-A1E9-195F13BB5928@cs.otago.ac.nz> On 7 May 2007, at 9:29 pm, Richard Carlsson wrote: > ok wrote: >> In Prolog, == means "exact identity" and >> =:= means "numerically equal after evaluation". I cannot imagine why >> Erlang swapped them. I keep on tripping up over this. > > For two terms X and Y, one of X < Y, X == Y, or X > Y is always true. > If you substitute =:= for ==, none of them is true if e.g. X is 0 and > Y is 0.0. I haven't programmed in Prolog in a long time, so I don't > recall how this is handled there. Isn't there a :< and :> or somesuch? Prolog has two sets of comparison operators: Term comparison: @< @=< == @> @>= \== Arithmetic comparison: < =< =:= > >= =\= There are three major differences: (1) The arithmetic comparison predicates evaluate their arguments as arithmetic expressions; term comparison ones don't. (2) Arithmetic comparisons regard numerically equal numbers as equal, even when they are of different types. So 0 =:= 0.0 (even though 0 \== 0.0) and 0.0 =:= -0.0 (even though 0.0 \== -0.0) (3) Term comparison is a total order; even restricted to numbers arithmetic comparison is only a partial order (thanks to IEEE arithmetic) even when restricted to numbers. Apparently thinking that the only significant difference was (1), and noting that Erlang evaluates function arguments, the Erlang designers started out by identifying term comparison and arithmetic comparison. When floating point was added, they noticed difference (2) and, to put it bluntly, wrecked term comparison. Note that 2 < 2.0 2 > 2.0 are both false; this means that the "term comparison" operators now completely fail to discriminate terms that are observably different. Worse still, it is downright EASY to find three terms X, Y, Z such that X == Y Y == Z X < Z Example: W = 1 bsl 66, X = W - 1, Z = W + 1, Y = float(W), {X == Y, Y == Z, X < Z}. The answer is {true,true,true}. Whatever happened to "things which are equal to the same thing are equal to each other"? DO YOU TRUST A SORTING FUNCTION IN A LANGUAGE THAT GETS COMPARISON THIS WRONG? Not me, or at any rate only when very carefully and explicitly limited to date where it works. (The same problem shows up in other languages. The problem is that the 'floating point contagion' rule which is appropriate when COMBINING values is not appropriate for COMPARING them. When you compare a floating-point number with a large integer, you should act AS IF you converted the floating point number to an exact rational, rather than converting the integer.) The result is unsatisfactory in yet a third way. EITHER < conforms to IEEE rules, in which case term ordering is NOT a total order, or it doesn't, in which case it's not what we want as an arithmetic order, or you forbid IEEE infinities and NaNs, in which case you have a really terrible time interfacing with other people's code which does NOT forbid those things (which were, after all, put in the standard for excellent reasons). If you want to ship floating point numbers around the net (and we have some people here who like to do that kind of thing) you DON'T want some strange language refusing to pass your data through! Term order and arithmetic order really are different, and it's NOT just in the equality comparison that the differences show up. > Here's a mistake I've seen in code that partitions elements: > > if X > Y -> ...; > X =:= Y -> ...; > X < Y -> ... > end This is where Prolog and Haskell shine: case compare x y of LT -> ... EQ -> ... GT -> ... From ulf@REDACTED Tue May 8 08:26:00 2007 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 8 May 2007 08:26:00 +0200 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <200705080118.36018.roger.larsson@norran.net> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> <200705080118.36018.roger.larsson@norran.net> Message-ID: <8209f740705072326j697b42f0g88c9543fb6df315@mail.gmail.com> 2007/5/8, Roger Larsson : > > > But I guess it all boils down to > Dict1=read_options_file(Dict0), > Dict2=store_options(Options, Dict1), > Dict3=post_process_options(Dict2), > {Path, [App, Vsn]}=get_app(Dict3), > Dict4=store_options( > [{app_name, list_to_atom(App)}, > {app_vsn, Vsn}]) > beeing kind of ugly and hard to update - add a line (Basic anyone)... > But on the other hand here you can notice some strange looking things > - is the store_options really expected to return a modified Dict Yes, it takes all the options and actually puts them in Dict, giving special treatment to the {report,Level} option. The example is taken from the 'builder' module in Jungerl. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Tue May 8 09:41:27 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 8 May 2007 09:41:27 +0200 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <200705080118.36018.roger.larsson@norran.net> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> <200705080118.36018.roger.larsson@norran.net> Message-ID: <95be1d3b0705080041r4f0df934q62773059c0fc655f@mail.gmail.com> Hi, On 5/8/07, Roger Larsson wrote: > On Monday 07 May 2007 22:32, Vlad Dumitrescu wrote: > > The example was > > ................... > > But it can be simplified to > That was just an example, taken from a previous discussion. > Note that all versions but your process based lacks one component from the > Unix pipes - concurrency! The 'ls' is not required to finish before the > final 'head', rather when head is finished the pipe is terminated. Yes, that could be a possible requirement. However, there's nothing to say that the compiler won't implement all links in the chain (even functional ones) as simple processes. > > ls() => grep(_?_, "*.erl") %% _?_ is a reserved variable, > > %% meaning "the current > > intermediate value" > > => sort %% this is a process name, could be a > > pid => hd/1 > > But what is the output from ls()? Complete listing? One line? One char? > ls() => sort => hd/1 > Same issue for sort, and hd/1... (sort would not like one char at the time...) That is up to the particular service. Of course, services having different format assumptions won't be easy to pipe together. But I would personally choose a structured data format over the raw text used in the Unix world. For this particular example, I would have ls() return a list of file descriptions if implemented as a function. The result list could be lazily constructed behind the scenes, if the framework could handle it transparently (by hiding the continuation passing infrastructure). If ls() is implemented as a process, the result could be returned as a sequence of messages containing list chunks, basically forming a lazy list too. [Yes, if ls() returns structured data, the next step shouldn't be called 'grep', but again, it is an example] > > If intermediate values need to be saved, writing > > Term => UnboundVariable => Next > > would bind UnboundVariable to the current result value and > > UnboundVariable will be accessible in the subsequent scope. > > This would require the complete result to be passed in each step... Yes and no. There are two options: * Some steps are eager, not lazy. The same applies to something like sorting, where it's not useful to sort partial data. * Or the value reflects the data sent until the current moment, and even sort's output would be the sorted list of partial data. But this is an even larger step away from Erlang as we know it, so it would take a lot more thinking about what it really means. It feels like a different computational model, data-flow based, where the '=>' operator is defining a data stream between two entities. I have been looking at that too. I realize that these are delicate matters. I wanted to test the response before going further. best regards, Vlad From erlang@REDACTED Tue May 8 12:34:57 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 8 May 2007 12:34:57 +0200 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <95be1d3b0705080041r4f0df934q62773059c0fc655f@mail.gmail.com> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> <200705080118.36018.roger.larsson@norran.net> <95be1d3b0705080041r4f0df934q62773059c0fc655f@mail.gmail.com> Message-ID: <9b08084c0705080334le700f74mc0a429461cebcf4e@mail.gmail.com> I think that all this gets rather complicated because we are thinking at the wrong abstraction level. I'd really like to see what lies behind the pipes. When you do "A | B | C" the pipe symbol is really hiding a lot of significant detail. The pipe is really a rather complicated thing which hides all sorts of details like flow-control, buffering etc. I can imagine a more complex notation Suppose we can "open up" the "|" operator, so we can see inside The A | B really means A |< P >| B Where P is a process P(A, B) := A ? M -> B ! M, P(A,B) To chain things through pipes I think you need to explicitly state the pipe types chain([ fun() -> make_a() end, fun() -> make_standard_pipe() end, fun() -> make_b() end ]) where make_standard_pipe() makes a simple buffered pipe etc. What would be really nice would be to implement "persistent infinite fault-tolerant with global end-point names" pipes (for want of a better name) with a defined protocol to get stuff in and out of the pipes (this would be something like the amazon simple queue service) Just for fun it might be nice to try and make one of these using a defined representation of a pipe Suppose a pipe descriptor is a tuple like this: {pipe, Name, [{Host1,Port2},{Host2,Port2},{Host3,Port2}]} meaning that pipe called name is stored on three machine accessible through {Host, Port} Then it should be pretty easy to hack together an API to store and retrieve tuples to the pipe store (assume also an out-of-band way of distributing suitable crypto keys to secure the pipe). What I havn't thought about is the pipe <-> appliciation protocols (some kind or peep/getHead/deleteHead/alertOnNewEntry protocol is needed) Then you just need a bit of syntax to expand A | B | ... into code that stores and fetches objects from the pipes. This could make a nice lightweight varient of amazons queue stuff without all the implementation mess of SOAP etc. Cheers /Joe On 5/8/07, Vlad Dumitrescu wrote: > Hi, > > On 5/8/07, Roger Larsson wrote: > > On Monday 07 May 2007 22:32, Vlad Dumitrescu wrote: > > > The example was > > > ................... > > > > But it can be simplified to > > > > That was just an example, taken from a previous discussion. > > > Note that all versions but your process based lacks one component from the > > Unix pipes - concurrency! The 'ls' is not required to finish before the > > final 'head', rather when head is finished the pipe is terminated. > > Yes, that could be a possible requirement. However, there's nothing to > say that the compiler won't implement all links in the chain (even > functional ones) as simple processes. > > > > ls() => grep(_?_, "*.erl") %% _?_ is a reserved variable, > > > %% meaning "the current > > > intermediate value" > > > => sort %% this is a process name, could be a > > > pid => hd/1 > > > > But what is the output from ls()? Complete listing? One line? One char? > > ls() => sort => hd/1 > > Same issue for sort, and hd/1... (sort would not like one char at the time...) > > That is up to the particular service. Of course, services having > different format assumptions won't be easy to pipe together. But I > would personally choose a structured data format over the raw text > used in the Unix world. > > For this particular example, I would have ls() return a list of file > descriptions if implemented as a function. The result list could be > lazily constructed behind the scenes, if the framework could handle it > transparently (by hiding the continuation passing infrastructure). > > If ls() is implemented as a process, the result could be returned as a > sequence of messages containing list chunks, basically forming a lazy > list too. > > [Yes, if ls() returns structured data, the next step shouldn't be > called 'grep', but again, it is an example] > > > > If intermediate values need to be saved, writing > > > Term => UnboundVariable => Next > > > would bind UnboundVariable to the current result value and > > > UnboundVariable will be accessible in the subsequent scope. > > > > This would require the complete result to be passed in each step... > > Yes and no. There are two options: > * Some steps are eager, not lazy. The same applies to something like > sorting, where it's not useful to sort partial data. > * Or the value reflects the data sent until the current moment, and > even sort's output would be the sorted list of partial data. But this > is an even larger step away from Erlang as we know it, so it would > take a lot more thinking about what it really means. It feels like a > different computational model, data-flow based, where the '=>' > operator is defining a data stream between two entities. I have been > looking at that too. > > I realize that these are delicate matters. I wanted to test the > response before going further. > > best regards, > Vlad > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Tue May 8 12:55:15 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 8 May 2007 12:55:15 +0200 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <9b08084c0705080334le700f74mc0a429461cebcf4e@mail.gmail.com> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> <200705080118.36018.roger.larsson@norran.net> <95be1d3b0705080041r4f0df934q62773059c0fc655f@mail.gmail.com> <9b08084c0705080334le700f74mc0a429461cebcf4e@mail.gmail.com> Message-ID: <95be1d3b0705080355u530361d3icd6b2e3d9cca46e@mail.gmail.com> Hi, On 5/8/07, Joe Armstrong wrote: > When you do "A | B | C" the pipe symbol is really hiding a lot of significant > detail. The pipe is really a rather complicated thing which hides all sorts of > details like flow-control, buffering etc. I can imagine a more complex notation > > Suppose we can "open up" the "|" operator, so we can see inside > > The A | B really means > > A |< P >| B > > Where P is a process > > P(A, B) := A ? M -> B ! M, P(A,B) Very good points. Up to here I have similar ideas, but didn't want to get into much details especially since there's a lot more to think about. There are also other ways to implement this (for example, depending on what the exact requirements are, the hidden process need not be a real process but can be simulated with continuation passing) The even more generic step, for a global queue service, I hadn't considered, but it feels important to do that, as from a customer point of view this use case has more impact than "just" some syntax to make things easier for programmers :-) Thanks for the input! best regards, Vlad From toby@REDACTED Tue May 8 15:05:13 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 8 May 2007 09:05:13 -0400 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <463EEFC3.6010105@gmail.com> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> <463EEFC3.6010105@gmail.com> Message-ID: <44CCAE53-58BF-486B-8155-52F1AC2A7A79@smartgames.ca> On 7-May-07, at 5:22 AM, Dmitrii 'Mamut' Dimandt wrote: > dda wrote: >> I have a module that manages strings and different encodings ? not >> only utf-8 but also exotic encodings found and used in Asia. It is >> not >> complete, but is more or less functional. I have mentioned before on >> this list but didn't seem to attract interest. Should some people be >> interested in such a tool, please contact me offlist, as I would be >> more than willing to give it away to the community. My current job >> prevents me to do much coding anyway. >> >> > You could post it to Google Code, for example... Yes, just first make sure the license is clear. --Toby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Tue May 8 15:08:29 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 8 May 2007 09:08:29 -0400 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <463F724A.1030101@netgate.com> References: <463EB7E7.7010708@ghostgun.com> <463F724A.1030101@netgate.com> Message-ID: <7407856F-7BDF-4E41-8DA1-13C3341EC5C8@smartgames.ca> On 7-May-07, at 2:39 PM, Jim Thompson wrote: > jm wrote: >> Has anyone attempted to start an erlang node from inittab? For >> example, >> something like >> >> n0:2345:/usr/sbin/erl -noshell >> >> or for the more crazy out there doing embedded systems: Replacing >> /sbin/init with an erlang node? Now I've have no idea what the >> advantage >> or disadvantages of such a set up would be. It's just a random >> thought >> that occured to me and I was interested to know if anyone had >> tried it. > > If you did this, how would you configure networking, perform > filesystem > checks, etc? That all happens before init is started. --T > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jim@REDACTED Tue May 8 16:42:51 2007 From: jim@REDACTED (Jim Thompson) Date: Tue, 08 May 2007 04:42:51 -1000 Subject: [erlang-questions] crazy thoughts: inittab and erl node In-Reply-To: <7407856F-7BDF-4E41-8DA1-13C3341EC5C8@smartgames.ca> References: <463EB7E7.7010708@ghostgun.com> <463F724A.1030101@netgate.com> <7407856F-7BDF-4E41-8DA1-13C3341EC5C8@smartgames.ca> Message-ID: <46408C6B.6080201@netgate.com> Toby Thain wrote: >> If you did this, how would you configure networking, perform filesystem >> checks, etc? > > That all happens before init is started. No, it doesn't. Certainly some kernels can configure networking during startup, but most do not, leaving the job to the various 'run levels' (really'rc' shell scripts), which in-turn, (typically) run shell scripts to accomplish these tasks. jim@REDACTED:~$ uname -a Linux he-colo.netgate.com 2.4.26 #3 SMP Thu Jul 15 20:01:46 PDT 2004 i686 GNU/Linux jim@REDACTED:~$ grep rc /etc/inittab si::sysinit:/etc/init.d/rcS l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 jim@REDACTED:~$ egrep -ilr ifup\|ifdown /etc/rc* /etc/rc0.d/S35networking /etc/rc6.d/S35networking /etc/rcS.d/S39ifupdown /etc/rcS.d/S40networking /etc/rcS.d/S18ifupdown-clean jim@REDACTED:~$ ... started by init. While this was linux, freebsd (and the other BSDs) are largely the same. > uname -a FreeBSD freebsd.netgate.com 6.0-RC1 FreeBSD 6.0-RC1 #0: Thu Oct 20 00:50:53 PDT 2005 jim@REDACTED:/usr/obj/usr/src/sys/GENERIC i386 > grep /etc/rc.d /etc/rc files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` > egrep -l ifconfig\|fsck /etc/rc.d/* /etc/rc.d/atm1 /etc/rc.d/bgfsck /etc/rc.d/dhclient /etc/rc.d/early.sh /etc/rc.d/fsck /etc/rc.d/ip6addrctl /etc/rc.d/netif /etc/rc.d/network_ipv6 /etc/rc.d/pflog /etc/rc.d/pfsync /etc/rc.d/root /etc/rc.d/rtadvd /etc/rc.d/sppp > From waldemar.rachwal@REDACTED Tue May 8 19:37:03 2007 From: waldemar.rachwal@REDACTED (Waldemar Rachwal) Date: Tue, 8 May 2007 19:37:03 +0200 Subject: [erlang-questions] bit-level binaries Message-ID: It was mentioned a few months ago (I missed the thread) that a bit-level binaries (augmented perhaps by binary comprehensions) might come with a next release. I guess such a big feature should come with a major release, but when it could happen then (I haven't figured out the cycle of B-0's)? (I admit SMP is very cool these days, but the slides from '05 EUC http://www.erlang.se/euc/05/1640PerKostis.pdf still impress me a lot). Regards, WR. From bob@REDACTED Tue May 8 20:11:47 2007 From: bob@REDACTED (Bob Ippolito) Date: Tue, 8 May 2007 11:11:47 -0700 Subject: [erlang-questions] bit-level binaries In-Reply-To: References: Message-ID: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> On 5/8/07, Waldemar Rachwal wrote: > It was mentioned a few months ago (I missed the thread) that a > bit-level binaries (augmented perhaps by binary comprehensions) might > come with a next release. I guess such a big feature should come with > a major release, but when it could happen then (I haven't figured out > the cycle of B-0's)? > > (I admit SMP is very cool these days, but the slides from '05 EUC > http://www.erlang.se/euc/05/1640PerKostis.pdf still impress me a lot). I believe that bit-level binaries were introduced in R11B-3 with shell support in R11B-4. From my notes it requires some compiler directives: -compile([binary_comprehension, bitlevel_binaries]). I haven't tried it yet... -bob From fpierfed@REDACTED Tue May 8 20:27:47 2007 From: fpierfed@REDACTED (Francesco Pierfederici) Date: Tue, 8 May 2007 11:27:47 -0700 Subject: [erlang-questions] bit-level binaries In-Reply-To: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> References: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> Message-ID: <1d7144ea0705081127i251cb149se1dbe06c161ee64c@mail.gmail.com> Hi, I can confirm that bitlevel binaries do indeed work on R11B-4 (haven't tried any other release). As Bob said, you need to compile using the bitlevel_binaries option. Cheers, Francesco On 5/8/07, Bob Ippolito wrote: > On 5/8/07, Waldemar Rachwal wrote: > > It was mentioned a few months ago (I missed the thread) that a > > bit-level binaries (augmented perhaps by binary comprehensions) might > > come with a next release. I guess such a big feature should come with > > a major release, but when it could happen then (I haven't figured out > > the cycle of B-0's)? > > > > (I admit SMP is very cool these days, but the slides from '05 EUC > > http://www.erlang.se/euc/05/1640PerKostis.pdf still impress me a lot). > > I believe that bit-level binaries were introduced in R11B-3 with shell > support in R11B-4. From my notes it requires some compiler directives: > > -compile([binary_comprehension, bitlevel_binaries]). > > I haven't tried it yet... > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From nm@REDACTED Tue May 8 20:49:10 2007 From: nm@REDACTED (Gaspar Chilingarov) Date: Tue, 08 May 2007 23:49:10 +0500 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> Message-ID: <4640C626.1010009@web.am> Vlad Dumitrescu wrote: > Hi, > > These work just fine in erlide. same in Vim /Gaspar > > On 5/7/07, Dominic Williams wrote: >> Thanks, that's useful. If you care to improve it, you might want >> to handle the following code properly (which confuses the >> emacs mode too, BTW. How about erlide, and vim ?). >> >> ascii_values() -> >> [$a, $\n, $", $1, $2]. >> >> multi_line() -> >> " >> This >> is a >> multi-line string >> ". > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From timuckun@REDACTED Tue May 8 22:56:44 2007 From: timuckun@REDACTED (Tim Uckun) Date: Wed, 9 May 2007 08:56:44 +1200 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <44CCAE53-58BF-486B-8155-52F1AC2A7A79@smartgames.ca> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> <463EEFC3.6010105@gmail.com> <44CCAE53-58BF-486B-8155-52F1AC2A7A79@smartgames.ca> Message-ID: <855e4dcf0705081356y1220318et98aa0a8886540343@mail.gmail.com> > > > dda wrote: > >> I have a module that manages strings and different encodings ? not > >> only utf-8 but also exotic encodings found and used in Asia. It is > >> not > >> complete, but is more or less functional. I have mentioned before on > >> this list but didn't seem to attract interest. Should some people be > >> interested in such a tool, please contact me offlist, as I would be > >> more than willing to give it away to the community. My current job > >> prevents me to do much coding anyway. > >> > >> > > You could post it to Google Code, for example... > > Yes, just first make sure the license is clear. Perhaps it could be submitted to CEAN. From christophe.romain@REDACTED Tue May 8 23:12:38 2007 From: christophe.romain@REDACTED (Christophe Romain) Date: Tue, 8 May 2007 23:12:38 +0200 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <855e4dcf0705081356y1220318et98aa0a8886540343@mail.gmail.com> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> <463EEFC3.6010105@gmail.com> <44CCAE53-58BF-486B-8155-52F1AC2A7A79@smartgames.ca> <855e4dcf0705081356y1220318et98aa0a8886540343@mail.gmail.com> Message-ID: <7273A789-1C97-4C86-9F13-80DB4DCB9C05@process-one.net> > Perhaps it could be submitted to CEAN. to submit something to CEAN, one must follow the packaging guide http://cean.process-one.net/contrib/packaging-guide.txt the code must be accessible from the net (svn/cvs/tar/tgz/tbz2/erl) and the packager must send me the .pub file which describe the package. regards. From martin.ankerl@REDACTED Tue May 8 23:13:36 2007 From: martin.ankerl@REDACTED (Martin Ankerl) Date: Tue, 8 May 2007 23:13:36 +0200 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <4640C626.1010009@web.am> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> <4640C626.1010009@web.am> Message-ID: > > These work just fine in erlide. > > same in Vim multiline works for me too, but [$a, $\n, $", $1, $2]. does not in my vim, both $\n and $" is a problem. Which version do you use? I have 7.0.164. -- Martin Ankerl | http://martin.ankerl.com From toby@REDACTED Wed May 9 05:01:15 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 8 May 2007 23:01:15 -0400 Subject: [erlang-questions] UTF-8 support. In-Reply-To: <7273A789-1C97-4C86-9F13-80DB4DCB9C05@process-one.net> References: <7f3901c50705061629v73d4c620u879c7235329522e9@mail.gmail.com> <463E6CD9.5000909@bredband.net> <463EEFC3.6010105@gmail.com> <44CCAE53-58BF-486B-8155-52F1AC2A7A79@smartgames.ca> <855e4dcf0705081356y1220318et98aa0a8886540343@mail.gmail.com> <7273A789-1C97-4C86-9F13-80DB4DCB9C05@process-one.net> Message-ID: On 8-May-07, at 5:12 PM, Christophe Romain wrote: >> Perhaps it could be submitted to CEAN. > > to submit something to CEAN, one must follow the packaging guide > http://cean.process-one.net/contrib/packaging-guide.txt In my opinion, the code should be clearly licensed before being released (to CEAN or wherever). I'm surprised the packaging guide doesn't have a template for this; it's arguably the most important metadatum besides the author's name :-) --Toby > > the code must be accessible from the net (svn/cvs/tar/tgz/tbz2/erl) > and the packager must send me the .pub file which describe the > package. > > regards. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bjorn@REDACTED Wed May 9 09:01:01 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 09 May 2007 09:01:01 +0200 Subject: [erlang-questions] bit-level binaries In-Reply-To: <1d7144ea0705081127i251cb149se1dbe06c161ee64c@mail.gmail.com> References: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> <1d7144ea0705081127i251cb149se1dbe06c161ee64c@mail.gmail.com> Message-ID: Bit-level binaries are an unoffical feature for now. Use them at your own risk. We plan to support them fully in R12B. /Bjorn "Francesco Pierfederici" writes: > Hi, > > I can confirm that bitlevel binaries do indeed work on R11B-4 (haven't > tried any other release). As Bob said, you need to compile using the > bitlevel_binaries option. > > Cheers, > Francesco > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From tobbe@REDACTED Wed May 9 09:24:28 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 09 May 2007 09:24:28 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 Message-ID: Hi, The fd_server (see jungerl) does not work with R11B-4. I suspect it has to do with the following (excerpt from the release notes): > http://www.erlang.org/download/otp_src_R11B-4.readme > > OTP-6452 In the documentation of the driver entry field.... This is most unfortunate since fd_server is important for Yaws users that want to open up privileged ports. The following is what happends: )1> fdsrv:start(). {error,{error,{{error,driver_incorrect_version}, "/home/tobbe/blaha/lib/fd_server/priv"}}} A more complete testcase could be: fdsrv:start(). {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). gen_tcp:listen(81,[{fd, Fd}]). I've heard rumors that fd_server may be included in a future OTP releases. Could that be true ? Anyway, if anyone comes up with an updated driver, it would be mighty good if it could be put into jungerl. Cheers, Tobbe (Ps. Btw R11B-4 can't be built unless --disable-hipe is used [Debian 4. 0,Gentoo]) From mikma264@REDACTED Wed May 9 10:11:47 2007 From: mikma264@REDACTED (Mikael Magnusson) Date: Wed, 09 May 2007 10:11:47 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 In-Reply-To: References: Message-ID: <46418243.3050408@gmail.com> Torbjorn Tornkvist wrote: > Hi, > > The fd_server (see jungerl) does not work with R11B-4. > I suspect it has to do with the following (excerpt from > the release notes): > >> http://www.erlang.org/download/otp_src_R11B-4.readme >> >> OTP-6452 In the documentation of the driver entry field.... > > This is most unfortunate since fd_server is important for Yaws > users that want to open up privileged ports. The following is > what happends: > > )1> fdsrv:start(). > {error,{error,{{error,driver_incorrect_version}, > "/home/tobbe/blaha/lib/fd_server/priv"}}} > > A more complete testcase could be: > > fdsrv:start(). > {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). > gen_tcp:listen(81,[{fd, Fd}]). > > I've heard rumors that fd_server may be included in a future OTP > releases. Could that be true ? > > Anyway, if anyone comes up with an updated driver, it would be > mighty good if it could be put into jungerl. > > Cheers, Tobbe > (Ps. Btw R11B-4 can't be built unless --disable-hipe is used [Debian 4. > 0,Gentoo]) > It looks like inet_db:fdopen is at fault. The Family and Fd arguments are swapped in the call to prim_inet:fdopen. Diffing otp_src_R11B-3 otp_src_R11B-4: -fdopen(Fd, Opts, Type, Family, Module) -> - case prim_inet:fdopen(Type, Fd, Family) of +fdopen(Fd, Opts, Protocol, Family, Module) -> + case prim_inet:fdopen(Protocol, Family, Fd) of {ok, S} -> case prim_inet:setopts(S, Opts) of ok -> prim_inet --------- +fdopen(Protocol, Fd, inet) -> fdopen1(Protocol, ?INET_AF_INET, Fd); +fdopen(Protocol, Fd, inet6) -> fdopen1(Protocol, ?INET_AF_INET6, Fd); +fdopen(_, _, _) -> {error, einval}. Mikael From mikma264@REDACTED Wed May 9 10:26:47 2007 From: mikma264@REDACTED (Mikael Magnusson) Date: Wed, 09 May 2007 10:26:47 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 In-Reply-To: <46418243.3050408@gmail.com> References: <46418243.3050408@gmail.com> Message-ID: <464185C7.20102@gmail.com> Mikael Magnusson wrote: > Torbjorn Tornkvist wrote: >> Hi, >> >> The fd_server (see jungerl) does not work with R11B-4. >> I suspect it has to do with the following (excerpt from >> the release notes): >> >>> http://www.erlang.org/download/otp_src_R11B-4.readme >>> >>> OTP-6452 In the documentation of the driver entry field.... >> This is most unfortunate since fd_server is important for Yaws >> users that want to open up privileged ports. The following is >> what happends: >> >> )1> fdsrv:start(). >> {error,{error,{{error,driver_incorrect_version}, >> "/home/tobbe/blaha/lib/fd_server/priv"}}} >> >> A more complete testcase could be: >> >> fdsrv:start(). >> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). >> gen_tcp:listen(81,[{fd, Fd}]). >> >> I've heard rumors that fd_server may be included in a future OTP >> releases. Could that be true ? >> >> Anyway, if anyone comes up with an updated driver, it would be >> mighty good if it could be put into jungerl. >> >> Cheers, Tobbe >> (Ps. Btw R11B-4 can't be built unless --disable-hipe is used [Debian 4. >> 0,Gentoo]) >> > > It looks like inet_db:fdopen is at fault. The Family and Fd arguments > are swapped in the call to prim_inet:fdopen. Correction, it's inet:fdopen, and the following patch solves the problem: --- inet.erl.orig 2007-05-09 10:19:50.000000000 +0200 +++ inet.erl 2007-05-09 10:17:59.000000000 +0200 @@ -749,7 +749,7 @@ fdopen(Fd, Opts, Protocol, Family, Module). fdopen(Fd, Opts, Protocol, Family, Module) -> - case prim_inet:fdopen(Protocol, Family, Fd) of + case prim_inet:fdopen(Protocol, Fd, Family) of {ok, S} -> case prim_inet:setopts(S, Opts) of ok -> Output from patched R11B-4: 1> fdsrv:start(). {ok,<0.33.0>} 2> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). {ok,9} 3> gen_tcp:listen(81,[{fd, Fd}]). {ok,#Port<0.107>} 4> Mikael From tobbe@REDACTED Wed May 9 10:50:09 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 09 May 2007 10:50:09 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 In-Reply-To: <464185C7.20102@gmail.com> References: <46418243.3050408@gmail.com> <464185C7.20102@gmail.com> Message-ID: Nice, but I can't even load the driver, see below. I'm running the the version that lives in jungerl. Strange... --Tobbe Mikael Magnusson wrote: > Mikael Magnusson wrote: >> Torbjorn Tornkvist wrote: >>> Hi, >>> >>> The fd_server (see jungerl) does not work with R11B-4. >>> I suspect it has to do with the following (excerpt from >>> the release notes): >>> >>>> http://www.erlang.org/download/otp_src_R11B-4.readme >>>> >>>> OTP-6452 In the documentation of the driver entry field.... >>> This is most unfortunate since fd_server is important for Yaws >>> users that want to open up privileged ports. The following is >>> what happends: >>> >>> )1> fdsrv:start(). >>> {error,{error,{{error,driver_incorrect_version}, >>> "/home/tobbe/blaha/lib/fd_server/priv"}}} >>> >>> A more complete testcase could be: >>> >>> fdsrv:start(). >>> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). >>> gen_tcp:listen(81,[{fd, Fd}]). >>> >>> I've heard rumors that fd_server may be included in a future OTP >>> releases. Could that be true ? >>> >>> Anyway, if anyone comes up with an updated driver, it would be >>> mighty good if it could be put into jungerl. >>> >>> Cheers, Tobbe >>> (Ps. Btw R11B-4 can't be built unless --disable-hipe is used [Debian 4. >>> 0,Gentoo]) >>> >> It looks like inet_db:fdopen is at fault. The Family and Fd arguments >> are swapped in the call to prim_inet:fdopen. > > Correction, it's inet:fdopen, and the following patch solves the problem: > > --- inet.erl.orig 2007-05-09 10:19:50.000000000 +0200 > +++ inet.erl 2007-05-09 10:17:59.000000000 +0200 > @@ -749,7 +749,7 @@ > fdopen(Fd, Opts, Protocol, Family, Module). > > fdopen(Fd, Opts, Protocol, Family, Module) -> > - case prim_inet:fdopen(Protocol, Family, Fd) of > + case prim_inet:fdopen(Protocol, Fd, Family) of > {ok, S} -> > case prim_inet:setopts(S, Opts) of > ok -> > > Output from patched R11B-4: > > 1> fdsrv:start(). > {ok,<0.33.0>} > 2> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}). > {ok,9} > 3> gen_tcp:listen(81,[{fd, Fd}]). > {ok,#Port<0.107>} > 4> > > Mikael From mikma264@REDACTED Wed May 9 11:01:58 2007 From: mikma264@REDACTED (Mikael Magnusson) Date: Wed, 09 May 2007 11:01:58 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 In-Reply-To: References: <46418243.3050408@gmail.com> <464185C7.20102@gmail.com> Message-ID: <46418E06.4030900@gmail.com> Torbjorn Tornkvist wrote: > Nice, but I can't even load the driver, see below. > I'm running the the version that lives in jungerl. > Strange... > > --Tobbe > The jungerl cvs version of fd_server works for me. Have you compiled it using R11B-4? Mikael From oscar@REDACTED Wed May 9 11:21:14 2007 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 09 May 2007 10:21:14 +0100 Subject: [erlang-questions] Syntax Highlighting for Erlang with gedit In-Reply-To: <4640C626.1010009@web.am> References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> <4640C626.1010009@web.am> Message-ID: <4641928A.9020902@erlang-consulting.com> Gaspar Chilingarov wrote: > Vlad Dumitrescu wrote: >> Hi, >> >> These work just fine in erlide. > > > same in Vim > /Gaspar Ascii-values are broken in one (mine) Vim-implementation... >> On 5/7/07, Dominic Williams wrote: >>> Thanks, that's useful. If you care to improve it, you might want >>> to handle the following code properly (which confuses the >>> emacs mode too, BTW. How about erlide, and vim ?). >>> >>> ascii_values() -> >>> [$a, $\n, $", $1, $2]. >>> >>> multi_line() -> >>> " >>> This >>> is a >>> multi-line string >>> ". >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > Regards -- Oscar Hellstr?m, oscar@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From oscar@REDACTED Wed May 9 11:26:37 2007 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 09 May 2007 10:26:37 +0100 Subject: [erlang-questions] Syntax Highlighting for Erlang with Vim (was gedit) In-Reply-To: References: <36208.217.128.75.198.1178534050.squirrel@www.geekisp.com> <95be1d3b0705070423i5cfbbp25dd8fa813445d98@mail.gmail.com> <4640C626.1010009@web.am> Message-ID: <464193CD.7050308@erlang-consulting.com> Martin Ankerl wrote: >>> These work just fine in erlide. >> same in Vim > > multiline works for me too, but > [$a, $\n, $", $1, $2]. > > does not in my vim, both $\n and $" is a problem. Which version do you > use? I have 7.0.164. > There are several vim packages out there. The syntax file that is bundled with vim is not very good. At least is was not at 6.X. Take a look at: http://groups.google.com/group/vim-erlang http://www.vim.org/scripts/script.php?script_id=1584 Could not find Gaspar's package by a quick google. I remember me and Gaspar discussing a merge of our packages, which has not happened yet. Regards -- Oscar Hellstr?m, oscar@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From tobbe@REDACTED Wed May 9 11:36:43 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 09 May 2007 11:36:43 +0200 Subject: [erlang-questions] fd_server does not work with R11B-4 In-Reply-To: <46418E06.4030900@gmail.com> References: <46418243.3050408@gmail.com> <464185C7.20102@gmail.com> <46418E06.4030900@gmail.com> Message-ID: Mikael Magnusson wrote: > Torbjorn Tornkvist wrote: >> Nice, but I can't even load the driver, see below. >> I'm running the the version that lives in jungerl. >> Strange... >> >> --Tobbe >> > > The jungerl cvs version of fd_server works for me. Have you compiled it > using R11B-4? Yes (and tested on both Debian and Gentoo, by three different people even... :-). --Tobbe From richardc@REDACTED Wed May 9 15:07:55 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 09 May 2007 15:07:55 +0200 Subject: [erlang-questions] another Erlang blogger Message-ID: <4641C7AB.3030105@it.uu.se> Just found this on reddit: http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/ /Richard From pat.eyler@REDACTED Wed May 9 15:11:40 2007 From: pat.eyler@REDACTED (pat eyler) Date: Wed, 9 May 2007 07:11:40 -0600 Subject: [erlang-questions] Provo Erlounge last night (and next month) Message-ID: <6fd0654b0705090611k584931c5nb59ec90ec8f9b298@mail.gmail.com> Not a bad meeting. 11 Erlang newbies getting together to talk about the language we're all excited to learn. We reviewed some basics, looked at some code, and set things up to make this a regular meeting: from 7-9PM on the second Tuesday of every month, we'll meet at the same OSTC location. If no one here minds, we'll probably just use this list to communicate. Hopefully that will let some of you with more Erlang experience weigh in on our silly questions, and maybe encourage other erlangers to get similar (or better) groups going in their own neck of the woods. -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com From silvester.roessner@REDACTED Wed May 9 14:00:35 2007 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Wed, 9 May 2007 14:00:35 +0200 Subject: [erlang-questions] Where can I find the definition of the external term format Message-ID: <2CEB6DA5040AED4F946351C85FAC87B56FA8E9@DEJENSAPP01V1.vision.zeiss.org> Hi all, sorry, but I have searched about have a day and found nothing but the source code of erl_marshal. Is there an official documentation? I want to write a perl to erlang interface. Thanks a lot! Silvester -------------- next part -------------- An HTML attachment was scrubbed... URL: From hal@REDACTED Wed May 9 17:06:27 2007 From: hal@REDACTED (Hal Snyder) Date: Wed, 9 May 2007 10:06:27 -0500 Subject: [erlang-questions] Service platform (longish rant) In-Reply-To: <9b08084c0705080334le700f74mc0a429461cebcf4e@mail.gmail.com> References: <95be1d3b0705071332i135193b9y1fd3d19cf70c379e@mail.gmail.com> <200705080118.36018.roger.larsson@norran.net> <95be1d3b0705080041r4f0df934q62773059c0fc655f@mail.gmail.com> <9b08084c0705080334le700f74mc0a429461cebcf4e@mail.gmail.com> Message-ID: <2A027227-32D6-4E33-87DA-35184B94A709@vailsys.com> Another observation about pipes. One of our recent subversive initiatives has been an attempt to institute automated testing in a fairly mechanized way using dejagnu and expect and such a la gcc and gdb. The plan is for the toolchain, which already embraces automake, to spit out a testframe for each new project (e.g. each new Erlang application), making it irresistable for programmers to write/ maintain the testsuite as they go. I naively thought the job would be technically simple as long as you have a usable text interface for all the major inputs and outputs. Just make sure any GUI-type programmers give you a text alternative, etc. Expect may be a bit crufty, but it excels at managing multiple dialogues, dealing with Unix process groups and pseudoterminals and line disciplines and such. Wrong. In complex systems, connections among processes under test and test drivers have an annoying tendency to plug or stall, and do so differently on different runs of the same setup. We have to be a lot more careful about issues of flow control and determinism. I now think of three major components to any data connection where I used to think there were only two: - data format - protocol / state machine - flow control And I have a new respect for Erlang distribution, where interconnection is clean and effortless. Hal On May 8, 2007, at 5:34 AM, Joe Armstrong wrote: > I think that all this gets rather complicated because we are thinking > at the wrong > abstraction level. I'd really like to see what lies behind the pipes. > > When you do "A | B | C" the pipe symbol is really hiding a lot of > significant > detail. The pipe is really a rather complicated thing which hides > all sorts of > details like flow-control, buffering etc. I can imagine a more > complex notation > > Suppose we can "open up" the "|" operator, so we can see inside > > The A | B really means > > A |< P >| B > > Where P is a process > > P(A, B) := A ? M -> B ! M, P(A,B) > > To chain things through pipes I think you need to explicitly state the > pipe types > > chain([ > fun() -> make_a() end, > fun() -> make_standard_pipe() end, > fun() -> make_b() end > ]) > > where make_standard_pipe() makes a simple buffered pipe etc. > > What would be really nice would be to implement > "persistent infinite fault-tolerant with global end-point names" pipes > (for want of a better > name) with a defined protocol to get stuff in and out of the pipes > > (this would be something like the amazon simple queue service) > > Just for fun it might be nice to try and make one of these using a > defined representation of a pipe > > Suppose a pipe descriptor is a tuple like this: > > {pipe, Name, [{Host1,Port2},{Host2,Port2},{Host3,Port2}]} > > meaning that pipe called name is stored on three machine accessible > through > {Host, Port} > > Then it should be pretty easy to hack together an API to store and > retrieve > tuples to the pipe store (assume also an out-of-band way of > distributing > suitable crypto keys to secure the pipe). > > What I havn't thought about is the pipe <-> appliciation protocols > (some kind or peep/getHead/deleteHead/alertOnNewEntry protocol is > needed) > > Then you just need a bit of syntax to expand A | B | ... into > code that stores and fetches objects from the pipes. > > This could make a nice lightweight varient of amazons queue stuff > without all the > implementation mess of SOAP etc. > > Cheers > > /Joe > > > On 5/8/07, Vlad Dumitrescu wrote: >> Hi, >> >> On 5/8/07, Roger Larsson wrote: >>> On Monday 07 May 2007 22:32, Vlad Dumitrescu wrote: >>>> The example was >>>> ................... >>> >>> But it can be simplified to >>> >> >> That was just an example, taken from a previous discussion. >> >>> Note that all versions but your process based lacks one component >>> from the >>> Unix pipes - concurrency! The 'ls' is not required to finish >>> before the >>> final 'head', rather when head is finished the pipe is terminated ... From dietmar-s@REDACTED Wed May 9 18:12:25 2007 From: dietmar-s@REDACTED (Dietmar Schaefer) Date: Wed, 09 May 2007 18:12:25 +0200 Subject: [erlang-questions] bit-level binaries In-Reply-To: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> References: <6a36e7290705081111v208e9c6cmd1415ba5a38c1a70@mail.gmail.com> Message-ID: <4641F2E9.6070603@online.de> Hi, I can confirm that bitlevel binaries do indeed work on R11B-4 (haven't tried any other release). As Bob said, you need to compile using the bitlevel_binaries option. Cheers, Francesco On 5/8/07, Bob Ippolito wrote: > On 5/8/07, Waldemar Rachwal wrote: > > It was mentioned a few months ago (I missed the thread) that a > > bit-level binaries (augmented perhaps by binary comprehensions) might > > come with a next release. I guess such a big feature should come with > > a major release, but when it could happen then (I haven't figured out > > the cycle of B-0's)? > > > > (I admit SMP is very cool these days, but the slides from '05 EUC > > http://www.erlang.se/euc/05/1640PerKostis.pdf still impress me a lot). > > I believe that bit-level binaries were introduced in R11B-3 with shell > support in R11B-4. From my notes it requires some compiler directives: > > -compile([binary_comprehension, bitlevel_binaries]). > > I haven't tried it yet... > > -bob > _______________________________________________ > 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 rrerlang@REDACTED Wed May 9 18:21:36 2007 From: rrerlang@REDACTED (Robert Raschke) Date: Wed, 9 May 2007 17:21:36 +0100 Subject: [erlang-questions] start.boot files and $ROOT Message-ID: Hi, first off, thank you to Tobbe, who pointed me at a worked example of using Yaws in an embedded fashion. That has got me off the ground in my playing about with Erlang apps. I have reached the stage where I can create a release tar with the applications together with the erts. But now I am slightly stumped on how to run this without going through a full Erlang install. The start.script file that got created by systools:make_script/2 uses the magic $ROOT to point to the various applications. Seeing that my tar file (created by systools:make_tar/2) contains the erts, how can I persuade the system to boot my extracted tree of code? I am doing all of this on Windows, which is potentially where I'm going wrong ;-) When I extract my tree and try to run it using "erts-5.5.4\bin\erl -boot releases\0.1\start" anywhere, it tries to access the location where I had initially installed the Erlang distribution. Is there any way on Windows to override the ROOT? One way, I'm guessing, is to set a 'variable' option to the systools:make_script/2 and then use the -boot_var command line option. But that seems quite clunky somehow. Thanks for any pointers, Robby -- r dot raschke at tombob dot com From rrerlang@REDACTED Wed May 9 18:49:19 2007 From: rrerlang@REDACTED (Robert Raschke) Date: Wed, 9 May 2007 17:49:19 +0100 Subject: [erlang-questions] start.boot files and $ROOT Message-ID: <7a37a26620a8855545a5256046d3004e@tombob.com> I wrote: > Is there any way on Windows to override the ROOT? Well, 'tis bad form to reply to oneself, but here goes anyway. I just found the ERL.INI file in the erts/bin folder, and editing that to reflect my extracted release tar location does the trick. I take it the INI file isn't documented anywhere? Or have I not been looking hard enough? Robby -- r dot raschke at tombob dot com From kenneth.lundin@REDACTED Wed May 9 20:11:28 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 9 May 2007 20:11:28 +0200 Subject: [erlang-questions] Where can I find the definition of the external term format In-Reply-To: <2CEB6DA5040AED4F946351C85FAC87B56FA8E9@DEJENSAPP01V1.vision.zeiss.org> References: <2CEB6DA5040AED4F946351C85FAC87B56FA8E9@DEJENSAPP01V1.vision.zeiss.org> Message-ID: On 5/9/07, Roessner, Silvester wrote: > > > > Hi all, > > > > sorry, but I have searched about have a day and found nothing but the source > code of erl_marshal. > > > > Is there an official documentation? The external term format is documented in erts/emulator/internal_doc/erl_ext_dist.txt in the source distribution. The text document will be upgradet to be part of the official documentation in a forthcoming release (I don't promise when) You can also look ath the erl_interface and j_interface sources to see how the connection handshake works because I am not sure it is completely described in the text. /Regards Kenneth (OTP development team at Ericsson) > > > > I want to write a perl to erlang interface. > > > > Thanks a lot! > > > > Silvester > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From ulf@REDACTED Wed May 9 21:35:51 2007 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 9 May 2007 21:35:51 +0200 Subject: [erlang-questions] a plea for cleaner modules Message-ID: <8209f740705091235h21091f71p645e0c23fa5548bd@mail.gmail.com> I spent some time on the train hacking away at Erlhive. Now that I'm able to safely handle processes, ets tables and files (at least virtual files) inside mnesia transactions, I thought I'd throw in a HTTP or FTP client as well. I was disappointed to find that neither the ftp nor the http module are especially clean, doing just what you'd expect. My first step in checking how much work is needed to port something into erlhive goes something like this: 2> Beam = code:which(ftp). "c:/Program/ERL55~1.4/lib/inets-4.7.11/ebin/ftp.beam" 4> {ok,{_,[{imports,Is}]}} = beam_lib:chunks(Beam,[imports]). {ok,{ftp,[{imports,[{application,start,1}, {dbg,p,2}, ...]}} 5> Ms = ordsets:from_list([M || {M,_,_} <- Is]). [application, dbg, erlang, error_logger, file, filename, ftp_progress, ftp_response, ftp_sup, gen_server, gen_tcp, inet, inet_db, io_lib, lists, string] Now, going through the list is a bit discouraging. The following dependencies would cause porting problems: [application, dbg, error_logger] (Ok, inet_db needs to be handled too, but that's a logical step.) None of these are needed for the ftp logic, and so I'm forced to first cut out portions of the code. After that, it should be a pretty clean recompile. Now, the bulk of ftp.erl is perfectly fine. It is, as it should be, just a gen_server (but why on earth is it hard-coded to run at low priority?!). But making the module double as a supervisor behaviour, and automatically bootstrapping the inets application, is unnecessary, I think. Why not have a clean ftp gen_server module, and put all the gunk in a wrapper module for those who want it? Even if porting to Erlhive isn't high on your list, I can think of many good reasons to write the main logic in a separate module, with as few dependencies as possible. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Thu May 10 09:23:01 2007 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 10 May 2007 09:23:01 +0200 Subject: [erlang-questions] large objects in dets Message-ID: <9b08084c0705100023g10e64820ube94a57bb3154653@mail.gmail.com> I'd like to store large objects in a persistent disk store. Dets is "almost" ok. Dets is a key-value store - but there will be problems if the value is large (think a 4 Gbyte movie) What I need is an interface that allows random access of large values dets:reserve_space_for_key(LargeKey, 2000000000) reserve 2 GB dets:store(LargeKey, Start, <>) dets:lookup(largeKey, Start, Len) -> <> Now I know that dets does not do this now. Now the questions - to those of you who have hacked dets - is this an easy extension to dets? - should I hack dets? - should I "roll-my-own" - has anybody already made a large object disk storage thingy /Joe From valentin@REDACTED Thu May 10 10:05:38 2007 From: valentin@REDACTED (Valentin Micic) Date: Thu, 10 May 2007 10:05:38 +0200 Subject: [erlang-questions] large objects in dets References: <9b08084c0705100023g10e64820ube94a57bb3154653@mail.gmail.com> Message-ID: <001001c792da$04eb3e00$6401a8c0@moneymaker2> First a question: Is 2GB limit per file preserved even in 64-bit environment? Than my 2c worth: > - should I hack dets? IMHO: NO. It's not worth while exercise. I suspect that DETS would be very slow in reading/writing BIG things. Secondly, you would not be able to do it in "chunks", but a whole thing at the time. > - should I "roll-my-own" YES. It would make far more sense to place your big things into a normal file (i.e. one thing per file) and use DETS table as a catalog/index of things. But then, next question would be why DETS and not mnesia with disk-only (DETS) or disk table (ETS + DISK LOG). That way, you'll get far better control over your life. V. From silvester.roessner@REDACTED Thu May 10 11:23:43 2007 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Thu, 10 May 2007 11:23:43 +0200 Subject: [erlang-questions] Where can I find the definition of the external term format In-Reply-To: <464289D9.6070903@ertw.com> References: <2CEB6DA5040AED4F946351C85FAC87B56FA8E9@DEJENSAPP01V1.vision.zeiss.org> <464289D9.6070903@ertw.com> Message-ID: <2CEB6DA5040AED4F946351C85FAC87B56FA9AB@DEJENSAPP01V1.vision.zeiss.org> Hi all, thanks a lot for your help! I already started with the implementation. > Hi Silvester. I'm on the tail end of writing a c++ to erlang binding, so > if you run into troubles with your perl interface I may be able to help. Dan, you surly will here from me ;-) > The text document will be upgradet to be part of the official > documentation in a forthcoming release (I don't promise when) Kenneth, that would be great! Silvester From ulf@REDACTED Thu May 10 13:42:20 2007 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 10 May 2007 13:42:20 +0200 Subject: [erlang-questions] per function/process locals In-Reply-To: <86E23A60-4527-4A23-905D-4452C817E660@cs.otago.ac.nz> References: <0AB33ABF-8CAA-40AA-AAE0-8EE94E98CB0B@cs.otago.ac.nz> <6616D98C65DD514BA2E1DDC5F922315501C23FCC@esealmw115.eemea.ericsson.se> <86E23A60-4527-4A23-905D-4452C817E660@cs.otago.ac.nz> Message-ID: <8209f740705100442v5e62e270mf314a69816e9ec98@mail.gmail.com> 2007/5/3, ok : > > On 2 May 2007, at 11:21 pm, Ulf Wiger (TN/EAB) wrote > [that instead of doing] > > init_state(L) -> > > lists:foldl( > > fun({a, A}, S) -> S#st{a = A}; > > ({b, B}, S) -> S#st{b = B}; > > ... > > end, #st{}, L). > [he tends to do] > > [A, B, C, D] = > > [proplists:get_value(K,L) || > > K <- [a, b, c, d]], > > #st{a = A, b = B, c = C, d = D} > > This is a rather interesting example, because it shows a clear trade- > off. > Suppose there are V "variables". We expect that the list will contain > each at most once; the worst case is when they all appear. Just to give some concrete input, we are currently looking at how to best populate a fairly large record, consisting of 42 attributes. I'm thinking that the exprecs contrib (that I've posted in the trapexit User Contributions forum) could try to output code that gives a reasonable tradeoff based on size of record and (possibly) length of list. Currently, it lays out the following code: -record(dia_base_DPR, {'Origin-Host' = undefined, 'Origin-Realm' = undefined, 'Disconnect-Cause' = undefined}). '#set-dia_base_DPR'(Vals, Rec) -> F = fun ([], R, _F1) -> R; ([{'Origin-Host', V} | T], R, F1) -> F1(T, R#dia_base_DPR{'Origin-Host' = V}, F1); ([{'Origin-Realm', V} | T], R, F1) -> F1(T, R#dia_base_DPR{'Origin-Realm' = V}, F1); ([{'Disconnect-Cause', V} | T], R, F1) -> F1(T, R#dia_base_DPR{'Disconnect-Cause' = V}, F1) end, F(Vals, Rec, F). ... but for a record of size 44, this is not desirable. Timing the two functions available for creating a new record: -module(test4). -compile(export_all). -compile({parse_transform, exprecs}). -export_records([r]). -record(r, {a1,a2,a3,a4,a5,a6,a7,a8,a9,a10, a11,a12,a13,a14,a15,a16,a17,a18, a19,a20,a21,a22,a23,a24,a25,a26, a27,a28,a29,a30,a31,a32,a33,a34, a35,a36,a37,a38,a39,a40,a41,a42, a43,a44,a45,a46,a47,a48,a49,a50}). 3> timer:tc(test4,'#new-r',[]). {5, {r,undefined,...}} 4> Attrs = test4:'#info-r'(fields). [a1, a2, a3, a4,...] 5> Vals = [{A,1} || A <- Attrs]. [{a1,1}, {a2,1}, {a3,1}, {a4,1},...] 6> timer:tc(test4,'#new-r',[Vals]). {98,{r,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,...}} I wrote a version basically doing this: -module(recgen). -export(['#new-r'/1]). '#new-r'(L) -> mk_rec(L, undefined, undefined). mk_rec([{Attr,Val}|T], X1, X2) -> X1 = if Attr == a1 -> Val; true -> X1 end, X2 = if Attr == a2 -> Val; true -> X2 end, mk_rec(T, X1, X2); mk_rec([], X1, X2) -> '#new-r'(X1, X2). '#new-r'(X1, X2) -> {r,X1,X2}. ...but for a record with 50 attributes, this was twice as slow when setting all 50 attributes. Obviously, wielding functions of arity 51 is not for free. (: BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From vijay@REDACTED Thu May 10 15:13:40 2007 From: vijay@REDACTED (vijay chakravarthy) Date: Thu, 10 May 2007 06:13:40 -0700 Subject: [erlang-questions] large objects in dets In-Reply-To: <9b08084c0705100023g10e64820ube94a57bb3154653@mail.gmail.com> References: <9b08084c0705100023g10e64820ube94a57bb3154653@mail.gmail.com> Message-ID: <3c2535310705100613w349c5a7btf8f529b666187aca@mail.gmail.com> Why is this not a URL? We do exactly the same thing, except for flash movies generated from powerpoint. The URL we use is actually an S3 url (Amazon S3). The only issue which you might want to consider is things like replication and garbage collection for these large objects - in some cases you would need to build your own. In our case, its simple, these objects are not shared, and S3 provides the redundancy. Of course, instead of something like S3 you could use a decent file system (ZFS in solaris is nice). Other alternatives are mogileFS, nutch file system -- if you want a replicated file system with simple semantics. Of course I would argue that mogileFS is better off rewritten in erlang -- but thats a project for another day. Vijay On 5/10/07, Joe Armstrong wrote: > > I'd like to store large objects in a persistent disk store. > > Dets is "almost" ok. > > Dets is a key-value store - but there will be problems if the value is > large (think a 4 Gbyte movie) > > What I need is an interface that allows random access of large values > > dets:reserve_space_for_key(LargeKey, 2000000000) reserve 2 GB > dets:store(LargeKey, Start, <>) > dets:lookup(largeKey, Start, Len) -> <> > > Now I know that dets does not do this now. > > Now the questions > > - to those of you who have hacked dets - is this an easy extension to > dets? > - should I hack dets? > - should I "roll-my-own" > - has anybody already made a large object disk storage thingy > > /Joe > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yerl@REDACTED Thu May 10 15:36:04 2007 From: yerl@REDACTED (yerl@REDACTED) Date: Thu, 10 May 2007 15:36:04 +0200 Subject: [erlang-questions] large objects in dets Message-ID: Hey! >(ZFS in solaris is nice). Other alternatives are mogileFS, nutch file system You mean "hadoop", nutch is a "search engine + crawler" ;-) cheers Youn?s From mike.toler@REDACTED Thu May 10 16:57:35 2007 From: mike.toler@REDACTED (Mike Toler) Date: Thu, 10 May 2007 09:57:35 -0500 Subject: [erlang-questions] Stand alone TLS encryption module? Message-ID: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> I'm working with the Tsung tool right now (written in Erlang) to load test a Jabber project. In the real world, all of the communications to and from the server would be encrypted using TLS, but that isn't supported by Tsung. Is there a stand alone TLS module (or even one that could be hijacked from another project) that would be fairly simple to integrate into another application? Thanks. Michael Toler (214) 278-1834 (Office) (972) 816-7790 (mobile) Systems Integration Engineer Prodea Systems. This message is confidential to Prodea Systems, Inc unless otherwise indicated or apparent from its nature. This message is directed to the intended recipient only, who may be readily determined by the sender of this message and its contents. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient:(a)any dissemination or copying of this message is strictly prohibited; and(b)immediately notify the sender by return message and destroy any copies of this message in any form(electronic, paper or otherwise) that you have.The delivery of this message and its information is neither intended to be nor constitutes a disclosure or waiver of any trade secrets, intellectual property, attorney work product, or attorney-client communications. The authority of the individual sending this message to legally bind Prodea Systems is neither apparent nor implied,and must be independently verified. -------------- next part -------------- An HTML attachment was scrubbed... URL: From psa@REDACTED Thu May 10 16:59:04 2007 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Thu, 10 May 2007 15:59:04 +0100 Subject: [erlang-questions] ets:lookup() versus mnesia:ets() In-Reply-To: <46138475.9000809@di.uminho.pt> References: <46136BCE.6020805@di.uminho.pt> <8209f740704040239x700ca3e4v1e61f6eb60bdf742@mail.gmail.com> <46138475.9000809@di.uminho.pt> Message-ID: <46433338.5000403@di.uminho.pt> Hi all, I know this is a sacrilege, breaking all rules of abstraction, assuming some internals of the implementation, bla, bla, bla, ... ;) But ... suppose that it is important to squeeze the last bit of performance and, in a scenario where I wanted to do reads on a non-replicated disc_copies mnesia table, of records that are only updated by the same process (even though other processes update other records), and where I use: mnesia:ets(fun()-> mnesia:read({Table, Key}) end) and therefore have the lowest access context / isolation level available and I am happy with it. Is there anything that could go wrong if I instead used: ets:lookup(Table, Key) This would save building the closure, and the tests that read must make to figure out the access context, and it can be twice as fast in a set table (I measured 2 microseconds instead of 4 on my notebook; mnesia:dirty_read is slower, taking 5 microseconds). So, is there any problem switching from mnesia:ets to ets:lookup in this scenario? Has such a thing crossed anyone's mind? Paulo Almeida From oscar@REDACTED Thu May 10 17:54:32 2007 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 10 May 2007 16:54:32 +0100 Subject: [erlang-questions] Stand alone TLS encryption module? In-Reply-To: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> References: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> Message-ID: <46434038.4030708@erlang-consulting.com> Mike Toler wrote: > I'm working with the Tsung tool right now (written in Erlang) to load > test a Jabber project. In the real world, all of the communications to > and from the server would be encrypted using TLS, but that isn't > supported by Tsung. > > > > Is there a stand alone TLS module (or even one that could be hijacked > from another project) that would be fairly simple to integrate into > another application? > The ssl module in the ssl application is used for this. You only need to hack the way the Tsung plugin connects, and after that, the interface to the module is the same as to the gen_tcp. > > Thanks. > > > > Michael Toler > > (214) 278-1834 (Office) > > (972) 816-7790 (mobile) > > Systems Integration Engineer > > Prodea Systems. > > > > > > > This message is confidential to Prodea Systems, Inc unless otherwise indicated > or apparent from its nature. This message is directed to the intended recipient > only, who may be readily determined by the sender of this message and its > contents. If the reader of this message is not the intended recipient, or an > employee or agent responsible for delivering this message to the intended > recipient:(a)any dissemination or copying of this message is strictly > prohibited; and(b)immediately notify the sender by return message and destroy > any copies of this message in any form(electronic, paper or otherwise) that you > have.The delivery of this message and its information is neither intended to be > nor constitutes a disclosure or waiver of any trade secrets, intellectual > property, attorney work product, or attorney-client communications. The > authority of the individual sending this message to legally bind Prodea Systems > is neither apparent nor implied,and must be independently verified. > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best Regards -- Oscar Hellstr?m, oscar@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From ulf.wiger@REDACTED Thu May 10 18:13:18 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 10 May 2007 18:13:18 +0200 Subject: [erlang-questions] ets:lookup() versus mnesia:ets() In-Reply-To: <46433338.5000403@di.uminho.pt> References: <46136BCE.6020805@di.uminho.pt><8209f740704040239x700ca3e4v1e61f6eb60bdf742@mail.gmail.com><46138475.9000809@di.uminho.pt> <46433338.5000403@di.uminho.pt> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501D55872@esealmw115.eemea.ericsson.se> Hi, Sure, it has been done. You seem to be aware of the drawbacks. mnesia:ets(fun/0) was created to avoid this very thing, assuming that it wouldn't matter for most people that it'd cost a couple of micros extra. Even better than mnesia:ets/1 is to use mnesia:activity(Type, fun/0), where Type can be set to ets, async_dirty, sync_dirty, etc., giving you a wider array of dirtiness to choose from. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Paulo S?rgio Almeida > Sent: den 10 maj 2007 16:59 > To: erlang-questions@REDACTED > Subject: [erlang-questions] ets:lookup() versus mnesia:ets() > > Hi all, > > I know this is a sacrilege, breaking all rules of > abstraction, assuming some internals of the implementation, > bla, bla, bla, ... ;) > > But ... suppose that it is important to squeeze the last bit > of performance and, in a scenario where I wanted to do reads > on a non-replicated disc_copies mnesia table, of records that > are only updated by the same process (even though other > processes update other records), and where I use: > > mnesia:ets(fun()-> mnesia:read({Table, Key}) end) > > and therefore have the lowest access context / isolation > level available and I am happy with it. Is there anything > that could go wrong if I instead used: > > ets:lookup(Table, Key) > > This would save building the closure, and the tests that read > must make to figure out the access context, and it can be > twice as fast in a set table (I measured 2 microseconds > instead of 4 on my notebook; mnesia:dirty_read is slower, > taking 5 microseconds). > > So, is there any problem switching from mnesia:ets to > ets:lookup in this scenario? Has such a thing crossed anyone's mind? > > Paulo Almeida > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Thu May 10 19:48:08 2007 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 10 May 2007 19:48:08 +0200 Subject: [erlang-questions] large objects in dets In-Reply-To: References: Message-ID: <9b08084c0705101048m26e418fdwca93c58a3523f8e8@mail.gmail.com> Any idea where the hadoop inter-machine protocol is *defined* /Joe On 5/10/07, yerl@REDACTED wrote: > Hey! > >(ZFS in solaris is nice). Other alternatives are mogileFS, nutch file system > > You mean "hadoop", nutch is a "search engine + crawler" ;-) > > cheers > Youn?s > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From psa@REDACTED Thu May 10 20:24:21 2007 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Thu, 10 May 2007 19:24:21 +0100 Subject: [erlang-questions] ets:lookup() versus mnesia:ets() In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501D55872@esealmw115.eemea.ericsson.se> References: <46136BCE.6020805@di.uminho.pt><8209f740704040239x700ca3e4v1e61f 6eb60bdf742@mail.gmail.com><46138475.9000809@di.uminho.pt> <46433338.5000403@di.uminho.pt> <6616D98C65DD514BA2E1DDC5F922315501D55872@esealmw115.eemea.ericsson.se> Message-ID: <46436355.2010901@di.uminho.pt> Ulf, thanks for the prompt reply. Ulf Wiger (TN/EAB) wrote: > Hi, > > Sure, it has been done. You seem to be aware of > the drawbacks. Do you mean, that apart from being bad software enginnering, it will be as safe as using mnesia:ets/1, if mnesia keeps using ets for its implementation? > mnesia:ets(fun/0) was created to avoid this very > thing, assuming that it wouldn't matter for most > people that it'd cost a couple of micros extra. I see. > Even better than mnesia:ets/1 is to use > > mnesia:activity(Type, fun/0), > > where Type can be set to ets, async_dirty, sync_dirty, > etc., giving you a wider array of dirtiness to choose > from. Ok. Btw, I tested mnesia:activity(ets, ...) but the runtime is similar to mnesia:ets, even a bit slower (5 microseconds instead of 4). Regards, Paulo From vijay@REDACTED Thu May 10 20:31:01 2007 From: vijay@REDACTED (vijay chakravarthy) Date: Thu, 10 May 2007 11:31:01 -0700 Subject: [erlang-questions] large objects in dets In-Reply-To: <9b08084c0705101048m26e418fdwca93c58a3523f8e8@mail.gmail.com> References: <9b08084c0705101048m26e418fdwca93c58a3523f8e8@mail.gmail.com> Message-ID: <3c2535310705101131v6eee7586n74342962682d741@mail.gmail.com> Background reading material that is relevant: http://labs.google.com/papers/gfs.html http://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DatanodeProtocol.java http://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java Other files in that directory are also relevant.. Vijay On 5/10/07, Joe Armstrong wrote: > > Any idea where the hadoop inter-machine protocol is *defined* > > /Joe > > > On 5/10/07, yerl@REDACTED wrote: > > Hey! > > >(ZFS in solaris is nice). Other alternatives are mogileFS, nutch file > system > > > > You mean "hadoop", nutch is a "search engine + crawler" ;-) > > > > cheers > > Youn?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 ulf.wiger@REDACTED Thu May 10 21:37:17 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 10 May 2007 21:37:17 +0200 Subject: [erlang-questions] ets:lookup() versus mnesia:ets() In-Reply-To: <46436355.2010901@di.uminho.pt> References: <46136BCE.6020805@di.uminho.pt><8209f740704040239x700ca3e4v1e61f 6eb60bdf742@mail.gmail.com><46138475.9000809@di.uminho.pt> <46433338.5000403@di.uminho.pt> <6616D98C65DD514BA2E1DDC5F922315501D55872@esealmw115.eemea.ericsson.se> <46436355.2010901@di.uminho.pt> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501D558E7@esealmw115.eemea.ericsson.se> Paulo S?rgio Almeida wrote: > > Ulf Wiger (TN/EAB) wrote: > > Hi, > > > > Sure, it has been done. You seem to be aware of the drawbacks. > > Do you mean, that apart from being bad software enginnering, > it will be as safe as using mnesia:ets/1, if mnesia keeps > using ets for its implementation? This is correct, as far as I can make out of the code. mnesia:ets(fun() -> mnesia:read({Tab,Key}) end) will unfold into a call to ets:lookup(Tab, Key), without any checks to see whether the table is even defined. > > Even better than mnesia:ets/1 is to use > > > > mnesia:activity(Type, fun/0), > > > > where Type can be set to ets, async_dirty, sync_dirty, etc., giving > > you a wider array of dirtiness to choose from. > > Ok. Btw, I tested mnesia:activity(ets, ...) but the runtime > is similar to mnesia:ets, even a bit slower (5 microseconds > instead of 4). You must have a really fast machine. (: That would be the environment lookup to see whether there's a custom access module (a unique feature of mnesia:activity(), which allows for nifty add-ons like rdbms. ;) If you really want to shave off that microsecond too, then mnesia:activity( ets, fun() -> mnesia:read({T,K}) end, [], mnesia) should do the trick, but then you remove the option of customizing the behaviour by installing a custom access module (no free lunch...) BR, Ulf W From masayuki.takagi@REDACTED Fri May 11 06:35:40 2007 From: masayuki.takagi@REDACTED (Masayuki TAKAGI) Date: Fri, 11 May 2007 13:35:40 +0900 Subject: [erlang-questions] Is mnesia fit to over TB data handling? Message-ID: <4F840557-AAC2-43E7-B51E-F30B48CC3017@bebit.co.jp> Hi all, I want to make a system as below: - dealing with TB class data - writing data all the time - receiving the result of some queries in a few seconds - being able to add disc storages and nodes dynamically as the data grow Is it possible with mnesia? I worry about that mnesia may be unifit to such large scale data handling. Please give me some advices. Masayuki TAKAGI beBit,Inc. URL: http://www.bebit.co.jp/ From ulf@REDACTED Fri May 11 08:26:15 2007 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 11 May 2007 08:26:15 +0200 Subject: [erlang-questions] Is mnesia fit to over TB data handling? In-Reply-To: <4F840557-AAC2-43E7-B51E-F30B48CC3017@bebit.co.jp> References: <4F840557-AAC2-43E7-B51E-F30B48CC3017@bebit.co.jp> Message-ID: <8209f740705102326i74f04c7bx9bba1836b167ef14@mail.gmail.com> What would worry me especially with using Mnesia for terabyte storage is that, even if I could come up with a scheme to make it work (which I think is possible), this is outside of Mnesia's design parameters, and it's not something the product is being tested for. There are other products out there that were actually designed for terabyte storage, and which are continously tested and benchmarked in this area. I would probably go with one of those, because it's an awful lot of data to lose. (But if you want to break new ground, that's another matter. ;-) BR, Ulf W 2007/5/11, Masayuki TAKAGI : > > Hi all, > > I want to make a system as below: > - dealing with TB class data > - writing data all the time > - receiving the result of some queries in a few seconds > - being able to add disc storages and nodes dynamically as the data grow > > Is it possible with mnesia? > I worry about that mnesia may be unifit to such large scale data > handling. > Please give me some advices. > > > Masayuki TAKAGI > beBit,Inc. > URL: http://www.bebit.co.jp/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevej@REDACTED Fri May 11 09:42:27 2007 From: stevej@REDACTED (Steve Jenson) Date: Fri, 11 May 2007 00:42:27 -0700 Subject: [erlang-questions] large objects in dets In-Reply-To: <9b08084c0705101048m26e418fdwca93c58a3523f8e8@mail.gmail.com> References: <9b08084c0705101048m26e418fdwca93c58a3523f8e8@mail.gmail.com> Message-ID: <81d74c280705110042l10270cdeldb39b05d126f722a@mail.gmail.com> Here's a start: http://lucene.apache.org/hadoop/api/org/apache/hadoop/ipc/RPC.html Just an FYI: Hadoop's DFS is different from GFS in at least one key way; Hadoop is (at least from the last time I checked) WORM and GFS files were designed to be appended to very often. Also, GFS handles small files very poorly. Of course, GFS had all kinds of tuning parameters so you could get a GFS cluster to handles lots of different scenarios but you had to be prepared for the trade-offs. Although it sounds like you aren't planning to append to your files, either. I agree with the opinion of sticking files on disk and using mnesia to keep track of where you placed them. You can avoid overloading your file system by using a multilevel directory structure. Of course, that only matters if you are planning on storing hundreds of thousands of files. Most modern unix file systems can actually handle tens of thousands of files in a single directory without trouble but your sysadmins would rather you didn't try run any commands that are O(N) the number of files like pesky 'ls'. Thousands of files in a directory should present you with no trouble. HTH, Steve On 5/10/07, Joe Armstrong wrote: > Any idea where the hadoop inter-machine protocol is *defined* > > /Joe > > > On 5/10/07, yerl@REDACTED wrote: > > Hey! > > >(ZFS in solaris is nice). Other alternatives are mogileFS, nutch file system > > > > You mean "hadoop", nutch is a "search engine + crawler" ;-) > > > > cheers > > Youn?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 > From ewan_higgs@REDACTED Fri May 11 10:26:48 2007 From: ewan_higgs@REDACTED (Ewan Higgs) Date: Fri, 11 May 2007 09:26:48 +0100 (BST) Subject: [erlang-questions] Is mnesia fit to over TB data handling? In-Reply-To: <4F840557-AAC2-43E7-B51E-F30B48CC3017@bebit.co.jp> Message-ID: <119684.5077.qm@web27005.mail.ukl.yahoo.com> I think this study will be of interest to you: http://erlang-consulting.com/thesis/dbms_eval.html It discusses the scalability limitations of Mnesia and investigates alternatives. Here are some relevant bits: "However, it is rather limited in its storage capabilities. Mnesia tables can only store 4 GB in the 32-bit implementation. Therefore, if a system has larger storage requirements than this, like the track and trace systems which continually grow over time, Mnesia is not a valid choice. 4 GB of data is not a large amount of data, so Erlang developers must find a way to meet these system requirements." "Conclusion: The results show that Ingres would be the best to use in conjunction with Erlang based on the criterion in the study found through the survey of the Erlang Community. However, there are obviously a number of other considerations to make before making the final choice. For instance what performance level we desire and also what licensing limitations the database management system." Kind regards, Ewan --- Masayuki TAKAGI wrote: > Hi all, > > I want to make a system as below: > - dealing with TB class data > - writing data all the time > - receiving the result of some queries in a few > seconds > - being able to add disc storages and nodes > dynamically as the data grow > > Is it possible with mnesia?? > I worry about that mnesia may be unifit to such > large scale data > handling. > Please give me some advices. > > > Masayuki TAKAGI > beBit,Inc. > URL: http://www.bebit.co.jp/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ From chandrashekhar.mullaparthi@REDACTED Fri May 11 10:47:39 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 11 May 2007 09:47:39 +0100 Subject: [erlang-questions] Stand alone TLS encryption module? In-Reply-To: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> References: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> Message-ID: On 10/05/07, Mike Toler wrote: > > I'm working with the Tsung tool right now (written in Erlang) to load test a > Jabber project. In the real world, all of the communications to and from > the server would be encrypted using TLS, but that isn't supported by Tsung. > > Is there a stand alone TLS module (or even one that could be hijacked from > another project) that would be fairly simple to integrate into another > application? Have you tried using stunnel(*) to sit in between Tsung and ejabberd? That way you don't have to change Tsung at all. Chandru * http://stunnel.org From timuckun@REDACTED Fri May 11 11:09:41 2007 From: timuckun@REDACTED (Tim Uckun) Date: Fri, 11 May 2007 21:09:41 +1200 Subject: [erlang-questions] Is mnesia fit to over TB data handling? In-Reply-To: <119684.5077.qm@web27005.mail.ukl.yahoo.com> References: <4F840557-AAC2-43E7-B51E-F30B48CC3017@bebit.co.jp> <119684.5077.qm@web27005.mail.ukl.yahoo.com> Message-ID: <855e4dcf0705110209n32e33696j604700910565bde8@mail.gmail.com> On 5/11/07, Ewan Higgs wrote: > I think this study will be of interest to you: That was indeed interesting thanks. It seems to me they should have evaluated mysql cluster. It's feature set is closest to mnesia and it promises to be suitable for telecom level uptime. Someone had mentioned using mnesia as a caching front end to a RDMBS, is there a document describing how to set something up like that? From nicolas@REDACTED Fri May 11 11:09:56 2007 From: nicolas@REDACTED (Nicolas Niclausse) Date: Fri, 11 May 2007 11:09:56 +0200 Subject: [erlang-questions] Stand alone TLS encryption module? In-Reply-To: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> References: <56DA5079467D1C48B857C6FE59D5D4FC5874A4@prodeaserve.prodea.local> Message-ID: <464432E4.6080507@niclux.org> Mike Toler ecrivait le 10.05.2007 16:57: > I?m working with the Tsung tool right now (written in Erlang) to load > test a Jabber project. In the real world, all of the communications to > and from the server would be encrypted using TLS, but that isn?t > supported by Tsung. Hello, Tsung is able to use the ssl module. From the documentation, this module (since ssl-3.0.6) is able to use tlsv1 : http://www.erlang.org/doc/doc-5.5.4/lib/ssl-3.1/doc/html/index.html Did you try it ? -- Nicolas From ingela@REDACTED Fri May 11 11:10:46 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Fri, 11 May 2007 11:10:46 +0200 Subject: [erlang-questions] a plea for cleaner modules In-Reply-To: References: Message-ID: <46443316.4090203@erix.ericsson.se> [...] > Now, going through the list is a bit discouraging. > The following dependencies would cause porting problems: > [application, dbg, error_logger] Well it is not exactly dependent on dbg. Dbg will never be called in a normal run of the ftp, http clients you have to give special debug flags for the dbg code to be run and it is mainly there for convince instead of cluttering the code with special debug macros doing io:format when some flag is set to true. When it comes to application it has to do with the bootstaping (see below) and is not strictly necessary. error_logger is used to handle unexpected "should-not-happen-normally" errors. > Now, the bulk of ftp.erl is perfectly fine. It is, as it should be, > just a gen_server (but why on earth is it hard-coded to run > at low priority?!). I can not answer that one, typically a good thing to write a comment about, alas whoever wrote that code did not. > But making the module double as a supervisor > behaviour, There is a point in the inets processes being part of the inets supervision tree, although for ftp the benefit is not that extensive. In the the new start up interface for inets I am thinking of crating a stand alone option for the start of inets services. > and automatically bootstrapping the inets application, > is unnecessary, I think. Bootstrapping is also of convince reasons so that it should be easy to test the functionality in the shell, which is appreciated by many. > Why not have a clean ftp gen_server module, and put all the > gunk in a wrapper module for those who want it? > Even if porting to Erlhive isn't high on your list, I can think of > many good reasons to write the main logic in a separate > module, with as few dependencies as possible. In principal I agree and I will consider it but I can not make any promises on exact what and when changes will be done. Regards Ingela - OTP team From ulf.wiger@REDACTED Fri May 11 11:41:36 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 11 May 2007 11:41:36 +0200 Subject: [erlang-questions] a plea for cleaner modules In-Reply-To: <46443316.4090203@erix.ericsson.se> References: <46443316.4090203@erix.ericsson.se> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501D55F05@esealmw115.eemea.ericsson.se> Ingela Anderton Andin wrote: > > [...] > > > Now, going through the list is a bit discouraging. > > The following dependencies would cause porting problems: > > > [application, dbg, error_logger] > > Well it is not exactly dependent on dbg. Dbg will never be > called in a normal run of the ftp, http clients you have to > give special debug flags for the dbg code to be run and it is > mainly there for convince instead of cluttering the code with > special debug macros doing io:format when some flag is set to true. > > When it comes to application it has to do with the > bootstaping (see below) and is not strictly necessary. > > error_logger is used to handle unexpected > "should-not-happen-normally" errors. Yes, I had noticed that these dependencies could be removed quite easily. The problem is that if a module contains several things that are not strictly needed to serve its main purpose, this extra stuff clutters the code, and makes the module less reusable. The main "porting problem" then is that in order to reuse the ftp code, I have to strip out the parts that would cause problems, which means that everytime you update the module in OTP, I have to do it all over again. The ftp module was just an example. I've come across this several times before, and have certainly been guilty of it myself too. I think the main problem is often that it's difficult to know in advance what the best division into modules is, and much of the gunk appears as a result of discovering things along the way. So the initial structure slowly breaks down over time. And once it works, one may be reluctant to start restructuring it just for the sake of asethetics. A good refactoring tool and QuickCheck would certainly help the situation. (: BR, Ulf W From twoggle@REDACTED Fri May 11 14:44:08 2007 From: twoggle@REDACTED (Tim Fletcher) Date: Fri, 11 May 2007 13:44:08 +0100 Subject: [erlang-questions] final year university project with erlang? In-Reply-To: References: Message-ID: A little while back now I asked for Erlang ideas for my final year university project (message below). It's taken a while, but i've finally found a supervisor. They weren't 100% keen on the ideas I put forward, so the title of the project I'm going to be doing is "Erlang and the robot scientists" :) It's based on a proposal to evaluate newer concurrent/declarative languages (i.e. Erlang, Haskell and Mozart) as a replacement for existing lab automation control software (mostly Visual Basic or C++). Thanks again to anyone who gave me suggestions. On 06/03/07, Tim Fletcher wrote: > Hi Folks, > > I'm currently on a work placement, but in October i'll be starting my > final year at university. As part of my course (Computer Science BSc) > i'll need to do a project - we can either pick one from those > suggested by the department, or we can submit a "student defined" > project. The suggestions aren't very inspiring, so I was wondering > whether anyone here had any ideas for something I could do involving > Erlang? > > Given my degree level, the project has to be of the "lifecycle" > variety, which has following "criteria": > > BCS/IEE accreditation requires a project that: follows a lifecycle > that can be > characterised as requirements-design-build-evaluate; describes and evaluates > the method(s) used to design, build and evaluate. > These projects do not have to be traditional engineering, but must > have, describe, > and evaluate a recognised method. > All lifecycle projects should aim to build or implement something, > and to evaluate > its quality and reliability etc. > > AFAIK the project can be run in conjunction with a company, or it > could be something that could help the community. > > My experience so far has been mostly Ruby/Python (in my own time), and > Java/Windows programming during my placement. I've only really had a > quick play with Erlang, but would rather get to know it a bit better, > and I think this could be a good opportunity to do so. > > Apologies if this is slightly off-topic - please feel free to email me > off the list. > From mike.toler@REDACTED Fri May 11 18:02:25 2007 From: mike.toler@REDACTED (Mike Toler) Date: Fri, 11 May 2007 11:02:25 -0500 Subject: [erlang-questions] Stand alone TLS encryption module? In-Reply-To: <464432E4.6080507@niclux.org> Message-ID: <56DA5079467D1C48B857C6FE59D5D4FC587795@prodeaserve.prodea.local> Do you happen to have an SSL test that I can look at to see how the requests and such progress through the Tsung code? Michael -----Original Message----- From: Nicolas Niclausse [mailto:nicolas@REDACTED] Sent: Friday, May 11, 2007 4:10 AM To: Mike Toler Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Stand alone TLS encryption module? Mike Toler ecrivait le 10.05.2007 16:57: > I'm working with the Tsung tool right now (written in Erlang) to load > test a Jabber project. In the real world, all of the communications to > and from the server would be encrypted using TLS, but that isn't > supported by Tsung. Hello, Tsung is able to use the ssl module. From the documentation, this module (since ssl-3.0.6) is able to use tlsv1 : http://www.erlang.org/doc/doc-5.5.4/lib/ssl-3.1/doc/html/index.html Did you try it ? -- Nicolas This message is confidential to Prodea Systems, Inc unless otherwise indicated or apparent from its nature. This message is directed to the intended recipient only, who may be readily determined by the sender of this message and its contents. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient:(a)any dissemination or copying of this message is strictly prohibited; and(b)immediately notify the sender by return message and destroy any copies of this message in any form(electronic, paper or otherwise) that you have.The delivery of this message and its information is neither intended to be nor constitutes a disclosure or waiver of any trade secrets, intellectual property, attorney work product, or attorney-client communications. The authority of the individual sending this message to legally bind Prodea Systems is neither apparent nor implied,and must be independently verified. From tim.becker@REDACTED Fri May 11 18:34:24 2007 From: tim.becker@REDACTED (Tim Becker) Date: Fri, 11 May 2007 18:34:24 +0200 Subject: [erlang-questions] Where can I find the definition of the external term format In-Reply-To: <2CEB6DA5040AED4F946351C85FAC87B56FA9AB@DEJENSAPP01V1.vision.zeiss.org> References: <2CEB6DA5040AED4F946351C85FAC87B56FA8E9@DEJENSAPP01V1.vision.zeiss.org> <464289D9.6070903@ertw.com> <2CEB6DA5040AED4F946351C85FAC87B56FA9AB@DEJENSAPP01V1.vision.zeiss.org> Message-ID: <254c7bfb0705110934h5beca7cdlc09a66e00c21b2@mail.gmail.com> >I'm on the tail end of writing a c++ to erlang binding, Hmmm, I'm working on ruby bindings. Java, C, C++, Perl, Ruby. Anyone NOT writing erlang bindings at the moment? :) -tim From mike.toler@REDACTED Fri May 11 18:55:23 2007 From: mike.toler@REDACTED (Mike Toler) Date: Fri, 11 May 2007 11:55:23 -0500 Subject: [erlang-questions] Stand alone TLS encryption module? In-Reply-To: <464432E4.6080507@niclux.org> Message-ID: <56DA5079467D1C48B857C6FE59D5D4FC5877D3@prodeaserve.prodea.local> Am I must missing the point here? Does Tsung support TLS right now? I have not gotten to the point of testing a secure connection yet (that is suppose to happen in the next couple of weeks), so I've been trying to research the problem up to now. Do I just need to specify that the connection is going to be SSL, and when the server sends the "starttls" XMPP message, the SSL module will handle it? (that would be too cool, but it seems like too much to ask for.) Michael -----Original Message----- From: Nicolas Niclausse [mailto:nicolas@REDACTED] Sent: Friday, May 11, 2007 4:10 AM To: Mike Toler Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Stand alone TLS encryption module? Mike Toler ecrivait le 10.05.2007 16:57: > I'm working with the Tsung tool right now (written in Erlang) to load > test a Jabber project. In the real world, all of the communications to > and from the server would be encrypted using TLS, but that isn't > supported by Tsung. Hello, Tsung is able to use the ssl module. From the documentation, this module (since ssl-3.0.6) is able to use tlsv1 : http://www.erlang.org/doc/doc-5.5.4/lib/ssl-3.1/doc/html/index.html Did you try it ? -- Nicolas This message is confidential to Prodea Systems, Inc unless otherwise indicated or apparent from its nature. This message is directed to the intended recipient only, who may be readily determined by the sender of this message and its contents. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient:(a)any dissemination or copying of this message is strictly prohibited; and(b)immediately notify the sender by return message and destroy any copies of this message in any form(electronic, paper or otherwise) that you have.The delivery of this message and its information is neither intended to be nor constitutes a disclosure or waiver of any trade secrets, intellectual property, attorney work product, or attorney-client communications. The authority of the individual sending this message to legally bind Prodea Systems is neither apparent nor implied,and must be independently verified. From nitin.matrix@REDACTED Sat May 12 02:08:37 2007 From: nitin.matrix@REDACTED (Nitin Verma) Date: Sat, 12 May 2007 05:38:37 +0530 Subject: [erlang-questions] casting float to integer Message-ID: <8ffd73620705111708l6229c005j924a92abf6c56c1b@mail.gmail.com> Hi All, I am looking for a function/BIF that can help me. Problem: I need a float number's floored integer. That is if: A = f(5/2), then A = 2 and A = f(1000/501), then A = 1 I found 'round/1' but it just rounds-off . -- Nitin From hokan.stenholm@REDACTED Sat May 12 02:14:31 2007 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Sat, 12 May 2007 02:14:31 +0200 Subject: [erlang-questions] casting float to integer In-Reply-To: <8ffd73620705111708l6229c005j924a92abf6c56c1b@mail.gmail.com> References: <8ffd73620705111708l6229c005j924a92abf6c56c1b@mail.gmail.com> Message-ID: <464506E7.5040807@bredband.net> Nitin Verma wrote: > Hi All, > > I am looking for a function/BIF that can help me. > > Problem: I need a float number's floored integer. That is if: > A = f(5/2), then A = 2 and > A = f(1000/501), then A = 1 > > I found 'round/1' but it just rounds-off . > > -- Nitin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > see erlang.erl documentation: ----------------------------------------------------------------------- *|trunc(Number) -> int()|* Types: *|Number = number()|* Returns an integer by the truncating |Number|. > *trunc(5.5).* 5 Allowed in guard tests. From jeffm@REDACTED Sat May 12 02:44:06 2007 From: jeffm@REDACTED (jm) Date: Sat, 12 May 2007 10:44:06 +1000 Subject: [erlang-questions] casting float to integer In-Reply-To: <8ffd73620705111708l6229c005j924a92abf6c56c1b@mail.gmail.com> References: <8ffd73620705111708l6229c005j924a92abf6c56c1b@mail.gmail.com> Message-ID: <46450DD6.20901@ghostgun.com> Nitin Verma wrote: > Hi All, > > I am looking for a function/BIF that can help me. > > Problem: I need a float number's floored integer. That is if: > A = f(5/2), then A = 2 and > A = f(1000/501), then A = 1 > > I found 'round/1' but it just rounds-off . > You seem to be having the same problem I was with integer arithmetic. I can't seem to find the manual entry for div so here's an example: $ erl Erlang (BEAM) emulator version 5.4.8 [source] [hipe] Eshell V5.4.8 (abort with ^G) 1> 1000 div 501. 1 2> 5 div 2. 2 Jeff. From saleyn@REDACTED Sat May 12 04:01:41 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 11 May 2007 21:01:41 -0500 Subject: [erlang-questions] TibcoRV Message-ID: <46452005.3@gmail.com> Hi, Does anybody have an Erlang driver binding for TibcoRV? Thanks. Serge From tom@REDACTED Sat May 12 09:45:02 2007 From: tom@REDACTED (Tom Samplonius) Date: Sat, 12 May 2007 00:45:02 -0700 (PDT) Subject: [erlang-questions] Is mnesia fit to over TB data handling? In-Reply-To: <855e4dcf0705110209n32e33696j604700910565bde8@mail.gmail.com> Message-ID: <4540454.1921178955902010.JavaMail.root@ly.sdf.com> ----- "Tim Uckun" wrote: > On 5/11/07, Ewan Higgs wrote: > > I think this study will be of interest to you: > > That was indeed interesting thanks. > > It seems to me they should have evaluated mysql cluster. It's feature > set is closest to mnesia and it promises to be suitable for telecom > level uptime. ... MySQL Cluster is not really a replicated database like Mnesia though. In a MySQL Cluster all data nodes have to be tied together by high-speed connects. Also as you add data nodes, query throughput drops, due to locking overhead. That is unavoidable in a pure cluster though, as locks need to synchronously applied to all nodes, as as the number of data nodes increase, so does the locking overhead. Mnesia is rather different. It can be synchronously updated, or not. Supports "dirty" transactions if you need. So it would scale to higher latency network links. Tom From per@REDACTED Sat May 12 09:50:11 2007 From: per@REDACTED (Per Hedeland) Date: Sat, 12 May 2007 09:50:11 +0200 (CEST) Subject: [erlang-questions] casting float to integer In-Reply-To: <464506E7.5040807@bredband.net> Message-ID: <200705120750.l4C7oB2N009699@pluto.hedeland.org> H?kan Stenholm wrote: > >Nitin Verma wrote: >> Hi All, >> >> I am looking for a function/BIF that can help me. >> >> Problem: I need a float number's floored integer. That is if: >> A = f(5/2), then A = 2 and >> A = f(1000/501), then A = 1 >> >> I found 'round/1' but it just rounds-off . >see erlang.erl documentation: > >----------------------------------------------------------------------- > >*|trunc(Number) -> int()|* But trunc is not the same as floor - though maybe Nitin actually wants trunc, or even div (which "truncates" the same way as trunc), as indicated by the examples. When I actually needed floor/1, I came up with this somewhat bizarre-looking definition: floor(V) when V >= 0 -> trunc(V); floor(V) -> trunc(V - trunc(V) + 1) + trunc(V) - 1. There may be a better way to do it... --Per Hedeland From robert.virding@REDACTED Sat May 12 12:36:56 2007 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 12 May 2007 12:36:56 +0200 Subject: [erlang-questions] casting float to integer In-Reply-To: <200705120750.l4C7oB2N009699@pluto.hedeland.org> References: <200705120750.l4C7oB2N009699@pluto.hedeland.org> Message-ID: <464598C8.9040305@telia.com> Can't you instead just have: floor(V) when V >= 0 -> trunc(V); floor(V) -> - trunc(-V) - 1. Robert Per Hedeland wrote: > H?kan Stenholm wrote: >> Nitin Verma wrote: >>> Hi All, >>> >>> I am looking for a function/BIF that can help me. >>> >>> Problem: I need a float number's floored integer. That is if: >>> A = f(5/2), then A = 2 and >>> A = f(1000/501), then A = 1 >>> >>> I found 'round/1' but it just rounds-off . > >> see erlang.erl documentation: >> >> ----------------------------------------------------------------------- >> >> *|trunc(Number) -> int()|* > > But trunc is not the same as floor - though maybe Nitin actually wants > trunc, or even div (which "truncates" the same way as trunc), as > indicated by the examples. When I actually needed floor/1, I came up > with this somewhat bizarre-looking definition: > > floor(V) when V >= 0 -> trunc(V); > floor(V) -> trunc(V - trunc(V) + 1) + trunc(V) - 1. > > There may be a better way to do it... > > --Per Hedeland > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per@REDACTED Sat May 12 14:22:49 2007 From: per@REDACTED (Per Hedeland) Date: Sat, 12 May 2007 14:22:49 +0200 (CEST) Subject: [erlang-questions] casting float to integer In-Reply-To: <464598C8.9040305@telia.com> Message-ID: <200705121222.l4CCMnps015176@pluto.hedeland.org> Robert Virding wrote: > >Can't you instead just have: > >floor(V) when V >= 0 -> trunc(V); >floor(V) -> - trunc(-V) - 1. No, try floor(-1.0). --Per >Robert > >Per Hedeland wrote: >> H?kan Stenholm wrote: >>> Nitin Verma wrote: >>>> Hi All, >>>> >>>> I am looking for a function/BIF that can help me. >>>> >>>> Problem: I need a float number's floored integer. That is if: >>>> A = f(5/2), then A = 2 and >>>> A = f(1000/501), then A = 1 >>>> >>>> I found 'round/1' but it just rounds-off . >> >>> see erlang.erl documentation: >>> >>> ----------------------------------------------------------------------- >>> >>> *|trunc(Number) -> int()|* >> >> But trunc is not the same as floor - though maybe Nitin actually wants >> trunc, or even div (which "truncates" the same way as trunc), as >> indicated by the examples. When I actually needed floor/1, I came up >> with this somewhat bizarre-looking definition: >> >> floor(V) when V >= 0 -> trunc(V); >> floor(V) -> trunc(V - trunc(V) + 1) + trunc(V) - 1. >> >> There may be a better way to do it... >> >> --Per Hedeland From heinrich@REDACTED Sun May 13 11:39:39 2007 From: heinrich@REDACTED (Heinrich Venter) Date: Sun, 13 May 2007 11:39:39 +0200 Subject: [erlang-questions] driver interfaces Message-ID: <000001c79542$a36df120$ea49d360$@com> Hi all I just want to make sure that I understand the driver interface basics correctly. driver_command/2 Takes iodata as data Delivers to the output callback as binary or array Returns values asynchronously with a driver_output call -If the outputv callback is set, this is used instead and delviers the data as ErlIOVec (which is faster) driver_controll/3 Takes iodata as data Delivers to the controll callback as binary or array Returns values synchronously with results in the supplied rbuf parameter -Return values may be either eterm format or binary -Fastest according to docs driver_call/3 Takes an erlang term as data Delivers to the call callback as pointer to eterm Returns values synchronously with results in the rbuf parameter -Return values must be in eterm format It would seem that each has its own uses. driver_controll is useful for exposing C functions most directly. For this the calling erlnang code should send a binary, packed with the parameters in the native format. Returned values will be a binary, again in the native format. driver_call is useful if you want to create functions that look more like erlang functions than C functions. You have to decode the sent terms and encode the responses through ei. driver_command is useful if you need to do asynchronous calls. Perhaps also useful in a multithreaded driver that does long computations (in combination with driver_async)? Some things I don't quite understand: Is the output callbacks format also determined by set_port_controll_flags like form the controll callback? Might it be useful to have a controll type callback that delivers the data as ErlIOVec, for the same optimisation reasons as for the output callback? Is driver_output2 useful? Is there an efficeincy issue with matching on a binary on the erlang side, or does this function predate binary matching? Is it more efficeint to use driver_output_binary than driver_output if it is known beforehand that the port is in binary mode? Any further insights would be appreciated -]-[einrich -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew.pflueger@REDACTED Mon May 14 01:38:40 2007 From: matthew.pflueger@REDACTED (Matthew Pflueger) Date: Sun, 13 May 2007 19:38:40 -0400 Subject: [erlang-questions] GotAPI Message-ID: <7037df270705131638m179c5fdpee2128459f05516d@mail.gmail.com> http://www.gotapi.com recently added the Erlang API to its site. GotAPI makes searching APIs incredibly easy. Check it out! Currently the API is erts 5.5.4 but soon it will be version agnostic... -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon May 14 01:45:02 2007 From: ok@REDACTED (ok) Date: Mon, 14 May 2007 11:45:02 +1200 Subject: [erlang-questions] casting float to integer In-Reply-To: <200705120750.l4C7oB2N009699@pluto.hedeland.org> References: <200705120750.l4C7oB2N009699@pluto.hedeland.org> Message-ID: <8DF6BA0B-07A9-40DE-82EB-473C8C3A8CFB@cs.otago.ac.nz> Concerning float->integer conversion, clearly round/1 and trunc/1 are not enough, and floor/1 and ceil[ing]/1 should also be provided. Until they are, you can find relatively simple code for them in xmerl, which I paraphrase: floor(X) -> case trunc(X) of Y when Y > X -> Y - 1 ; Z -> Z end. ceiling(X) -> case trunc(X) of Y when Y < X -> Y + 1 ; Z -> Z end. From adam@REDACTED Mon May 14 09:15:40 2007 From: adam@REDACTED (Adam Lindberg) Date: Mon, 14 May 2007 09:15:40 +0200 Subject: [erlang-questions] GotAPI In-Reply-To: <6344005f0705140014w197879c4o40a2e013818c534b@mail.gmail.com> References: <7037df270705131638m179c5fdpee2128459f05516d@mail.gmail.com> <6344005f0705140014w197879c4o40a2e013818c534b@mail.gmail.com> Message-ID: <6344005f0705140015g27509583gcb79b19250bceaec@mail.gmail.com> This is good news, the days of searching the Erlang manual by hand are over! ^_^ There's also the Erlang search engine, searching some other sites too: http://shurl.org/erlang Cheers! Adam On 5/14/07, Matthew Pflueger wrote: > http://www.gotapi.com recently added the Erlang API to its site. GotAPI > makes searching APIs incredibly easy. Check it out! > > Currently the API is erts 5.5.4 but soon it will be version agnostic... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- Adam Lindberg Software Developer Erlang Training and Consulting Ltd 401 Fruit and Wool Exchange, Brushfield Street, London, E1 6EL, United Kingdom Company Registration 3893360 VAT Number GB 752 1091 57 Tel +44 207 456 1020 Fax +44 870 1390 779 Mobile +44 7960 726 016 Email adam@REDACTED From cjsvance@REDACTED Mon May 14 09:33:07 2007 From: cjsvance@REDACTED (Christopher Vance) Date: Mon, 14 May 2007 17:33:07 +1000 Subject: [erlang-questions] compiler suite for C node on MS Windows Message-ID: I'm wanting to write (and then compile) a C node on MS Windows. I have the downloaded Windows Erlang, and would like to know which compiler suite I should expect to use (mingw, cygwin, or MS Visual C++). A similar C node will be compiled also on MacOS and BSD, but the content will of course need to differ slightly. -- Christopher From lenartlad@REDACTED Mon May 14 10:29:21 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 14 May 2007 10:29:21 +0200 Subject: [erlang-questions] [Q] ets atomicity Message-ID: <46481DE1.4080607@volny.cz> Hello, just one question about ets (and dets): Suppose I have a {key, value} ets table and two processes (reader and writer) accessing it. If both access the same row of the table at the same time, is it guaranteed by the BIFs that the reader process reads either old row or the newly written one, or put in other words, is row access in ets atomic? Thanks, Ladislav Lenart From thomasl_erlang@REDACTED Mon May 14 10:41:29 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 14 May 2007 01:41:29 -0700 (PDT) Subject: [erlang-questions] GotAPI In-Reply-To: <7037df270705131638m179c5fdpee2128459f05516d@mail.gmail.com> Message-ID: <34140.70025.qm@web38808.mail.mud.yahoo.com> --- Matthew Pflueger wrote: > http://www.gotapi.com recently added the Erlang API > to its site. GotAPI > makes searching APIs incredibly easy. Check it out! > > Currently the API is erts 5.5.4 but soon it will be > version agnostic... Very nice indeed. That would be handy for internal development work too. A nit: some object-oriented terminology is used. So, we have "class compile" in the menu tree for instance. But Erlang doesn't have classes. Best, Thomas ____________________________________________________________________________________ Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. http://sims.yahoo.com/ From mats.cronqvist@REDACTED Mon May 14 10:47:03 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 14 May 2007 10:47:03 +0200 Subject: [erlang-questions] compiler suite for C node on MS Windows In-Reply-To: References: Message-ID: <46482207.2010405@ericsson.com> Christopher Vance wrote: > I'm wanting to write (and then compile) a C node on MS Windows. I > have the downloaded Windows Erlang, and would like to know which > compiler suite I should expect to use (mingw, cygwin, or MS Visual > C++). A similar C node will be compiled also on MacOS and BSD, but > the content will of course need to differ slightly. FWIW, i believe OTP uses cygwin for the official MS build. mats From kenneth.lundin@REDACTED Mon May 14 11:16:30 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 14 May 2007 11:16:30 +0200 Subject: [erlang-questions] [Q] ets atomicity In-Reply-To: <46481DE1.4080607@volny.cz> References: <46481DE1.4080607@volny.cz> Message-ID: Hi, Yes, ets and dets access per table entry is atomic. /Kenneth (OTP Team at Ericsson) On 5/14/07, Ladislav Lenart wrote: > Hello, > > just one question about ets (and dets): Suppose I have a {key, value} > ets table and two processes (reader and writer) accessing it. If both > access the same row of the table at the same time, is it guaranteed > by the BIFs that the reader process reads either old row or the newly > written one, or put in other words, is row access in ets atomic? > > Thanks, > > Ladislav Lenart > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From matthias@REDACTED Mon May 14 18:28:48 2007 From: matthias@REDACTED (Matthias Radestock) Date: Mon, 14 May 2007 17:28:48 +0100 Subject: [erlang-questions] permanently removing a mnesia node Message-ID: Say I have a running mnesia cluster with four disk-copy nodes - node1, node2, node3, node4. I shut down all four nodes. Then I discover that the machines for node3 and node4 have disappeared, never to come back. How do I get node1 and node2 working again such that they share data with each other but no longer require the presence of node3 and node4? I can use force_load_table or set_master_nodes to get node1 and node2 running, but I'd have to do that every time I start the nodes, which doesn't seem right. Furthermore, I then cannot make any subsequent changes to the schema since schema operations appear to require all disk-copy nodes to be present. Note that if only one of node3 or node4 disappear I can use del_table_copy to remove the schema copy from that node. However, if more than one node has disappeared them del_table_copy fails since it requires all other disk-copy nodes to be running. So in the example, del_table_copy(schema, node3) complains that node4 isn't running and del_table_copy(schema, node4) complains that node3 isn't running. One suggestion from #erlang was to fake the disappeared nodes on another machine, so that the aforementioned del_table_copy succeeds. That is a rather complex operation though and feels like a hack. Another suggestion was to create a backup of the db, remove all references to the disappeared nodes from it (using a variation of the change_node_name function from the Mnesia User Guide), and then restore it. That is rather involved though, particularly when there are several cluster nodes remaining. Is there a better solution? Should the mnesia api perhaps be extended so that when removing copies of the schema table it is possible to specify *several* nodes, e.g. del_table_copy(schema, [node3, node4]) in the example, and the operation succeeds as long as all remaining disk-nodes are running? Regards, Matthias. From nitin.matrix@REDACTED Mon May 14 19:02:49 2007 From: nitin.matrix@REDACTED (Nitin Verma) Date: Mon, 14 May 2007 22:32:49 +0530 Subject: [erlang-questions] casting float to integer In-Reply-To: <200705121222.l4CCMnps015176@pluto.hedeland.org> References: <464598C8.9040305@telia.com> <200705121222.l4CCMnps015176@pluto.hedeland.org> Message-ID: <8ffd73620705141002o194566b8ic2959f67c4d4bdd5@mail.gmail.com> Thanx for all the replies, appreciate it. I am very new to functional programming, and to Erlang. This all helped me a lot. I saw something very weird. ( 2^(n-1) ? 1 ) / 2^n + 1/2 < 1 --- 1> Tc=(math:pow(2,52) - 1) / math:pow(2,53). 0.500000 2> Td= Tc + 1/2. 1.000000 3> trunc(Td). 0 This is correct. --- 1> Tc=(math:pow(2,53) - 1) / math:pow(2,54). 0.500000 2> Td=Tc + 1/2. 1.00000 3> trunc(Td). 1 eeh, what happened here? On 5/12/07, Per Hedeland wrote: > Robert Virding wrote: > > > >Can't you instead just have: > > > >floor(V) when V >= 0 -> trunc(V); > >floor(V) -> - trunc(-V) - 1. > > No, try floor(-1.0). > > --Per > > >Robert > > > >Per Hedeland wrote: > >> H?kan Stenholm wrote: > >>> Nitin Verma wrote: > >>>> Hi All, > >>>> > >>>> I am looking for a function/BIF that can help me. > >>>> > >>>> Problem: I need a float number's floored integer. That is if: > >>>> A = f(5/2), then A = 2 and > >>>> A = f(1000/501), then A = 1 > >>>> > >>>> I found 'round/1' but it just rounds-off . > >> > >>> see erlang.erl documentation: > >>> > >>> ----------------------------------------------------------------------- > >>> > >>> *|trunc(Number) -> int()|* > >> > >> But trunc is not the same as floor - though maybe Nitin actually wants > >> trunc, or even div (which "truncates" the same way as trunc), as > >> indicated by the examples. When I actually needed floor/1, I came up > >> with this somewhat bizarre-looking definition: > >> > >> floor(V) when V >= 0 -> trunc(V); > >> floor(V) -> trunc(V - trunc(V) + 1) + trunc(V) - 1. > >> > >> There may be a better way to do it... > >> > >> --Per Hedeland > From bob@REDACTED Mon May 14 19:33:17 2007 From: bob@REDACTED (Bob Ippolito) Date: Mon, 14 May 2007 10:33:17 -0700 Subject: [erlang-questions] casting float to integer In-Reply-To: <8ffd73620705141002o194566b8ic2959f67c4d4bdd5@mail.gmail.com> References: <464598C8.9040305@telia.com> <200705121222.l4CCMnps015176@pluto.hedeland.org> <8ffd73620705141002o194566b8ic2959f67c4d4bdd5@mail.gmail.com> Message-ID: <6a36e7290705141033r6664142cicf4b7d434f0cc5c3@mail.gmail.com> Floating point math happened. The float precision of the Erlang shell is very misleading. 1> io:format("~.21g~n", [(math:pow(2,52) - 1) / math:pow(2,53)]). 0.499999999999999888978 ok 2> io:format("~.21g~n", [((math:pow(2,52) - 1) / math:pow(2,53)) + 1/2]). 0.999999999999999888978 ok 3> io:format("~.21g~n", [(math:pow(2,53) - 1) / math:pow(2,54)]). 0.499999999999999944489 ok 4> io:format("~.21g~n", [((math:pow(2,53) - 1) / math:pow(2,54)) + 1/2]). 1.00000000000000000000 ok This is what you should expect from any language that uses floating point math. Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import division >>> (2**52 - 1) / (2**53) 0.49999999999999989 >>> (2**53 - 1) / (2**54) 0.49999999999999994 >>> ((2**52 - 1) / (2**53)) + (1/2) 0.99999999999999989 >>> ((2**53 - 1) / (2**54)) + (1/2) 1.0 You might want to read up on how IEEE-754 doubles (64-bit floating point) work. It's the de facto standard representation for a "float" type in most languages (except the ones where you can choose "float" or "double", where "float" is a 32-bit single). -bob On 5/14/07, Nitin Verma wrote: > Thanx for all the replies, appreciate it. I am very new to functional > programming, and to Erlang. This all helped me a lot. > > I saw something very weird. > > ( 2^(n-1) ? 1 ) / 2^n + 1/2 < 1 > --- > > 1> Tc=(math:pow(2,52) - 1) / math:pow(2,53). > 0.500000 > 2> Td= Tc + 1/2. > 1.000000 > 3> trunc(Td). > 0 > > This is correct. > --- > > 1> Tc=(math:pow(2,53) - 1) / math:pow(2,54). > 0.500000 > 2> Td=Tc + 1/2. > 1.00000 > 3> trunc(Td). > 1 > > eeh, what happened here? > > > > On 5/12/07, Per Hedeland wrote: > > Robert Virding wrote: > > > > > >Can't you instead just have: > > > > > >floor(V) when V >= 0 -> trunc(V); > > >floor(V) -> - trunc(-V) - 1. > > > > No, try floor(-1.0). > > > > --Per > > > > >Robert > > > > > >Per Hedeland wrote: > > >> H?kan Stenholm wrote: > > >>> Nitin Verma wrote: > > >>>> Hi All, > > >>>> > > >>>> I am looking for a function/BIF that can help me. > > >>>> > > >>>> Problem: I need a float number's floored integer. That is if: > > >>>> A = f(5/2), then A = 2 and > > >>>> A = f(1000/501), then A = 1 > > >>>> > > >>>> I found 'round/1' but it just rounds-off . > > >> > > >>> see erlang.erl documentation: > > >>> > > >>> ----------------------------------------------------------------------- > > >>> > > >>> *|trunc(Number) -> int()|* > > >> > > >> But trunc is not the same as floor - though maybe Nitin actually wants > > >> trunc, or even div (which "truncates" the same way as trunc), as > > >> indicated by the examples. When I actually needed floor/1, I came up > > >> with this somewhat bizarre-looking definition: > > >> > > >> floor(V) when V >= 0 -> trunc(V); > > >> floor(V) -> trunc(V - trunc(V) + 1) + trunc(V) - 1. > > >> > > >> There may be a better way to do it... > > >> > > >> --Per Hedeland > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pix@REDACTED Mon May 14 19:11:58 2007 From: pix@REDACTED (Federico Feroldi) Date: Mon, 14 May 2007 19:11:58 +0200 Subject: [erlang-questions] Suggestion for a spell corrector implementation Message-ID: Hello everybody, following the Spell Corrector implementation in 20 lines of Python code made by Peter Norvig (http://www.norvig.com/spell-correct.html) I wanted to try an Erlang one, here's what I did: http://www.pixzone.com/blog/223/spell-corrector-aka-google-suggest-in-erlang-first-part/ It's a bit more that 20 lines of code but it can be probably refactored and optimized, I'm open to any suggestions on how to improve the code! thanks -federico http://www.pixzone.com/blog/ From horndude77@REDACTED Tue May 15 04:25:53 2007 From: horndude77@REDACTED (Jay Anderson) Date: Tue, 15 May 2007 02:25:53 +0000 (UTC) Subject: [erlang-questions] Erlang math libraries Message-ID: Are there any math libraries for erlang out there. I'm looking for things like vector/matrix operations, arbitrary precision real number operations, rational number operations, complex number operations, etc... If not are there any wrappers around c/c++/java libraries of this sort? A bit of searching didn't turn up anything. Thanks! -----Jay From matthias@REDACTED Tue May 15 08:42:24 2007 From: matthias@REDACTED (Matthias Lang) Date: Tue, 15 May 2007 08:42:24 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: Message-ID: <17993.22096.76503.895100@antilipe.corelatus.se> > vector/matrix operations, arbitrary precision real number > operations, rational number operations, complex number operations, > etc... If not are there any wrappers around c/c++/java libraries of > this sort? A bit of searching didn't turn up anything. Thanks! This sort of stuff is a fair way off Erlang's beaten path. A couple of leads which spring to mind are - Wings3d, which you can find on sourceforge, does a fair bit of matrix work in Erlang. It's probably worth looking at the code there (in the e3d directory) - Tony Rogvall was playing around with various complex/complex transforms in Erlang a while ago. I don't know if he reads the list, though. Classy email address, btw. Matthias From erlang@REDACTED Tue May 15 12:18:28 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 15 May 2007 12:18:28 +0200 Subject: [erlang-questions] Suggestion for a spell corrector implementation In-Reply-To: References: Message-ID: <9b08084c0705150318r15c2ffc5sa5865ffdc47d5855@mail.gmail.com> It's rather difficult to read your code - is it possible to indent the code so as to show the structure, and use shorter function names etc. this would make it much more readable ... You could write deletions like this: deletions(Word) -> [Word -- [I] || I <- Word] -- is the list subtraction operator The 3'rd clause of transposition_edits is a mess Change transposition_edits(Before, [Current, Next | After], Edits) -> transposition_edits([Current | Before], [Next | After], [ lists:reverse(Before) ++ [Next, Current] ++ After | Edits]). To: transposition_edits(Before, [Current, Next | After], Edits) -> transposition_edits([Current | Before], [Next | After], reverse(Before, [Next, Current|After]) | Edits]). I'd probably write it like this trans([H,H1|T], Before, L) -> trans([H1|T], [H|Before], [reverse(Before, [H1,H|After]) | L] The convention I use is to put the list I am "reducing" on the far left and call the variables [H|T] etc. the "result" is the last argument - it's a list (called L). Whenever you see ++ think "can I get rid of this" /Joe On 5/14/07, Federico Feroldi wrote: > Hello everybody, > following the Spell Corrector implementation in 20 lines of Python code > made by Peter Norvig (http://www.norvig.com/spell-correct.html) I wanted > to try an Erlang one, here's what I did: > > http://www.pixzone.com/blog/223/spell-corrector-aka-google-suggest-in-erlang-first-part/ > > It's a bit more that 20 lines of code but it can be probably refactored > and optimized, I'm open to any suggestions on how to improve the code! > > thanks > > -federico > > http://www.pixzone.com/blog/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pix@REDACTED Tue May 15 12:49:51 2007 From: pix@REDACTED (Federico Feroldi) Date: Tue, 15 May 2007 12:49:51 +0200 Subject: [erlang-questions] Suggestion for a spell corrector implementation In-Reply-To: <9b08084c0705150318r15c2ffc5sa5865ffdc47d5855@mail.gmail.com> References: <9b08084c0705150318r15c2ffc5sa5865ffdc47d5855@mail.gmail.com> Message-ID: Joe Armstrong wrote: > It's rather difficult to read your code - is it possible to indent the code > so as to show the structure, and use shorter function names etc. this would make > it much more readable Hi Joe, thanks for the suggestion, I've tried to indent the code to my tastes, are there any style guidelines for the Erlang code? (such as GNU intending style for C/C++ code) > You could write deletions like this: > > deletions(Word) -> > [Word -- [I] || I <- Word] > > -- is the list subtraction operator As I understand this will only remove the 1st occurrence of each letter, what I need in this case is to remove each position letter once. 6> W2 = "santa". "santa" 7> [W2 -- [I] || I <- W2]. ["anta","snta","sata","sana","snta"] you got "snta" two times, the last one should be "sant". > trans([H,H1|T], Before, L) -> > trans([H1|T], [H|Before], [reverse(Before, [H1,H|After]) | L] > > The convention I use is to put the list I am "reducing" on the far left > and call the variables [H|T] etc. the "result" is the last argument - it's > a list (called L). Thanks for the suggestion! I just user more "verbose" names to let people unfamiliar with Erlang's syntax understand it better! :) Do you believe I can implement the edits generator function with some kind of list comprehension instead of using recursion? thanks! (sorry for the bad code, I've just started to learn Erlang!) -federico http://www.pixzone.com/blog/ From ulf.wiger@REDACTED Tue May 15 12:52:00 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 15 May 2007 12:52:00 +0200 Subject: [erlang-questions] Suggestion for a spell corrector implementation In-Reply-To: References: Message-ID: <6616D98C65DD514BA2E1DDC5F922315501DE1E39@esealmw115.eemea.ericsson.se> Here's a suggestion for transposition_edits(), that I find a little bit more intuitive: transposition_edits(Word) -> Transpose = fun(P) -> lists:concat([string:sub_string(Word,1,P), lists:reverse( string:sub_string(Word,P+1,P+2)), string:sub_string(Word,P+3)]) end, [Transpose(P) || P <- lists:seq(0,length(Word)-2)]. (Not making any claims about it being efficient or anything - it's probably efficient enough.) BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Federico Feroldi > Sent: den 14 maj 2007 19:12 > To: erlang-questions@REDACTED > Subject: [erlang-questions] Suggestion for a spell corrector > implementation > > Hello everybody, > following the Spell Corrector implementation in 20 lines of > Python code made by Peter Norvig > (http://www.norvig.com/spell-correct.html) I wanted to try an > Erlang one, here's what I did: > > http://www.pixzone.com/blog/223/spell-corrector-aka-google-sug gest-in-erlang-first-part/ > > It's a bit more that 20 lines of code but it can be probably > refactored and optimized, I'm open to any suggestions on how > to improve the code! > > thanks > > -federico > > http://www.pixzone.com/blog/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From samir.bot@REDACTED Tue May 15 15:45:06 2007 From: samir.bot@REDACTED (Samir Saklikar) Date: Tue, 15 May 2007 19:15:06 +0530 Subject: [erlang-questions] Crypto_drv does not link Message-ID: Hello All, I am trying to compile Erlang 5.5.4 on cygwin. Here is the error I get ../priv/obj/i686-pc-cygwin/crypto_drv.o: In function `start': /cygdrive/d/erlang/otp_src_R11B-4/lib/crypto/c_src/crypto_drv.c:151: undefined reference to `set_port_control_flags' /cygdrive/d/erlang/otp_src_R11B-4/lib/crypto/c_src/crypto_drv.c:152: undefined reference to `driver_alloc' /cygdrive/d/erlang/otp_src_R11B-4/lib/crypto/c_src/crypto_drv.c:152: undefined reference to `driver_free' /cygdrive/d/otp_src_R11B-4/lib/crypto/c_src/crypto_drv.c:152: undefined reference to `driver_realloc' and similar errors for driver_alloc_binary. I checked that all of these seem to be defined in erts/emulator/beam/io.c ... How come this file is not getting linked ? What is the name of the library for that ? I tried something like the following...but of no use /erts $ find . -name "*.a" | xargs nm -a | grep driver_alloc_binary What am i missing here ? Is there some issue with Erlang on Cywin ? thanks and regards Samir -------------- next part -------------- An HTML attachment was scrubbed... URL: From masca@REDACTED Tue May 15 16:07:10 2007 From: masca@REDACTED (=?ISO-8859-2?Q?Martin_Dvo=F8=E1k?=) Date: Tue, 15 May 2007 16:07:10 +0200 Subject: [erlang-questions] mnesia shutdown Message-ID: <4649BE8E.9080303@volny.cz> Hello, I'm building a mnesia application and I wonder how the system can be shutdown so that nothing that should be in the database is lost. Before the application shutdown I suspend all the processes (so that no more data is generated) and I wish to halt the node after everything has been written to disk. I've read mnesia and ejabberd sources and I found no point where the application ensures proper database shutdown. Can you point me to some docs or give a hint? Thanks, Martin From pacini@REDACTED Tue May 15 16:29:48 2007 From: pacini@REDACTED (Filippo Pacini) Date: Tue, 15 May 2007 16:29:48 +0200 Subject: [erlang-questions] mnesia shutdown In-Reply-To: <4649BE8E.9080303@volny.cz> References: <4649BE8E.9080303@volny.cz> Message-ID: <4649C3DC.9080909@sgconsulting.it> Hi, I'm not an expert, but init:stop() should be what you are looking for. cheers, filippo Martin Dvo??k wrote: > Hello, > > I'm building a mnesia application and I wonder how the system can be > shutdown so that nothing that should be in the database is lost. > > Before the application shutdown I suspend all the processes (so that no > more data is generated) and I wish to halt the node after everything has > been written to disk. > > I've read mnesia and ejabberd sources and I found no point where the > application ensures proper database shutdown. > > Can you point me to some docs or give a hint? > > Thanks, > Martin > From francesco@REDACTED Tue May 15 16:46:09 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Tue, 15 May 2007 15:46:09 +0100 Subject: [erlang-questions] Comercial Users of Functional Programming Languages Deadline June 1st Message-ID: <4649C7B1.5010903@erlang-consulting.com> A node to say that the deadline for the CUFP talk submission is approaching. The goal of the CUFP workshop is to act as a voice for these users of functional languages. The workshop supports the increasing viability of functional programming in the commercial, governmental, and open-source space by providing a forum for FP professionals to share their experiences and ideas, whether those ideas are related to business, management, or engineering. The workshop is also designed to enable the formation and reinforcement of relationships that further the commercial use of functional languages. Providing user feedback to language designers and implementors is not a primary goal of the workshop, though it will be welcome if it occurs. Talks are typically about 30-45 minutes long, but can be shorter. They aim to inform participants about how functional programming played out in real-world applications, focusing especially on the re-usable lessons learned, or insights gained. Your talk does not need to be highly technical; for this audience, reflections on the commercial, management, or software engineering aspects are, if anything, more important. You do not need to submit a paper! If you are interested in offering a talk, or nominating someone to do so, send an e-mail to /kfisher at research.att.com/ or /simonpj at microsoft.com/ by *June 1, 2007* with a short description of what you'd like to talk about or what you think your nominee should give a talk about. Such descriptions should be roughly a page in length. For more information and to view past proceedings, visit http://cufp.galois.com/ Regards, Francesco -- http://www.erlang-consulting.com From codeslinger@REDACTED Tue May 15 22:27:16 2007 From: codeslinger@REDACTED (Toby DiPasquale) Date: Tue, 15 May 2007 16:27:16 -0400 Subject: [erlang-questions] mnesia shutdown In-Reply-To: <4649C3DC.9080909@sgconsulting.it> References: <4649BE8E.9080303@volny.cz> <4649C3DC.9080909@sgconsulting.it> Message-ID: On May 15, 2007, at 10:29 AM, Filippo Pacini wrote: > Hi, > I'm not an expert, but init:stop() should be what you are looking for. Also, if you're in the shell, q() is an alias for init:stop() so either will work from the REPL. -- Toby DiPasquale From ok@REDACTED Wed May 16 02:00:39 2007 From: ok@REDACTED (ok) Date: Wed, 16 May 2007 12:00:39 +1200 Subject: [erlang-questions] Suggestion for a spell corrector implementation In-Reply-To: <9b08084c0705150318r15c2ffc5sa5865ffdc47d5855@mail.gmail.com> References: <9b08084c0705150318r15c2ffc5sa5865ffdc47d5855@mail.gmail.com> Message-ID: <04D489EE-5660-4AF8-AFF5-E329A7FA83C9@cs.otago.ac.nz> On 15 May 2007, at 10:18 pm, Joe Armstrong wrote: > You could write deletions like this: > > deletions(Word) -> > [Word -- [I] || I <- Word] > > -- is the list subtraction operator Unfortunately, this gives the wrong answers. deletions("suggest") = ["uggest","sggest","sugest","sugest","uggest","sugges"] ok ok ok ok* wrong ok The second "sugest" happens to be a good answer, but for the wrong reason. It should be there because the second "g" was deleted, but it's there because the first one was deleted again. We see this clearly in the fact that "uggest" was reported a second time, when the right answer there was "sugget". deletions("mama") = ["ama","mma","ama","mma"] where we are now missing two of the right answers. deletions([]) -> []; deletions([C|Cs]) -> [Cs | [[C|Ds] || Ds <- deletions(Cs)]]. seems to be the simplest way to get the right answer. With this definition, deletions("suggest") = ["uugest","sggest","sugest","sugest","suggst","sugget","sugges"] deletions("mama") = ["ama","mma","maa","mam"] From horndude77@REDACTED Wed May 16 05:39:09 2007 From: horndude77@REDACTED (Jay Anderson) Date: Wed, 16 May 2007 03:39:09 +0000 (UTC) Subject: [erlang-questions] Erlang math libraries References: <17993.22096.76503.895100@antilipe.corelatus.se> Message-ID: > This sort of stuff is a fair way off Erlang's beaten path. That's too bad, many big numerical computations are highly parallelizable which seems to be the big sell of erlang. Are there reasons these problems are not solved with erlang? I wrote my own quick and dirty rational module to do what I need for now. > A couple of leads which spring to mind are > > - Wings3d, which you can find on sourceforge, does a fair bit of > matrix work in Erlang. It's probably worth looking at the code > there (in the e3d directory) > This does indeed have vector and matrix operations, but not for the general case. (I was pleasantly surprised however by how easy it was to understand their code. Perhaps that's a tribute to erlang.) I'd want to do much larger matrix operations. Any thoughts on how to represent a matrix with erlang? (dense or sparse) Would a list of lists be good enough or would there be a better way? > - Tony Rogvall was playing around with various complex/complex > transforms in Erlang a while ago. I don't know if he reads the > list, though. > > Classy email address, btw. Sigh, perhaps it's time for a change. I've had this email for a very long time. I play the horn. Well, played until I got these blasted braces. They make it quite a bit more difficult. -----Jay From jeffm@REDACTED Wed May 16 05:52:27 2007 From: jeffm@REDACTED (jm) Date: Wed, 16 May 2007 13:52:27 +1000 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> Message-ID: <464A7FFB.8000408@ghostgun.com> Jay Anderson wrote: > This does indeed have vector and matrix operations, but not for the general > case. (I was pleasantly surprised however by how easy it was to understand their > code. Perhaps that's a tribute to erlang.) I'd want to do much larger matrix > operations. Any thoughts on how to represent a matrix with erlang? (dense or > sparse) Would a list of lists be good enough or would there be a better way? > I'd sneek a look at how lisp or haskell handle matrices to get some ideas. Jeff. From dgud@REDACTED Wed May 16 08:45:38 2007 From: dgud@REDACTED (Dan Gudmundsson) Date: Wed, 16 May 2007 08:45:38 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> Message-ID: <464AA892.7090505@erix.ericsson.se> Jay Anderson wrote: > >> A couple of leads which spring to mind are >> >> - Wings3d, which you can find on sourceforge, does a fair bit of >> matrix work in Erlang. It's probably worth looking at the code >> there (in the e3d directory) >> > > This does indeed have vector and matrix operations, but not for the general > case. (I was pleasantly surprised however by how easy it was to understand their > code. Perhaps that's a tribute to erlang.) I'd want to do much larger matrix > operations. Any thoughts on how to represent a matrix with erlang? (dense or > sparse) Would a list of lists be good enough or would there be a better way? > There is a sparse matrix solver in wings/plugins_src/autouv/auv_matrix.erl used in auv_mapping.erl. But you need something different for a dense matrix. /Dan From dcaoyuan@REDACTED Wed May 16 10:35:09 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Wed, 16 May 2007 16:35:09 +0800 Subject: [erlang-questions] io:format error with UTF-8 encoding binary Message-ID: Hi, Did somebody else encounter error when io:format(~p~n, [Bin]) where Bin is a binary with UTF-8 encoding string? I encountered this error several times, to reproduce it, please try attached text file: > erl 1> {ok, Bin} = file:read_file("6.txt"). 2> io:format("Content: ~p~n", [Bin]). Then erl shell will hang, without any error message printed out. And also, the Bin could not be inserted into MYSQL blob field too. The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these 3 bytes, everything works fine. My environment is Windows XP. the OTP is otp_win32_R11B-4 Thanks. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 6.txt URL: From bengt.kleberg@REDACTED Wed May 16 10:48:06 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 16 May 2007 10:48:06 +0200 Subject: [erlang-questions] io:format error with UTF-8 encoding binary In-Reply-To: References: Message-ID: <464AC546.3040203@ericsson.com> On 2007-05-16 10:35, Caoyuan wrote: > Hi, > > Did somebody else encounter error when io:format(~p~n, [Bin]) where > Bin is a binary with UTF-8 encoding string? ...deleted > The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these > 3 bytes, everything works fine. > > My environment is Windows XP. the OTP is otp_win32_R11B-4 this is not possible to reproduce on solaris. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From vladdu55@REDACTED Wed May 16 10:57:38 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 16 May 2007 10:57:38 +0200 Subject: [erlang-questions] io:format error with UTF-8 encoding binary In-Reply-To: References: Message-ID: <95be1d3b0705160157n1a1d6f9cq7c504c7032f143d9@mail.gmail.com> Hi, It works for me just fine on Windows. regards, Vlad On 5/16/07, Caoyuan wrote: > Hi, > > Did somebody else encounter error when io:format(~p~n, [Bin]) where > Bin is a binary with UTF-8 encoding string? > > I encountered this error several times, to reproduce it, please try > attached text file: > > erl > 1> {ok, Bin} = file:read_file("6.txt"). > 2> io:format("Content: ~p~n", [Bin]). > > Then erl shell will hang, without any error message printed out. And > also, the Bin could not be inserted into MYSQL blob field too. > > The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these > 3 bytes, everything works fine. > > My environment is Windows XP. the OTP is otp_win32_R11B-4 > > Thanks. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From matthias@REDACTED Wed May 16 12:01:42 2007 From: matthias@REDACTED (Matthias Lang) Date: Wed, 16 May 2007 12:01:42 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> Message-ID: <17994.54918.577247.227597@antilipe.corelatus.se> Matthias > > This sort of stuff is a fair way off Erlang's beaten path. Jay > That's too bad, many big numerical computations are highly Jay > parallelizable which seems to be the big sell of erlang. Jay > Are there reasons these problems are not solved with erlang? Pragmatic: The first big and successful Erlang projects were telecom control systems. Using Erlang in similar applications is thus fairly low-risk. Which makes it the beaten path by default. Attempt at a big picture: There's a range of ways to "do things in parallel" and they differ radically in scale. At one extreme you have parallelism at the instruction level, e.g. a TI 6x DSP executes 8 instructions every clock cycle and doesn't care (1) about data dependencies. Then you move up through things like hyperthreading to approaches with multiple cores sharing one on-die L2 cache and then separate CPUs sharing main memory. After that come shared-bus systems (blades) and then LAN-coupled approaches (clusters). After that come even more loosely coupled systems. You can expect Erlang to be a good candidate for exploiting hardware which "does things in parallel" for two mostly independent reasons. One reason is basically as per the 1977 Backus paper (2), which I think boils down to "functional programs are more amenable to fine-grained parallelisation". The sort of parallelisation which, say, a TI 6x DSP provides. I don't think Erlang even attempts to exploit this in practice. Another reason is that Erlang programs are naturally divided into many largely independent processes. This lets you exploit the sort of parallelism in the range from multicore to cluster. Lots of Erlang systems win from this in practice, even ones which weren't even written with such hardware in mind. This is a big selling point for people writing, say, control systems for telecom switches. For people writing numerical applications, the easily exploited gains from coarse-grained parallelism might be attractive, or they might not. It's certainly not as clear a win, especially not when the competition in that area is so stiff. If anyone has a reference to something, anything, which formalises the concept of "scale in paralellism", I'd love to know about it. Others on the list have tried to distinguish between "concurrency" and "parallelism", but I haven't seen anything which suggests that there's a widely accepted difference in meaning. Matthias (1) I.e. if two of those 8 instructions write to the same register, that is your problem, not the CPUs. In practice, the C compiler takes care of that, but it sure makes single-stepping the machine code interesting. (2) http://www.stanford.edu/class/cs242/readings/backus.pdf I last read this paper years ago. It's possible I've completely mischaracterised its contents. From dcaoyuan@REDACTED Wed May 16 13:55:47 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Wed, 16 May 2007 19:55:47 +0800 Subject: [erlang-questions] io:format error with UTF-8 encoding binary In-Reply-To: <95be1d3b0705160157n1a1d6f9cq7c504c7032f143d9@mail.gmail.com> References: <95be1d3b0705160157n1a1d6f9cq7c504c7032f143d9@mail.gmail.com> Message-ID: I'm just wondering if it depends on OS and OS's default Language setting, my language setting is zh_CN. I tried again and again on my machine, it hangs every time :-) On 5/16/07, Vlad Dumitrescu wrote: > Hi, > > It works for me just fine on Windows. > > regards, > Vlad > > On 5/16/07, Caoyuan wrote: > > Hi, > > > > Did somebody else encounter error when io:format(~p~n, [Bin]) where > > Bin is a binary with UTF-8 encoding string? > > > > I encountered this error several times, to reproduce it, please try > > attached text file: > > > erl > > 1> {ok, Bin} = file:read_file("6.txt"). > > 2> io:format("Content: ~p~n", [Bin]). > > > > Then erl shell will hang, without any error message printed out. And > > also, the Bin could not be inserted into MYSQL blob field too. > > > > The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these > > 3 bytes, everything works fine. > > > > My environment is Windows XP. the OTP is otp_win32_R11B-4 > > > > Thanks. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > From adam@REDACTED Wed May 16 16:06:56 2007 From: adam@REDACTED (Adam Lindberg) Date: Wed, 16 May 2007 16:06:56 +0200 Subject: [erlang-questions] io:format error with UTF-8 encoding binary In-Reply-To: References: <95be1d3b0705160157n1a1d6f9cq7c504c7032f143d9@mail.gmail.com> Message-ID: <6344005f0705160706v51acaf7fnd0b8eea6c1180878@mail.gmail.com> Hi Caoyuan! You could try to change the language and see if that's it. Try going to the Control Panel and start Regional and Language settings and change it, see if that helps. You could also try to temporarily change keyboard layout (seems to me that some stuff in Windows is connected to that too). Cheers! Adam On 5/16/07, Caoyuan wrote: > I'm just wondering if it depends on OS and OS's default Language > setting, my language setting is zh_CN. I tried again and again on my > machine, it hangs every time :-) > > On 5/16/07, Vlad Dumitrescu wrote: > > Hi, > > > > It works for me just fine on Windows. > > > > regards, > > Vlad > > > > On 5/16/07, Caoyuan wrote: > > > Hi, > > > > > > Did somebody else encounter error when io:format(~p~n, [Bin]) where > > > Bin is a binary with UTF-8 encoding string? > > > > > > I encountered this error several times, to reproduce it, please try > > > attached text file: > > > > erl > > > 1> {ok, Bin} = file:read_file("6.txt"). > > > 2> io:format("Content: ~p~n", [Bin]). > > > > > > Then erl shell will hang, without any error message printed out. And > > > also, the Bin could not be inserted into MYSQL blob field too. > > > > > > The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these > > > 3 bytes, everything works fine. > > > > > > My environment is Windows XP. the OTP is otp_win32_R11B-4 > > > > > > Thanks. > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Adam Lindberg Software Developer Erlang Training and Consulting Ltd 401 Fruit and Wool Exchange, Brushfield Street, London, E1 6EL, United Kingdom Company Registration 3893360 VAT Number GB 752 1091 57 Tel +44 207 456 1020 Fax +44 870 1390 779 Mobile +44 7960 726 016 Email adam@REDACTED From dcaoyuan@REDACTED Wed May 16 17:38:38 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Wed, 16 May 2007 23:38:38 +0800 Subject: [erlang-questions] io:format error with UTF-8 encoding binary In-Reply-To: <6344005f0705160706v51acaf7fnd0b8eea6c1180878@mail.gmail.com> References: <95be1d3b0705160157n1a1d6f9cq7c504c7032f143d9@mail.gmail.com> <6344005f0705160706v51acaf7fnd0b8eea6c1180878@mail.gmail.com> Message-ID: Hi Adam, I tried the Regional and Languages settings, the issue is still there. The problem is a bit strange, sometimes, if I cut the length to a bit small value, it works fine (A longer binary without UTF-8 encoded 3-bytes chars always works fine). Since there is no error messages outputted, I have no way to trace it. In case of my application that uses MYSQL, the erlang node will die when I insert such binary to BLOB field. If this happens only on my environment, it may be os/platform related bug of OTP? Regards, On 5/16/07, Adam Lindberg wrote: > Hi Caoyuan! > > You could try to change the language and see if that's it. Try going > to the Control Panel and start Regional and Language settings and > change it, see if that helps. You could also try to temporarily change > keyboard layout (seems to me that some stuff in Windows is connected > to that too). > > Cheers! > Adam > > On 5/16/07, Caoyuan wrote: > > I'm just wondering if it depends on OS and OS's default Language > > setting, my language setting is zh_CN. I tried again and again on my > > machine, it hangs every time :-) > > > > On 5/16/07, Vlad Dumitrescu wrote: > > > Hi, > > > > > > It works for me just fine on Windows. > > > > > > regards, > > > Vlad > > > > > > On 5/16/07, Caoyuan wrote: > > > > Hi, > > > > > > > > Did somebody else encounter error when io:format(~p~n, [Bin]) where > > > > Bin is a binary with UTF-8 encoding string? > > > > > > > > I encountered this error several times, to reproduce it, please try > > > > attached text file: > > > > > erl > > > > 1> {ok, Bin} = file:read_file("6.txt"). > > > > 2> io:format("Content: ~p~n", [Bin]). > > > > > > > > Then erl shell will hang, without any error message printed out. And > > > > also, the Bin could not be inserted into MYSQL blob field too. > > > > > > > > The lasted three bytes of 6.txt is <<226,128,156>>. If I remove these > > > > 3 bytes, everything works fine. > > > > > > > > My environment is Windows XP. the OTP is otp_win32_R11B-4 > > > > > > > > Thanks. > > > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- > Adam Lindberg > Software Developer > > Erlang Training and Consulting Ltd > 401 Fruit and Wool Exchange, > Brushfield Street, London, > E1 6EL, United Kingdom > Company Registration 3893360 VAT Number GB 752 1091 57 > Tel +44 207 456 1020 > Fax +44 870 1390 779 > Mobile +44 7960 726 016 > Email adam@REDACTED > From roger.larsson@REDACTED Wed May 16 18:36:23 2007 From: roger.larsson@REDACTED (Roger Larsson) Date: Wed, 16 May 2007 18:36:23 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <17994.54918.577247.227597@antilipe.corelatus.se> References: <17994.54918.577247.227597@antilipe.corelatus.se> Message-ID: <200705161836.23418.roger.larsson@norran.net> On Wednesday 16 May 2007 12:01, Matthias Lang wrote: > (1) I.e. if two of those 8 instructions write to the same register, > ? ? that is your problem, not the CPUs. In practice, the C compiler > ? ? takes care of that, but it sure makes single-stepping the machine > ? ? code interesting. It is even worse. You may have several results in different pipeline stages to the same register. This results in really bad interrupt latency since you can not take any interrupts in a tight loop! The C compiler handles that too... But to get maximum performance you need to annotate the code with pragmas - expect errornous results if you get the annotations wrong! Suppose you have a for loop in your code. To get maximum performance you need to annotate it to tell that there will be at least 100 loops, but not more than 1000, in steps of eight. (At least that was needed when I used it some years ago, the analyzer might have become better) /RogerL From garyjefferson123@REDACTED Wed May 16 22:01:06 2007 From: garyjefferson123@REDACTED (Gary Jefferson) Date: Wed, 16 May 2007 13:01:06 -0700 (PDT) Subject: [erlang-questions] number->bytes and bytes->number Message-ID: <669463.34757.qm@web35805.mail.mud.yahoo.com> How do I convert a number like "2 bsl 160" to a list of bytes (20 bytes in this case) and vice versa? thanks, Gary ____________________________________________________________________________________Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. http://farechase.yahoo.com/ From matthias@REDACTED Wed May 16 22:25:40 2007 From: matthias@REDACTED (Matthias Lang) Date: Wed, 16 May 2007 22:25:40 +0200 Subject: [erlang-questions] number->bytes and bytes->number In-Reply-To: <669463.34757.qm@web35805.mail.mud.yahoo.com> References: <669463.34757.qm@web35805.mail.mud.yahoo.com> Message-ID: <17995.26820.687568.138968@antilipe.corelatus.se> Gary Jefferson writes: > How do I convert a number like "2 bsl 160" to a list > of bytes (20 bytes in this case) and vice versa? Assuming you meant 21 octets, not 20: 3> Int = 2 bsl 160. 2923003274661805836407369665432566039311865085952 4> binary_to_list(<>). [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] Depending on how general you want this to be you'll need to write a function to figure out how many bytes the answer will consume. There are various possible approaches which are left as an exercise. Matthias From chsu79@REDACTED Wed May 16 22:31:30 2007 From: chsu79@REDACTED (Christian S) Date: Wed, 16 May 2007 22:31:30 +0200 Subject: [erlang-questions] number->bytes and bytes->number In-Reply-To: <669463.34757.qm@web35805.mail.mud.yahoo.com> References: <669463.34757.qm@web35805.mail.mud.yahoo.com> Message-ID: The maximum unsigned integer you can store in 160 bits (20 bytes) is 2^160-1. Try this in the shell: N = 2 bsl 160 - 1. <>. On 5/16/07, Gary Jefferson wrote: > How do I convert a number like "2 bsl 160" to a list > of bytes (20 bytes in this case) and vice versa? > > thanks, > Gary > > > > ____________________________________________________________________________________Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. > http://farechase.yahoo.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From garyjefferson123@REDACTED Wed May 16 22:54:57 2007 From: garyjefferson123@REDACTED (Gary Jefferson) Date: Wed, 16 May 2007 13:54:57 -0700 (PDT) Subject: [erlang-questions] number->bytes and bytes->number In-Reply-To: Message-ID: <992058.6487.qm@web35813.mail.mud.yahoo.com> Thanks, Matthias and Christian. Now, how do I go back (from list/binary to number)? I'm such a noob. Where is a good resource on reading about datatypes in erlang? Thanks, Gary --- Christian S wrote: > The maximum unsigned integer you can store in 160 > bits (20 bytes) is 2^160-1. > > Try this in the shell: > > N = 2 bsl 160 - 1. > <>. ____________________________________________________________________________________Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. http://smallbusiness.yahoo.com/webhosting From andrew@REDACTED Thu May 17 02:06:45 2007 From: andrew@REDACTED (andrew cooke) Date: Wed, 16 May 2007 20:06:45 -0400 (CLT) Subject: [erlang-questions] Parallel Sudoku Solver Message-ID: <24484.200.120.169.16.1179360405.squirrel@acooke.dyndns.org> Just for fun, but if you have tips on how to improve it (I know nothing about parallel optimisation) then please feel free to comment (in particular, I wondered if there was any kind of parallel equivalent to simulated annealing, perhaps with a temperature that was local to a group of nodes). Cheers, Andrew PS Ooops forgot: http://www.acooke.org/cute/ParallelSu0.html From ok@REDACTED Thu May 17 02:23:48 2007 From: ok@REDACTED (ok) Date: Thu, 17 May 2007 12:23:48 +1200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> Message-ID: <5B5278D4-C010-4E44-B6AA-511C03C0E731@cs.otago.ac.nz> On 16 May 2007, at 3:39 pm, Jay Anderson wrote: > That's too bad, many big numerical computations are highly > parallelizable which seems to be the big sell of erlang. There's a distinction between "parallel" and "concurrent". Erlang is designed for concurrency and distribution rather than parallelism. > Are there reasons these problems are not solved with erlang? If I want Fortran, I know where to find it. If I have a numeric problem which is big enough and hard enough that I want to run it in parallel, I want it to be efficient. There is no substitute for a language that provides a compiler with enough information to pare overheads to the bone, and unfortunately compilers that are really good at optimising numeric code are not cheap to develop. Putting that kind of support into Erlang would have taken scarce development resources away from the kind of problems Erlang was invented for. Mind you, it would be nice to have good numeric performance *as well*, and one could certainly imagine an amalgam of Erlang and APL (but not, please, J; there are good ideas in J but readability isn't one of them). Let's take an example. 8000 dot products of 3000-element vectors: Fortran 90: 0.79 seconds (Sun Fortran compiler, -O3) C 89: 1.96 seconds (Sun C compiler, -xO3) Erlang: 42.33 seconds (erlc +native) You would have to be running on at least 54 machines (assuming linear speedup) for parallel Erlang code to catch up with Fortran, but then the Fortran compiler I use would do automatic parallelisation for me if I had the right licence (quick check: by golly I *DO*, it's just that I only have a uniprocessor machine). > I'd want to do much larger matrix operations. > Any thoughts on how to represent a matrix with erlang? (dense or > sparse) Would a list of lists be good enough or would there be a > better way? A list of lists is good enough *expressively*. You can even do Gaussian elimination with partial pivoting with surprising ease. However, think about the space and memory reference count overheads compared with Fortran or C arrays numbers: both are a factor of two. Another representation is better for parallelism: 1x1 matrix: a number 2nx2n matrix: {TL,TR, BL,BR} For example, matrix_add({Atl,Atr,Abl,Abr}, {Btl,Btr,Bbl,Bbr}) -> {matrix_add(Atl,Btl), matrix_add(Atr,Btr), matrix_add(Abl,Abl), matrix_add(Abr,Bbr)}; matrix_add(A, B) -> A+B. The child adds can proceed in parallel without having to wade through a whole lot of list cells to find their work. From ok@REDACTED Thu May 17 02:38:03 2007 From: ok@REDACTED (ok) Date: Thu, 17 May 2007 12:38:03 +1200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <464A7FFB.8000408@ghostgun.com> References: <17993.22096.76503.895100@antilipe.corelatus.se> <464A7FFB.8000408@ghostgun.com> Message-ID: <061640C9-00C9-4E9F-9D2E-5B07D5CB73A9@cs.otago.ac.nz> On 16 May 2007, at 3:52 pm, jm wrote: > I'd sneek a look at how lisp or haskell handle matrices to get some > ideas. I wouldn't bother. Lisp: aside from some header information, Lisp handles arrays EXACTLY like C and Fortran. In particular, to add 1 to every element of an array of numbers, (do ((i 0 (1+ i))) ; for i := 0 then i+1 ((>= i n)) ; until i >= n do (setf (aref a i) ; a[i] := (+ 1 (aref a i)))) ; 1 + a[i] You can specify the element type of a Lisp array, so you can have arrays of unboxed elements. With careful use of Lisp type annotations, you can (with a good Lisp compiler) avoid all boxing of intermediates, and basically end up with the kind of performance you would expect from a good native code Java compiler. Haskell has support for immutable arrays -- Array indextype elementtype -- but it is so general that the overheads are unpleasantly high. (For example, multidimensional arrays are normally accessed using tuples as subscripts.) There are widely accepted libraries, which are not, however, part of the "standard", which include "state transformation" monads providing mutable variables tamed to fit in a pure functional language, and those libraries include unboxed arrays -- but still with the exceed generality for subscripts. Erlang of course does have tuples, which are immutable simple vectors. From jeffm@REDACTED Thu May 17 02:46:29 2007 From: jeffm@REDACTED (jm) Date: Thu, 17 May 2007 10:46:29 +1000 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <5B5278D4-C010-4E44-B6AA-511C03C0E731@cs.otago.ac.nz> References: <17993.22096.76503.895100@antilipe.corelatus.se> <5B5278D4-C010-4E44-B6AA-511C03C0E731@cs.otago.ac.nz> Message-ID: <464BA5E5.8040308@ghostgun.com> ok wrote: > Mind you, it would be nice to have good numeric performance *as well*, > and one could certainly imagine an amalgam of Erlang and APL (but not, > please, J; there are good ideas in J but readability isn't one of them). > > Let's take an example. > > 8000 dot products of 3000-element vectors: > Fortran 90: 0.79 seconds (Sun Fortran compiler, -O3) > C 89: 1.96 seconds (Sun C compiler, -xO3) > Erlang: 42.33 seconds (erlc +native) > > You would have to be running on at least 54 machines (assuming linear > speedup) for parallel Erlang code to catch up with Fortran, but then > the Fortran compiler I use would do automatic parallelisation for me > if I had the right licence (quick check: by golly I *DO*, it's just > that I only have a uniprocessor machine). That is simple demostration of different languages are better suited, at least todays laguages, to different problem domains. Erlang while developed it a telco environment I actually think of as a control systems langauge for conplex systems. So in is no surprise to be to see it being pick up by web developers. What does suprise me though is that I haven't seen many references to robotics. May be it's just that the web guys make more noise on the mailing list :-). Turning back to the topic at hand. It would be interesting to see what a grid computing scenario with erlang with fortran libraries would be like. Erlang could do the monitoring and control, passing parameters around, etcetera while Fortran with it's execellent maths libraries would do the grunt work. Jeff. From jeffm@REDACTED Thu May 17 04:47:17 2007 From: jeffm@REDACTED (jm) Date: Thu, 17 May 2007 12:47:17 +1000 Subject: [erlang-questions] erlyweb install problems with yaws_headers.hrl Message-ID: <464BC235.6080306@ghostgun.com> In attempting to install erlyweb 0.6 by following the directions at http://yarivsblog.com/articles/2006/10/27/introducing-erlyweb-the-erlang-twist-on-web-framworks/ I get this error: erlyweb:create_app("music", "apps"). =ERROR REPORT==== 17-May-2007::11:43:31 === beam/beam_load.c(1097): Error loading module erlyweb: use of opcode 125; this emulator supports only up to 115 ** exited: {undef,[{erlyweb,create_app,["music","apps"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** 2> =ERROR REPORT==== 17-May-2007::11:43:31 === Loading of /Users/gg/ulocal/lib/erlang/lib/erlyweb-0.6/ebin/erlyweb.beam failed: badfile =ERROR REPORT==== 17-May-2007::11:43:31 === Error in process <0.36.0> with exit value: {undef,[{erlyweb,create_app,["music","apps"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} In an attepmt ot fix this error I cd to the installed directory .../erlyweb-0.6 and execute $ make clean rm ebin/*.beam $ make sh make.sh Recompile: src/erlyweb/yaws_headers src/erlyweb/yaws_headers.erl:31: can't find include file "yaws_api.hrl" src/erlyweb/yaws_headers.erl:35: record headers undefined src/erlyweb/yaws_headers.erl:38: record arg undefined . . src/erlyweb/yaws_headers.erl:86: record headers undefined Crash dump was written to: erl_crash.dump init terminating in do_boot () make: *** [all] Error 1 How do I tell make that the yaws_api.hrl is located in ~/ulocal/lib/yaws/include/ ? Jeff. From goertzen@REDACTED Thu May 17 04:51:54 2007 From: goertzen@REDACTED (Daniel Goertzen) Date: Wed, 16 May 2007 21:51:54 -0500 Subject: [erlang-questions] Announcing eipp: erlang bindings for c++ Message-ID: <464BC34A.2010004@ertw.com> I'm please to announce "eipp": erlang bindings for c++. My employer allowed me to open source this library, so many thanks to http://www.norscan.com . The goal of eipp is to provide a simple, safe, and efficient interface to the erlang External Term Format from c++. This is a work in progress (at http://code.google.com/p/eipp/), but what's there now seems to do useful work. An example is worth a thousand words, so below is a complete port program example. The unit tests also provide good examples until I can scrape together proper documentation. Cheers, Dan. (comments welcome) ----------------------------------------- #include #include "eipp.h" #include "eipp_packet.h" using namespace eipp; using namespace std; int main() { while(1) { atom_t cmd; // atom type... think std::string et data; // generic "erlang term" type // expect tuple of the form {CmdAtom, Data} untuple(cmd,data)=binary_to_term(receive4(cin)); // Only one command supported for now... if(cmd=="times2") { int num=data; // "et" can cast itself to many types num*=2; send4(cout,term_to_binary(tuple("ok",num))); } } } ----------------------------------------- From dcaoyuan@REDACTED Thu May 17 07:05:13 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Thu, 17 May 2007 13:05:13 +0800 Subject: [erlang-questions] erlyweb install problems with yaws_headers.hrl In-Reply-To: <464BC235.6080306@ghostgun.com> References: <464BC235.6080306@ghostgun.com> Message-ID: Edit Emakefile which is under the root folder of erlyweb. There is a line including: {i,"/usr/local/src/yaws/include"} change it to your yaws/include path. On 5/17/07, jm wrote: > In attempting to install erlyweb 0.6 by following the directions at > > http://yarivsblog.com/articles/2006/10/27/introducing-erlyweb-the-erlang-twist-on-web-framworks/ > > I get this error: > > erlyweb:create_app("music", "apps"). > > =ERROR REPORT==== 17-May-2007::11:43:31 === > beam/beam_load.c(1097): Error loading module erlyweb: > use of opcode 125; this emulator supports only up to 115 > > ** exited: {undef,[{erlyweb,create_app,["music","apps"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > 2> > =ERROR REPORT==== 17-May-2007::11:43:31 === > Loading of /Users/gg/ulocal/lib/erlang/lib/erlyweb-0.6/ebin/erlyweb.beam > failed: badfile > > =ERROR REPORT==== 17-May-2007::11:43:31 === > Error in process <0.36.0> with exit value: > {undef,[{erlyweb,create_app,["music","apps"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > In an attepmt ot fix this error I cd to the installed directory > .../erlyweb-0.6 and execute > > $ make clean > rm ebin/*.beam > $ make > sh make.sh > Recompile: src/erlyweb/yaws_headers > src/erlyweb/yaws_headers.erl:31: can't find include file "yaws_api.hrl" > src/erlyweb/yaws_headers.erl:35: record headers undefined > src/erlyweb/yaws_headers.erl:38: record arg undefined > . > . > src/erlyweb/yaws_headers.erl:86: record headers undefined > Crash dump was written to: erl_crash.dump > init terminating in do_boot () > make: *** [all] Error 1 > > How do I tell make that the yaws_api.hrl is located in > ~/ulocal/lib/yaws/include/ ? > > > Jeff. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From timuckun@REDACTED Thu May 17 10:27:29 2007 From: timuckun@REDACTED (Tim Uckun) Date: Thu, 17 May 2007 20:27:29 +1200 Subject: [erlang-questions] Windows service. Message-ID: <855e4dcf0705170127t11df5f65k41fc6255eb8fc870@mail.gmail.com> I noticed that ejabberd runs as a windows service, a quick google search did not point to a library, does anybody know of one? From chandrashekhar.mullaparthi@REDACTED Thu May 17 12:03:27 2007 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 17 May 2007 11:03:27 +0100 Subject: [erlang-questions] number->bytes and bytes->number In-Reply-To: <992058.6487.qm@web35813.mail.mud.yahoo.com> References: <992058.6487.qm@web35813.mail.mud.yahoo.com> Message-ID: On 16/05/07, Gary Jefferson wrote: > Thanks, Matthias and Christian. Now, how do I go back > (from list/binary to number)? I'm such a noob. Where > is a good resource on reading about datatypes in > erlang? > > Thanks, > Gary > 1> Int = 2 bsl 160. 2923003274661805836407369665432566039311865085952 2> Bin = <>. <<2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>> 3> 3> 3> 3> <> = Bin. <<2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>> 4> SameInt. 2923003274661805836407369665432566039311865085952 From heinrich@REDACTED Thu May 17 12:13:48 2007 From: heinrich@REDACTED (Heinrich Venter) Date: Thu, 17 May 2007 12:13:48 +0200 Subject: [erlang-questions] Windows service. In-Reply-To: <855e4dcf0705170127t11df5f65k41fc6255eb8fc870@mail.gmail.com> References: <855e4dcf0705170127t11df5f65k41fc6255eb8fc870@mail.gmail.com> Message-ID: <001401c7986c$11d74900$3585db00$@com> The Erlang Windows build comes with a tool called erlsrv that I have successfully used to run Erlang as a windows service. The Erlang documentation has everything you need to know about it. Hope this helps -]-[ -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Tim Uckun Sent: Thursday, May 17, 2007 10:27 AM To: erlang-questions@REDACTED Subject: [erlang-questions] Windows service. I noticed that ejabberd runs as a windows service, a quick google search did not point to a library, does anybody know of one? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.1/805 - Release Date: 5/15/2007 10:47 AM From martin@REDACTED Thu May 17 13:18:24 2007 From: martin@REDACTED (Martin Carlson) Date: Thu, 17 May 2007 12:18:24 +0100 (BST) Subject: [erlang-questions] TCP Kernel bug/feature Message-ID: <10252.81.149.81.161.1179400704.squirrel@webmail.erlang-consulting.com> Hi all, Came across a strange Linux kernel bug/feature this morning while testing a TCP application we've written. The following code captures the behavior. server(Ip, Port) -> {ok, Socket} = gen_tcp:listen(Port, [{ip, Ip}, {reuseaddr, true}, {packet, 4}, binary]), {ok, Client} = gen_tcp:accept(Socket), gen_tcp:close(Socket), Client. client(Ip, Port) -> case gen_tcp:connect(Ip, Port, [{packet, 4}, binary]) of {ok, Client} -> Client; {error, econnrefused} -> client(Ip, Port); {error, Reason} -> erlang:error(Reason) end. node1() -> server({127,0,0,1}, 12345), halt(). node2() -> client("127.0.0.1", 12345), io:format("Connection lost~n"), client("127.0.0.1", 12345). When running node1() on one Erlang node and node2 on another this creates a socket connected to itself. One can capture the socket and pass data forth and back. netstat gives the following result: tcp 0 0 127.0.0.1:12345 127.0.0.1:12345 ESTABLISHED This however only seem to work on Suse 9.3 with a stock kernel and has probably been fixed in newer versions of the kernel. uname say: 2.6.11.4-20a-smp #1 SMP Wed Mar 23 21:52:37 UTC 2005 i686 i686 i386 GNU/Linux -- Martin Carlson Erlang Training & Consulting http://www.erlang-consulting.com From javierparis@REDACTED Thu May 17 14:06:24 2007 From: javierparis@REDACTED (Javier =?iso-8859-1?q?Par=EDs?=) Date: Thu, 17 May 2007 14:06:24 +0200 Subject: [erlang-questions] TCP Kernel bug/feature In-Reply-To: <10252.81.149.81.161.1179400704.squirrel@webmail.erlang-consulting.com> References: <10252.81.149.81.161.1179400704.squirrel@webmail.erlang-consulting.com> Message-ID: <200705171406.24567.javierparis@udc.es> El Thursday 17 May 2007 13:18:24 Martin Carlson escribi?: Hi, > When running node1() on one Erlang node and node2 on another > this creates a socket connected to itself. One can capture the socket and > pass data forth and back. > > netstat gives the following result: > tcp 0 0 127.0.0.1:12345 127.0.0.1:12345 > ESTABLISHED > > This however only seem to work on Suse 9.3 with a stock kernel and has > probably been fixed in newer versions of the kernel. Well, as far as I know, this is not against the RFC, so there isn't any reason why it shouldn't work. It's curious, tough :) Regards. -- Javier Par?s From dot@REDACTED Thu May 17 17:02:04 2007 From: dot@REDACTED (Tony Finch) Date: Thu, 17 May 2007 16:02:04 +0100 Subject: [erlang-questions] TCP Kernel bug/feature In-Reply-To: <200705171406.24567.javierparis@udc.es> References: <10252.81.149.81.161.1179400704.squirrel@webmail.erlang-consulting.com> <200705171406.24567.javierparis@udc.es> Message-ID: On Thu, 17 May 2007, Javier Par?s wrote: > El Thursday 17 May 2007 13:18:24 Martin Carlson escribi?: > > > When running node1() on one Erlang node and node2 on another this > > creates a socket connected to itself. One can capture the socket and > > pass data forth and back. > > > > netstat gives the following result: > > tcp 0 0 127.0.0.1:12345 127.0.0.1:12345 > > ESTABLISHED > > > > This however only seem to work on Suse 9.3 with a stock kernel and has > > probably been fixed in newer versions of the kernel. > > Well, as far as I know, this is not against the RFC, so there isn't any > reason why it shouldn't work. It's curious, tough :) The problem is that the client connections should be using ephemeral port numbers - there's nothing in the code that asks for a connection from port 12345. Tony. -- f.a.n.finch http://dotat.at/ FAIR ISLE: EASTERLY 4 OR 5 VEERING SOUTHERLY 5 TO 7. SLIGHT OR MODERATE INCREASING MODERATE OR ROUGH. OCCASIONAL RAIN. MODERATE OR GOOD. From dmitriid@REDACTED Thu May 17 17:19:27 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Thu, 17 May 2007 18:19:27 +0300 Subject: [erlang-questions] Announcing eipp: erlang bindings for c++ In-Reply-To: <464BC34A.2010004@ertw.com> References: <464BC34A.2010004@ertw.com> Message-ID: <464C727F.9090900@gmail.com> Daniel Goertzen wrote: > I'm please to announce "eipp": erlang bindings for c++. My employer > allowed me to open source this library, so many thanks to > http://www.norscan.com . > > Hi! I've reposted your announcement to a russian site, http://rsdn.com I've been immediately asked the following: - How is it better than erl_interface? - There is no C++ in the example - Does cleans up terms automatically on free_term()? All this I resend to you as I've had just a tiny peek at the code and can't answer those questions for sure. Though my guess for eipp vs. erl_interface is that eipp is, at the very least, much less verbose. Go eipp :) From pjdtech2000@REDACTED Thu May 17 18:55:44 2007 From: pjdtech2000@REDACTED (pj) Date: Thu, 17 May 2007 16:55:44 +0000 (UTC) Subject: [erlang-questions] Announcing eipp: erlang bindings for c++ References: <464BC34A.2010004@ertw.com> <464C727F.9090900@gmail.com> Message-ID: Dmitrii 'Mamut' Dimandt gmail.com> writes: > > Daniel Goertzen wrote: > > I'm please to announce "eipp": erlang bindings for c++. My employer > > allowed me to open source this library, so many thanks to > > http://www.norscan.com . > > > > > Hi! > > I've reposted your announcement to a russian site, http://rsdn.com > > I've been immediately asked the following: > > - How is it better than erl_interface? > - There is no C++ in the example > - Does cleans up terms automatically on free_term()? > I am a bit confused. This looks like just C++ wrapper for handling erlang C data structures. I didnt see any networking code. This is not a erl_interface replacement is it? (not yet anyways). From als@REDACTED Thu May 17 19:04:06 2007 From: als@REDACTED (Anthony Shipman) Date: Fri, 18 May 2007 03:04:06 +1000 Subject: [erlang-questions] escript questions Message-ID: <200705180304.06885.als@iinet.net.au> How do I write to stderr from a script? The io functions take a standard_io atom but there does not seem to be a standard_err. I tried doing file:open("/dev/fd/2", [write]) but erlang appears to refuse to write to device files. I get warning messages from unused functions in my script which I would like to suppress. I tried adding some dummy code: unused(), ... unused() -> [fun error/1, fun warning/1, fun message/2]. But I just get the error: escript: script failed with error reason undef when I do that. Is this an escript bug? -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From jeffm@REDACTED Fri May 18 02:56:26 2007 From: jeffm@REDACTED (jm) Date: Fri, 18 May 2007 10:56:26 +1000 Subject: [erlang-questions] erlyweb install problems with yaws_headers.hrl In-Reply-To: References: <464BC235.6080306@ghostgun.com> Message-ID: <464CF9BA.9030303@ghostgun.com> Caoyuan wrote: > Edit Emakefile which is under the root folder of erlyweb. There is a > line including: > {i,"/usr/local/src/yaws/include"} > change it to your yaws/include path. > Ah, I was looking for an environment variable. That gets me a little closer. I now get Recompile: src/erlyweb/erlyweb_util src/erlyweb/erlyweb_util.erl:87: function iolist_to_binary/1 undefined src/erlyweb/erlyweb_util.erl:97: function iolist_to_binary/1 undefined src/erlyweb/erlyweb_util.erl:121: function iolist_to_binary/1 undefined src/erlyweb/erlyweb_util.erl:139: function iolist_to_binary/1 undefined src/erlyweb/erlyweb_util.erl:156: function iolist_to_binary/1 undefined {"init terminating in do_boot",{undef,[{erltl,compile,["src/erlyweb/erlyweb_view.et",[{outdir,"ebin"},debug_info,show_errors,show_warnings]]},{filelib,fold_files2,6},{filelib,fold_files2,6},{erl_eval,do_apply,5},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () make: *** [all] Error 1 Appears as if iolist_to_binary/1 should be in kernel/erlang.erl. I tried the example from the doco on getapi.com and it fails it. Appears I have kernel-2.10.9 and to doco refers to 2.11.4. mmm, time for an upgrade. The recompile of R11B-4 took a long time but it seems to have fixed the problem. Thanks. Jeff. From goertzen@REDACTED Fri May 18 04:25:44 2007 From: goertzen@REDACTED (Daniel Goertzen) Date: Thu, 17 May 2007 21:25:44 -0500 Subject: [erlang-questions] Announcing eipp: erlang bindings for c++ In-Reply-To: <464C727F.9090900@gmail.com> References: <464BC34A.2010004@ertw.com> <464C727F.9090900@gmail.com> Message-ID: <464D0EA8.3020609@ertw.com> Hi Dmitrii. I'm not especially familiar with erl_interface, so I'll just talk a bit about eipp so you get a feel for it. The main class in eipp is "et" (erlang term). It is essentially a variant type inspired by the "any" class from the boost library (earlier revs were actually directly derived from boost::any). Any type that can be transported by erlang etf can be represented by an et. Example: et a,b,c; a=123; b=3.14; c="i_am_an_atom"; eipp also provides runtime automatic casts for getting things out of et: int x; double y; int z; x=a; y=b; z=c; // throws bad_match exception, can't convert atom_t to int eipp also has named constructors and destructurers for lists and tuples (inspired by boost::tuple). et a,b,x,y,z; a=tuple(123,3.14,"an_atom"); b=list(1,2,3,"another_atom"); untuple(x,y,z)=a; et supports the insert operator: et a=tuple("example",3); cout << a << endl; output: {example, 3} eipp has a binary type, the primary use of which is for storing serialized et instances. The binary type is really a pointer to std::vector, so you would need to drill into that type to get at the raw data (ie, for transmitting through a socket for example). sendN() functions are provided to send binaries to an iostream in a format compatible with erlang port packet format. et a=tuple("example",4) et x=term_to_binary(a) send4(cout,x); Similarly, receiveN() functions are provided for receiving terms. Internally, et instances decoded from a binary are different from natively constructed et instances. Decoding is done "lazily", meaning that the binary is kept around and the term is decoded just-in-time (tuples and lists must be eagerly converted however, but not their contents). The advantage to this is that unneeded terms don't have to be decoded, and terms that are often not needed by a c++ program (funs, pids) can be sent back to a real erlang node without ever being decoded. All memory is automatically cleaned up (hooray for boost::shared_ptr !), even for a bunch of decoded terms that may refer to the same binary. eipp uses the encode & decode functions from ei, although I'd like to work on producing native c++ transcoders. eipp does not do the erlang distribution protocol, although that's something I'd like to add eventually. Cheers, Dan. Dmitrii 'Mamut' Dimandt wrote: > Daniel Goertzen wrote: > >> I'm please to announce "eipp": erlang bindings for c++. My employer >> allowed me to open source this library, so many thanks to >> http://www.norscan.com . >> >> >> > Hi! > > I've reposted your announcement to a russian site, http://rsdn.com > > I've been immediately asked the following: > > - How is it better than erl_interface? > - There is no C++ in the example > - Does cleans up terms automatically on free_term()? > > All this I resend to you as I've had just a tiny peek at the code and > can't answer those questions for sure. > > Though my guess for eipp vs. erl_interface is that eipp is, at the very > least, much less verbose. > > > Go eipp :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From goertzen@REDACTED Fri May 18 04:28:01 2007 From: goertzen@REDACTED (Daniel Goertzen) Date: Thu, 17 May 2007 21:28:01 -0500 Subject: [erlang-questions] Announcing eipp: erlang bindings for c++ In-Reply-To: References: <464BC34A.2010004@ertw.com> <464C727F.9090900@gmail.com> Message-ID: <464D0F31.5020005@ertw.com> No, eipp does not do any networking (yet). It is useful for port programs and programs where you manage all the networking (that's how I use it now). Cheers, Dan. pj wrote: > Dmitrii 'Mamut' Dimandt gmail.com> writes: > > >> Daniel Goertzen wrote: >> >>> I'm please to announce "eipp": erlang bindings for c++. My employer >>> allowed me to open source this library, so many thanks to >>> http://www.norscan.com . >>> >>> >>> >> Hi! >> >> I've reposted your announcement to a russian site, http://rsdn.com >> >> I've been immediately asked the following: >> >> - How is it better than erl_interface? >> - There is no C++ in the example >> - Does cleans up terms automatically on free_term()? >> >> > > I am a bit confused. > This looks like just C++ wrapper for handling erlang C data structures. > I didnt see any networking code. > This is not a erl_interface replacement is it? (not yet anyways). > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From horndude77@REDACTED Fri May 18 04:30:13 2007 From: horndude77@REDACTED (Jay Anderson) Date: Fri, 18 May 2007 02:30:13 +0000 (UTC) Subject: [erlang-questions] Erlang math libraries References: <17993.22096.76503.895100@antilipe.corelatus.se> <464A7FFB.8000408@ghostgun.com> Message-ID: I decided it would be a good exercise for me to put together matrix and vector modules. I have a question about tail recursion in erlang. I was making the transpose function. This was my first impulse: t(M) -> t(M, []). t([[]|_], NewM) -> lists:reverse(NewM); t(M, NewM) -> t([T || [_|T] <- M], [ [H || [H|_] <- M] |NewM]). I don't particularly like the reverse at the end, but I'd rather do that and keep it tail recursive. Then I was looking at lists.erl in stdlib and this is the implementation of lists:map: map(F, [H|T]) -> [F(H)|map(F, T)]; map(F, []) when is_function(F, 1) -> []. This seems like it wouldn't be tail recursive. So does the erlang compiler optimize this somehow? Would the following be preferable for transpose? t([[]|_]) -> []; t(M) -> [ [H || [H|_] <- M] | t([T || [_|T] <- M]) ]. -----Jay From tom@REDACTED Fri May 18 04:39:56 2007 From: tom@REDACTED (Tom Samplonius) Date: Thu, 17 May 2007 19:39:56 -0700 (PDT) Subject: [erlang-questions] TCP Kernel bug/feature In-Reply-To: <10252.81.149.81.161.1179400704.squirrel@webmail.erlang-consulting.com> Message-ID: <5409945.2041179455996779.JavaMail.root@ly.sdf.com> ----- "Martin Carlson" wrote: > Hi all, > > Came across a strange Linux kernel bug/feature this morning while > testing > a TCP application we've written. > > The following code captures the behavior. > > server(Ip, Port) -> > {ok, Socket} = gen_tcp:listen(Port, [{ip, Ip}, {reuseaddr, true}, > {packet, 4}, binary]), > {ok, Client} = gen_tcp:accept(Socket), > gen_tcp:close(Socket), > Client. > > > client(Ip, Port) -> > case gen_tcp:connect(Ip, Port, [{packet, 4}, binary]) of > {ok, Client} -> > Client; > {error, econnrefused} -> > client(Ip, Port); > {error, Reason} -> > erlang:error(Reason) > end. > > > node1() -> > server({127,0,0,1}, 12345), > halt(). > > > node2() -> > client("127.0.0.1", 12345), > io:format("Connection lost~n"), > client("127.0.0.1", 12345). > > When running node1() on one Erlang node and node2 on another > this creates a socket connected to itself. One can capture the socket > and > pass data forth and back. > > netstat gives the following result: > tcp 0 0 127.0.0.1:12345 127.0.0.1:12345 > ESTABLISHED > > This however only seem to work on Suse 9.3 with a stock kernel and > has > probably been fixed in newer versions of the kernel. > > uname say: > 2.6.11.4-20a-smp #1 SMP Wed Mar 23 21:52:37 UTC 2005 i686 i686 i386 > GNU/Linux I think this is way it is supposed to work. A socket is a unique pair of source and destination ports. You run a server on 12345, and then connect from 12345 to 12345. So that is a legal socket. This should work this way on most OSes. Normally when you establish a client connection, you don't special the port to establish the socket from. You let the OS use the next available number from some magical pool of ports. You should have a really good reason to establish a connection from a specific port. > > -- > Martin Carlson > Erlang Training & Consulting > http://www.erlang-consulting.com > Tom From ok@REDACTED Fri May 18 06:44:22 2007 From: ok@REDACTED (ok) Date: Fri, 18 May 2007 16:44:22 +1200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> <464A7FFB.8000408@ghostgun.com> Message-ID: On 18 May 2007, at 2:30 pm, Jay Anderson wrote:ing at lists.erl in stdlib and this is > the implementation of lists:map: > > map(F, [H|T]) -> > [F(H)|map(F, T)]; > map(F, []) when is_function(F, 1) -> []. > > This seems like it wouldn't be tail recursive. So does the erlang > compiler optimize this somehow? There is no fundamental reason why it couldn't: map(P, [], []). map(P, [X|Xs], [Y|Ys]) :- call(P, X, Y), map(P, Xs, Ys). is the Prolog equivalent, and it *is* tail recursive. It would have to be implemented something like this: map/2 (arguments *R, A1, A2): if A2 is a pair then H := head(A2) X := A1(H) L := [X|_] *R := L A2 := := tail(A2) R := &tail(L) goto map/2 else if A2 is nil then *R := nil return else call no_match_trap The issue here is the assignment *R := L, which changes a location in the heap. It's actually an initialisation, not a "real" assignment, but the garbage collector has to expect this kind of thing, which the garbage collector(s) developed for Erlang don't. So it's not just a matter of changing the compiler. > > Would the following be preferable for transpose? > > t([[]|_]) -> []; > t(M) -> [ [H || [H|_] <- M] | t([T || [_|T] <- M]) ]. Measure the alternatives and find out. There is NO substitute for measurement. From dcaoyuan@REDACTED Fri May 18 09:48:05 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Fri, 18 May 2007 15:48:05 +0800 Subject: [erlang-questions] ErlyBird 0.11.2 released - An Erlang IDE based on NetBeans Message-ID: I'm please to announce the release of ErlyBird 0.11.2, an Erlang IDE based on NetBeans. This is a bug-fix, stabilization release. Since I tightly modified GSF/GLF modules of NetBeans, this release will only provide all-in-one IDE package, which is in size of 14.8M. To download, please go to: http://sourceforge.net/project/showfiles.php?group_id=192439 To install: 1. Unzip erlybird-bin-0.11.2.zip to somewhere, for Windows user, execute 'bin/erlybird.exe' for *nix user, 'bin/erlybird'. 2. Check/set your OTP path. From [Tools]->[Options], click on 'Miscellanous', then expand 'Erlang Installation', fill in the full path of your 'erl.exe' or 'erl' file. For instance: "C:/erl/bin/erl.exe" 3. The default -Xmx option for jvm is set to 256M, if you want to increase, open the config file of ErlyBird that is located at etc/erlybird.conf, set -J-Xmx in line of 'default_options' The status of ErlyBird is still Alpha, feedback and bug reports are welcome. CHANGELOG: - Indexing will skip too big files according to the max memeory. This avoids ErlyBird to hang when indexing. - If erl/erl.exe is under the environment path, ErlyBird will try to set Erlang Installation path automatically. - Including function args in completion suggestion. - Various bugs fixes especially for stabilization. For more information, please visit my blogs: http://www.blogtrader.net/page/dcaoyuan From dot@REDACTED Fri May 18 10:39:12 2007 From: dot@REDACTED (Tony Finch) Date: Fri, 18 May 2007 09:39:12 +0100 Subject: [erlang-questions] TCP Kernel bug/feature In-Reply-To: <5409945.2041179455996779.JavaMail.root@ly.sdf.com> References: <5409945.2041179455996779.JavaMail.root@ly.sdf.com> Message-ID: On Thu, 17 May 2007, Tom Samplonius wrote: > > I think this is way it is supposed to work. A socket is a unique pair > of source and destination ports. You run a server on 12345, and then > connect from 12345 to 12345. So that is a legal socket. This should > work this way on most OSes. No, he is connecting from an ephemeral port not from 12345. Tony. -- f.a.n.finch http://dotat.at/ VIKING NORTH UTSIRE SOUTH UTSIRE: SOUTHERLY 5 TO 7, OCCASIONALLY GALE 8. MODERATE OR ROUGH, OCCASIONALLY VERY ROUGH. RAIN OR SHOWERS. MODERATE OR GOOD. From nicoleneh@REDACTED Fri May 18 13:24:46 2007 From: nicoleneh@REDACTED (Nicolene Heunis) Date: Fri, 18 May 2007 13:24:46 +0200 Subject: [erlang-questions] ODBC problem Message-ID: Hi all, I am having a lot of trouble with the odbc module. I have installed unixODBC 2.2.12 and the easysoft mssql driver(odbc-sqlserver-1.0.0-linux-x86-64). Here are my results: Eshell V5.5.4 (abort with ^G) 1> application:start(odbc). ok 2> {ok,Ref} = odbc:connect("DSN=XXX;UID=XXX;PWD=XXX",[{trace_driver,on}]). {ok,<0.38.0>} 3> odbc:sql_query(Ref, "select getdate();"). *** glibc detected *** free(): invalid next size (fast): 0x0000000000525bc0 *** {error,connection_closed} =ERROR REPORT==== 18-May-2007::13:19:02 === ** Generic server <0.38.0> terminating ** Last message in was {#Port<0.101>,{exit_status,134}} ** When Server state == {state,#Port<0.101>, {<0.30.0>,#Ref<0.0.0.77>}, <0.30.0>, undefined, on, true, true, on, connected, undefined, 0, [#Port<0.99>,#Port<0.100>], #Port<0.102>, #Port<0.103>} ** Reason for termination == ** {port_exit,killed} I have tested unixODBC and the easysoft driver and they are both working. Does anyone know what the problem might be? I did not get these errors when using freeTDS but I am looking for an alternative driver. Is there known issues with the easysoft driver? Thanks Nicolene -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Fri May 18 15:39:48 2007 From: james.hague@REDACTED (James Hague) Date: Fri, 18 May 2007 08:39:48 -0500 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <17993.22096.76503.895100@antilipe.corelatus.se> <464A7FFB.8000408@ghostgun.com> Message-ID: >This seems like it wouldn't be tail recursive. So does the erlang compiler >optimize this somehow? Google for "tail recursion modulo cons." No, the current Erlang compiler doesn't handle it. I brought this up back 2002: http://erlang.org/ml-archive/erlang-questions/200211/msg00158.html (The short version is that it requires changes to the garbage collector in order to work.) James -------------- next part -------------- An HTML attachment was scrubbed... URL: From juneaftn@REDACTED Fri May 18 16:12:27 2007 From: juneaftn@REDACTED (June Kim) Date: Fri, 18 May 2007 23:12:27 +0900 Subject: [erlang-questions] Displaying the line number when error occured Message-ID: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> Suppose foo.erl is: -module(foo). -export([bar/1]). bar(X)-> 1+2+3, 5=X. ============== 8> foo:bar(5). =ERROR REPORT==== 18-May-2007::23:08:44 === Error in process <0.61.0> with exit value: {{badmatch,5},[{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {{badmatch,5}, [{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** The report isn't very helpful. Is there any way I can see the line number of the source code that the error occured? From dmitriid@REDACTED Fri May 18 16:34:19 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Fri, 18 May 2007 17:34:19 +0300 Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> References: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> Message-ID: <464DB96B.9030906@gmail.com> June Kim wrote: > Suppose foo.erl is: > > -module(foo). > -export([bar/1]). > > bar(X)-> > 1+2+3, > 5=X. > > ============== > > 8> foo:bar(5). > > =ERROR REPORT==== 18-May-2007::23:08:44 === > Error in process <0.61.0> with exit value: > {{badmatch,5},[{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {{badmatch,5}, > [{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** > > The report isn't very helpful. Is there any way I can see the line > number of the source code that the error occured? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > A while back somone posted this patch for shell.erl: Index: shell.erl =================================================================== RCS file: /hipe/otp/lib/stdlib/src/shell.erl,v retrieving revision 1.8 diff -u -r1.8 shell.erl --- shell.erl 24 Jan 2006 11:46:11 -0000 1.8 +++ shell.erl 11 Apr 2006 20:52:30 -0000 @@ -248,10 +248,77 @@ {'EXIT', Pid, Res} -> {Res, Eval}; {'EXIT', Eval, Reason} -> - io:fwrite("** exited: ~P **\n", [Reason, ?LINEMAX]), + report_exit(Reason), get_command1(Pid, start_eval(Bs, RT, Ds), Bs, RT, Ds) end. +report_exit(Reason) -> + {Term,Trace} = analyze_exit(Reason), + io:fwrite("** exited: ~P **\n~s", [Term, ?LINEMAX, Trace]). + +analyze_exit({Term, Stack}=Reason) when is_list(Stack) -> + case is_stacktrace(Stack) of + true -> + {Term, format_stacktrace(Stack)}; + false -> + {Reason, ""} + end; +analyze_exit(Reason) -> + {Reason, ""}. + +is_stacktrace([]) -> + true; +is_stacktrace([{M,F,A}|Fs]) when is_atom(M), is_atom(F), is_integer(A) -> + is_stacktrace(Fs); +is_stacktrace([{M,F,As}|Fs]) when is_atom(M), is_atom(F), is_list(As) -> + is_stacktrace(Fs); +is_stacktrace(_) -> + false. + +format_stacktrace(Stack) -> + format_stacktrace(Stack,"in function","in call from"). + +format_stacktrace([{M,F,A}|Fs],Pre,Pre1) when is_integer(A) -> + [io_lib:fwrite(" ~s ~w:~w/~w\n", [Pre,M,F,A]) + | format_stacktrace(Fs,Pre1,Pre1)]; +format_stacktrace([{M,F,As}|Fs],Pre,Pre1) when is_list(As) -> + A = length(As), + C = case is_op(M,F,A) of + true when A == 1 -> + [A1] = As, + io_lib:fwrite("~s ~s", [F,format_arg(A1)]); + true when A == 2 -> + [A1, A2] = As, + io_lib:fwrite("~s ~s ~s", + [format_arg(A1),F,format_arg(A2)]); + false -> + io_lib:fwrite("~w(~s)", [F,format_arglist(As)]) + end, + [io_lib:fwrite(" ~s ~w:~w/~w\n called as ~s\n", + [Pre,M,F,A,C]) + | format_stacktrace(Fs,Pre1,Pre1)]; +format_stacktrace([],_Pre,_Pre1) -> + "". + +format_arg(A) -> + io_lib:fwrite("~P",[A,?LINEMAX]). + +format_arglist([A]) -> + format_arg(A); +format_arglist([A|As]) -> + [io_lib:fwrite("~P,",[A,?LINEMAX]) | format_arglist(As)]; +format_arglist([]) -> + "". + +is_op(erlang, F, A) -> + erl_internal:arith_op(F, A) + orelse erl_internal:bool_op(F, A) + orelse erl_internal:comp_op(F, A) + orelse erl_internal:list_op(F, A) + orelse erl_internal:send_op(F, A); +is_op(_M, _F, _A) -> + false. + prompt(N) -> case is_alive() of true -> {format,"(~s)~w> ",[node(),N]}; @@ -407,7 +474,7 @@ Ev ! {shell_rep,self(),ok}, shell_rep(Ev, Bs0, RT, Ds); {'EXIT',Ev,Reason} -> % It has exited unnaturally - io:fwrite("** exited: ~P **\n", [Reason,?LINEMAX]), + report_exit(Reason), {{'EXIT',Reason},start_eval(Bs0, RT, Ds0), Bs0, Ds0}; {'EXIT',_Id,interrupt} -> % Someone interrupted us exit(Ev, kill), I don't think it prints line numers, but it's supposed to be more readable -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrickerj@REDACTED Fri May 18 19:11:32 2007 From: patrickerj@REDACTED (Patrick) Date: Fri, 18 May 2007 19:11:32 +0200 Subject: [erlang-questions] SHA-256 + salting Message-ID: How do i apply sha-256 and salting on passwords? There is unfortunately no information on this anywhere.. BR, Patrick From tty.erlang@REDACTED Fri May 18 19:54:30 2007 From: tty.erlang@REDACTED (t ty) Date: Fri, 18 May 2007 13:54:30 -0400 Subject: [erlang-questions] SHA-256 + salting In-Reply-To: References: Message-ID: <290b3ba10705181054k4d0974c9j7bfd11f05c05afbc@mail.gmail.com> I'm assuming you're applying the salt after the data. Init a context, update it with your data, then update with the salt, and finalize. crypto:start(), C1 = crypto:sha_init(), C2 = crypto:sha_update(C1, Data), C3 = crypto:sha_update(C2, Salt), Digest = crypto:sha_final(C4). To tag the salt on just append it to the digest (after convertion to a list). Regards t On 5/18/07, Patrick wrote: > How do i apply sha-256 and salting on passwords? There is > unfortunately no information on this anywhere.. > > BR, > Patrick > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jay@REDACTED Sat May 19 03:47:15 2007 From: jay@REDACTED (Jay Nelson) Date: Fri, 18 May 2007 18:47:15 -0700 Subject: [erlang-questions] Erlang math libraries Message-ID: <464E5723.8070403@duomark.com> > Any thoughts on how to represent a matrix with erlang? (dense or > sparse) Would a list of lists be good enough or would there be a better way? I would consider trying a tuple of binaries and using the whizzy new bit binary primitives. Compactness and speed may be noticeable if you are using dense matrices. jay From enrique.marcote@REDACTED Sat May 19 13:42:43 2007 From: enrique.marcote@REDACTED (Enrique Marcote) Date: Sat, 19 May 2007 13:42:43 +0200 Subject: [erlang-questions] erlang nodes over a wifi network Message-ID: <868840700705190442t615181c9jf2c5626992732f7f@mail.gmail.com> Hi all, I'm doing some tests connecting several erlang nodes over a wifi network. The same application works perfectly over ethernet but when I go wireless, approximately every 5 minutes I get a noconnection error in some of the nodes (nodes reconnect by themselves after a period of time that goes from 5 secs to 1min). I'm setting the following kernel parameters in the sys.config: [{kernel, [{sync_nodes_mandatory, []}, {sync_nodes_optional, ['sun@REDACTED']}, {sync_nodes_timeout, 5000}]}, Nodes communicate with each other issuing rpc calls. Are there any recommendations you could point out in order to connect several erlang nodes over a medium quality wifi network? (quality is in average 50%). The network quality is not perfect but seems good enough for other applications (ssh, http...). Any help would be greatly appreciated. Thanks in advance. Quique From saifi@REDACTED Sat May 19 16:27:49 2007 From: saifi@REDACTED (Saifi Khan) Date: Sat, 19 May 2007 19:57:49 +0530 (IST) Subject: [erlang-questions] module_info Message-ID: Hi: Started working through the 'Getting started with Erlang' examples. There are two module_info functions that seem to be defined for every module. module_info/0 module_info/1 What is the purpose of module_info function ? On invocation the following info is shown for example 2> tut:module_info(). [{exports,[{double,1},{module_info,0},{module_info,1}]}, {imports,[]}, {attributes,[{vsn,[273405249567272843094678604656701543356]}]}, {compile,[{options,[]}, {version,"4.4.4"}, {time,{2007,5,19,14,5,5}}, {source,"/data/code/tut.erl"}]}] What is the interpretation of the vsn entry in the attributes field ? There is a very large number there. What is its purpose ? Appreciate if the experienced erlangers share their thoughts. thanks Saifi. TWINCLING Society http://www.twincling.org/ From enrique.marcote@REDACTED Sat May 19 16:31:45 2007 From: enrique.marcote@REDACTED (Enrique Marcote) Date: Sat, 19 May 2007 16:31:45 +0200 Subject: [erlang-questions] erlang nodes over a wifi network In-Reply-To: <868840700705190442t615181c9jf2c5626992732f7f@mail.gmail.com> References: <868840700705190442t615181c9jf2c5626992732f7f@mail.gmail.com> Message-ID: <868840700705190731k551d977av7589285bf3436383@mail.gmail.com> Hi all, I'm trying to connect several erlang nodes over a wifi network. The same application works perfectly over ethernet but when I go wireless, approximately every 5 minutes I get a noconnection error in some of the nodes (nodes reconnect by themselves after a period of time that goes from 5 secs to 1min). I'm setting the following kernel parameters in the sys.config: [{kernel, [{sync_nodes_mandatory, []}, {sync_nodes_optional, ['sun@REDACTED']}, {sync_nodes_timeout, 5000}]}, Nodes communicate with each other issuing rpc calls. Are there any recommendations you could point out in order to connect several erlang nodes over a medium quality wifi network? (quality is in average 50%). The network quality is not perfect but seems good enough for other applications (ssh, http...). Any help would be greatly appreciated. Thanks in advance. Quique ---------- Forwarded message ---------- From: Enrique Marcote Date: Sat, 19 May 2007 13:42:43 +0200 Subject: erlang nodes over a wifi network To: erlang-questions@REDACTED Hi all, I'm doing some tests connecting several erlang nodes over a wifi network. The same application works perfectly over ethernet but when I go wireless, approximately every 5 minutes I get a noconnection error in some of the nodes (nodes reconnect by themselves after a period of time that goes from 5 secs to 1min). I'm setting the following kernel parameters in the sys.config: [{kernel, [{sync_nodes_mandatory, []}, {sync_nodes_optional, ['sun@REDACTED']}, {sync_nodes_timeout, 5000}]}, Nodes communicate with each other issuing rpc calls. Are there any recommendations you could point out in order to connect several erlang nodes over a medium quality wifi network? (quality is in average 50%). The network quality is not perfect but seems good enough for other applications (ssh, http...). Any help would be greatly appreciated. Thanks in advance. Quique From mpquique@REDACTED Sat May 19 16:49:30 2007 From: mpquique@REDACTED (Enrique Marcote) Date: Sat, 19 May 2007 16:49:30 +0200 Subject: [erlang-questions] erlang nodes over a wifi (50% quality) network Message-ID: <868840700705190749x299c9058ha07175fe2f1540c1@mail.gmail.com> Hi all, I'm trying to connect several erlang nodes over a wifi network. The same application works perfectly over Ethernet but when I go wireless, approximately every 5 minutes I get a noconnection error in some of the nodes (nodes reconnect by themselves after a period of time that goes from 5 secs to 1min). I'm setting the following kernel parameters in the sys.config: [{kernel, [{sync_nodes_mandatory, []}, {sync_nodes_optional, ['sun@REDACTED']}, {sync_nodes_timeout, 5000}]}, Some applications register globally. Nodes communicate with each other issuing rpc calls. Are there any recommendations you could point out in order to connect several erlang nodes over a medium quality wifi network? (quality is in average 50%). The network quality is not perfect but seems good enough for other applications (ssh, http...). Any help would be greatly appreciated. Thanks in advance. Quique From ulf@REDACTED Sat May 19 17:09:28 2007 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 19 May 2007 17:09:28 +0200 Subject: [erlang-questions] erlang nodes over a wifi network In-Reply-To: <868840700705190731k551d977av7589285bf3436383@mail.gmail.com> References: <868840700705190442t615181c9jf2c5626992732f7f@mail.gmail.com> <868840700705190731k551d977av7589285bf3436383@mail.gmail.com> Message-ID: <8209f740705190809k139505a6iae6d20d496f48b@mail.gmail.com> The sync_nodes_timeout setting is only relevant to the distributed application controller, and tells it how long to wait for the other node to appear before proceeding as if they were dead. The parameter that ought to be of interest in this case is -kernel net_ticktime It is by default set to 60 seconds, which means that the nodes will send a tick if they haven't sent anything else to the other node in 60/4 seconds. If nothing has been received from the other node after 4 tick intervals, the connection is considered dead. Since the other node is expected to sent ticks at the same interval (that is, net_ticktime must be the same on both sides), something should always be received. The heartbeat code is brilliant. It's very concise and obviously flawless, but I'm convinced that it has a hole in it. (: It's just that we've experienced nodedowns during extreme situations where our other - less elegant - heartbeat algorithms have been able to recover. One situation that was weird enough to remember was when we had reason to learn about the tcp rexmit settings. We found that with an aggressive net_ticktime (10 seconds, which really shouldn't be considered that aggressive), we had to set tcp.rexmit_max so that the TCP retransmission logic didn't wait to long before resending a packet. Not only that, we had to set the rexmit_init value (this was Solaris 8, and I don't recall the exact syntax) to be low - otherwise the _first_ retransmission wait would trigger the nodedown. You would perhaps run Wireshark to try to find out what's actually going on when the nodedown happens. Again, I have a feeling that the erlang tick algorithm is sometimes a bit easily offended, but we've not been able to pin down the exact circumstances, nor find an actual flaw in the algorithm. BR, Ulf W 2007/5/19, Enrique Marcote : > > Hi all, > > I'm trying to connect several erlang nodes over a wifi network. The > same application works perfectly over ethernet but when I go > wireless, approximately every 5 minutes I get a noconnection error in > some of the nodes (nodes reconnect by themselves after a period of > time that goes from 5 secs to 1min). > > I'm setting the following kernel parameters in the sys.config: > > [{kernel, [{sync_nodes_mandatory, []}, {sync_nodes_optional, > ['sun@REDACTED']}, {sync_nodes_timeout, 5000}]}, > > Nodes communicate with each other issuing rpc calls. > > Are there any recommendations you could point out in order to connect > several erlang nodes over a medium quality wifi network? (quality is > in average 50%). The network quality is not perfect but seems good > enough for other applications (ssh, http...). > > Any help would be greatly appreciated. Thanks in advance. > > Quique > > ---------- Forwarded message ---------- > From: Enrique Marcote > Date: Sat, 19 May 2007 13:42:43 +0200 > Subject: erlang nodes over a wifi network > To: erlang-questions@REDACTED > > Hi all, > > I'm doing some tests connecting several erlang nodes over a wifi > network. The same application works perfectly over ethernet but when > I go wireless, approximately every 5 minutes I get a noconnection > error in some of the nodes (nodes reconnect by themselves after a > period of time that goes from 5 secs to 1min). > > I'm setting the following kernel parameters in the sys.config: > > [{kernel, [{sync_nodes_mandatory, []}, > {sync_nodes_optional, ['sun@REDACTED']}, > {sync_nodes_timeout, 5000}]}, > > Nodes communicate with each other issuing rpc calls. > > Are there any recommendations you could point out in order to connect > several erlang nodes over a medium quality wifi network? (quality is > in average 50%). The network quality is not perfect but seems good > enough for other applications (ssh, http...). > > Any help would be greatly appreciated. Thanks in advance. > > Quique > _______________________________________________ > 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 Sat May 19 17:11:08 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Sat, 19 May 2007 17:11:08 +0200 Subject: [erlang-questions] module_info In-Reply-To: References: Message-ID: <464F138C.7050308@ericsson.com> On 2007-05-19 16:27, Saifi Khan wrote: > Hi: > > Started working through the 'Getting started with Erlang' examples. > > There are two module_info functions that seem to be defined > for every module. > module_info/0 > module_info/1 > > What is the purpose of module_info function ? they give you information about the module (from the compiler). > On invocation the following info is shown for example > 2> tut:module_info(). > [{exports,[{double,1},{module_info,0},{module_info,1}]}, > {imports,[]}, > {attributes,[{vsn,[273405249567272843094678604656701543356]}]}, ...deleted > > What is the interpretation of the vsn entry in the attributes field ? if you have an entry like this: -vsn('1.0.0'). in your module, this value will be available from module_info(). otherwise the compiler creates a value. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From toby@REDACTED Sat May 19 17:53:39 2007 From: toby@REDACTED (Toby Thain) Date: Sat, 19 May 2007 11:53:39 -0400 Subject: [erlang-questions] erlang nodes over a wifi (50% quality) network In-Reply-To: <868840700705190749x299c9058ha07175fe2f1540c1@mail.gmail.com> References: <868840700705190749x299c9058ha07175fe2f1540c1@mail.gmail.com> Message-ID: <88A36FA4-214E-41B6-BDC4-5E1645B42536@smartgames.ca> On 19-May-07, at 10:49 AM, Enrique Marcote wrote: > Hi all, > > I'm trying to connect several erlang nodes over a wifi network. ... > > Any help would be greatly appreciated. If you get desperate, you could try setting up a UDP OpenVPN; this can make an unreliable network appear reliable to applications. --Toby > Thanks in advance. > > Quique > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From gamehack@REDACTED Sat May 19 18:27:15 2007 From: gamehack@REDACTED (Milen Dzhumerov) Date: Sat, 19 May 2007 17:27:15 +0100 Subject: [erlang-questions] Bubble sort in Erlang Message-ID: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Hi all, I've recently picked up the "Programming Erlang" book and started experimenting with Erlang. So I wanted to implement some toy algorithms - would you believe me that I was kind of stuck for several days on the train while going to work implementing a simple bubble sort algorithm? I think FP really hit my head - that's the first time I've tried any functional programming. The hardest part for me was (and still is) maintaining and mutating the state (like whether a swap has occurred). So I thought because I have to use recursion instead of iteration, I could maintain the state using parameter passing. Here it goes, my first Erlang toy program: -module(bsort). -export([bubble_sort/1, bstage/1, bstage/2]). bubble_sort([A,B|Tail]) when Tail =/= [] -> {Status, List} = bstage([A,B|Tail]), case Status of sorted -> List; not_sorted -> bubble_sort(List) end; bubble_sort([A,B]) -> if A > B -> [B, A]; true -> [A, B] end; bubble_sort([A]) -> [A]; bubble_sort([]) -> []. bstage(L) -> {Swapped, List} = bstage(L, false), case Swapped of false -> {sorted, List}; true -> {not_sorted, List} end. bstage([A,B|Tail], Swapped) when Tail =/= [] -> if A > B -> {_, List1} = bstage([A|Tail], true), {true, [B] ++ List1}; true -> {Swap, List} = bstage([B|Tail], Swapped), {Swap, [A] ++ List} end; bstage([A,B], Swapped) -> if A > B -> {true, [B,A]}; true -> {Swapped, [A,B]} end. Any comments are greatly appreciated. Kind regards, Milen From andrew@REDACTED Sat May 19 19:52:59 2007 From: andrew@REDACTED (andrew cooke) Date: Sat, 19 May 2007 13:52:59 -0400 (CLT) Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Message-ID: <29994.200.120.169.16.1179597179.squirrel@acooke.dyndns.org> > Hi all, > > I've recently picked up the "Programming Erlang" book and started > experimenting with Erlang. So I wanted to implement some toy > algorithms - would you believe me that I was kind of stuck for > several days on the train while going to work implementing a simple > bubble sort algorithm? I think FP really hit my head - that's the > first time I've tried any functional programming. The hardest part > for me was (and still is) maintaining and mutating the state (like > whether a swap has occurred). So I thought because I have to use > recursion instead of iteration, I could maintain the state using > parameter passing. Here it goes, my first Erlang toy program: > > -module(bsort). > -export([bubble_sort/1, bstage/1, bstage/2]). > you can put the call to bstage in the case statement which save you introducing "Status" (although below i argue you shouldn't be doing this at all). > bubble_sort([A,B|Tail]) when Tail =/= [] -> > {Status, List} = bstage([A,B|Tail]), > case Status of > sorted -> List; > not_sorted -> bubble_sort(List) > end; if you put this before the definition above you won't need to check for an empty Tail since that case is handled here. You can also separate out the if into guard conditions, which I think looks nicer. > bubble_sort([A,B]) -> > if > A > B -> [B, A]; > true -> [A, B] > end; > bubble_sort([A]) -> [A]; > bubble_sort([]) -> []. in fact in general it's best to put the simplest definitions at the top - partly so that you don't have to worry so much about the more complex ones and also because when reading it's nice to know what the exit conditions are. here you seem to be using a flag to indicate that the system is still bubbling. i haven't tried to follow what you are doing in detail, but in general you shouldn't need to do this. instead, you should simply call yourself again if you need to. also, you have some appends in the code (++). generally that means you should be passing around an accumulator list instead. > bstage(L) -> > {Swapped, List} = bstage(L, false), > case Swapped of > false -> {sorted, List}; > true -> {not_sorted, List} > end. > > bstage([A,B|Tail], Swapped) when Tail =/= [] -> > if > A > B -> {_, List1} = bstage([A|Tail], true), > {true, [B] ++ List1}; > true -> {Swap, List} = bstage([B|Tail], Swapped), > {Swap, [A] ++ List} > end; if you put my two comments above together, you may find that the function below can, because it receives a list it is accumulating on, pass "the whole list" to bubble_sort directly, rather that returning "true" and leaving that task to the higher levels. remember that with tail recursion there's no problem repeatedly calling functions. > bstage([A,B], Swapped) -> > if > A > B -> {true, [B,A]}; > true -> {Swapped, [A,B]} > end. i don't know if this helps or if it's too vague/abstract. sorry i don't have more time to understand in detail, but i hope the comments above explain the kind of "gut reactions" that i would follow in trying to rewrite this cleanly (ie without the flag that indicates that the function needs to be called again). you're getting there and i think this is the right way to learn. keep going :o) andrew ps i feel a bit embarrassed giving advice - i am not the worlds greatest functional programmer. so if someone contradicts me they are probably right. > > Any comments are greatly appreciated. > > Kind regards, > Milen > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From andrew@REDACTED Sat May 19 20:27:57 2007 From: andrew@REDACTED (andrew cooke) Date: Sat, 19 May 2007 14:27:57 -0400 (CLT) Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Message-ID: <12421.200.120.169.16.1179599277.squirrel@acooke.dyndns.org> wasn't sure my previous post was clear. i don't know if you're prefer to work things out yourself, but below (after your email) i have written a sketch of what i would expect things to turn out like once you add an accumulator list. code is not tested. > Hi all, > > I've recently picked up the "Programming Erlang" book and started > experimenting with Erlang. So I wanted to implement some toy > algorithms - would you believe me that I was kind of stuck for > several days on the train while going to work implementing a simple > bubble sort algorithm? I think FP really hit my head - that's the > first time I've tried any functional programming. The hardest part > for me was (and still is) maintaining and mutating the state (like > whether a swap has occurred). So I thought because I have to use > recursion instead of iteration, I could maintain the state using > parameter passing. Here it goes, my first Erlang toy program: > > -module(bsort). > -export([bubble_sort/1, bstage/1, bstage/2]). > > bubble_sort([A,B|Tail]) when Tail =/= [] -> > {Status, List} = bstage([A,B|Tail]), > case Status of > sorted -> List; > not_sorted -> bubble_sort(List) > end; > bubble_sort([A,B]) -> > if > A > B -> [B, A]; > true -> [A, B] > end; > bubble_sort([A]) -> [A]; > bubble_sort([]) -> []. > > bstage(L) -> > {Swapped, List} = bstage(L, false), > case Swapped of > false -> {sorted, List}; > true -> {not_sorted, List} > end. > > bstage([A,B|Tail], Swapped) when Tail =/= [] -> > if > A > B -> {_, List1} = bstage([A|Tail], true), > {true, [B] ++ List1}; > true -> {Swap, List} = bstage([B|Tail], Swapped), > {Swap, [A] ++ List} > end; > bstage([A,B], Swapped) -> > if > A > B -> {true, [B,A]}; > true -> {Swapped, [A,B]} > end. > > Any comments are greatly appreciated. this is the kind of thing i would expect - i haven't tested the code sort(List) -> repeat_til_done(List, []). repeat_til_done([], Acc) -> lists:reverse(Acc); repeat_til_done([A], Acc) -> repeat_til_done([], [A|Acc]); repeat_til_done([A,B|Tail], Acc) when A > B -> repeat_til_done([B|Tail], [A|Acc]); repeat_til_done([A,B|Tail], Acc) -> sort(lists:reverse(Acc) ++ [B,A|Tail]). i don't know if the logic is correct, but the idea is that when you have a swap (the last condition) you just restart. andrew > > Kind regards, > Milen > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From kruegger@REDACTED Sat May 19 23:10:01 2007 From: kruegger@REDACTED (Stephen Han) Date: Sat, 19 May 2007 14:10:01 -0700 Subject: [erlang-questions] convert UTF-8 encoded string to atom. Message-ID: <86f1f5350705191410o3f561370j3b4df97c1330ce9a@mail.gmail.com> Hi. I need your advice on converting UTF-8 encoded string into atom. 1. Is there any function that I can use? 2. Will it be a problem, having non-printable character-based atom within virtual machine? 3. What will be the good approach where in a situation that code converts accepted string to atom when sometime that string is UTF-8 format. I know that the atom is not garbaged collected but assuming that I have limited number of string that won't overflow the atom table within the virtual machine. regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sat May 19 23:43:03 2007 From: bob@REDACTED (Bob Ippolito) Date: Sat, 19 May 2007 14:43:03 -0700 Subject: [erlang-questions] convert UTF-8 encoded string to atom. In-Reply-To: <86f1f5350705191410o3f561370j3b4df97c1330ce9a@mail.gmail.com> References: <86f1f5350705191410o3f561370j3b4df97c1330ce9a@mail.gmail.com> Message-ID: <6a36e7290705191443p4d5c517x73ea6c58f589538b@mail.gmail.com> On 5/19/07, Stephen Han wrote: > Hi. > > I need your advice on converting UTF-8 encoded string into atom. > > 1. Is there any function that I can use? > 2. Will it be a problem, having non-printable character-based atom within > virtual machine? > 3. What will be the good approach where in a situation that code converts > accepted string to atom when sometime that string is UTF-8 format. I know > that the atom is not garbaged collected but assuming that I have limited > number of string that won't overflow the atom table within the virtual > machine. It doesn't care what your string is encoded as, so long as it's a list of bytes. 1> list_to_atom([0,255]). '\000\377' -bob From robert.virding@REDACTED Sun May 20 00:40:18 2007 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 20 May 2007 00:40:18 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <464E5723.8070403@duomark.com> References: <464E5723.8070403@duomark.com> Message-ID: <464F7CD2.8080106@telia.com> I suppose it really depends on what you are going to do with these matrices. If you are going to work with them in Erlang then I don't really see the point of keeping them as binaries. Robert Jay Nelson wrote: >> Any thoughts on how to represent a matrix with erlang? (dense or >> sparse) Would a list of lists be good enough or would there be a better way? > > I would consider trying a tuple of binaries and using the whizzy new > bit binary primitives. Compactness and speed may be noticeable if you > are using dense matrices. > > jay > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dot@REDACTED Sun May 20 02:29:08 2007 From: dot@REDACTED (Tony Finch) Date: Sun, 20 May 2007 01:29:08 +0100 Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Message-ID: On Sat, 19 May 2007, Milen Dzhumerov wrote: > > So I wanted to implement some toy algorithms - would you believe me that > I was kind of stuck for several days on the train while going to work > implementing a simple bubble sort algorithm? Quicksort and mergesort are easier to implement in a functional way than bubblesort. Mergesort is generally faster in this setting. http://www.erlang.org/doc/doc-5.5.4/doc/programming_examples/list_comprehensions.html#3.2 Tony. -- f.a.n.finch http://dotat.at/ FISHER GERMAN BIGHT: SOUTH OR SOUTHWEST 5 TO 7. MODERATE OR ROUGH. RAIN OR SHOWERS. MODERATE OR GOOD. From jsnx@REDACTED Sun May 20 03:00:14 2007 From: jsnx@REDACTED (Jason Dusek) Date: Sat, 19 May 2007 18:00:14 -0700 Subject: [erlang-questions] kicking my servers all day long... Message-ID: <42784f260705191800l3528209en3ea280847518c9fe@mail.gmail.com> I'm writing a distributed, finite differences heat diffusion simulation in Erlang. My idea about how to do it goes like this: a) break the big grid into many little grids b) assign the grids to individual servers, and connect each server to those servers with adjacent grids. c) for each time step, have the servers evolve their state and then spawn a new server with the updated data I have sample code which models (c) as updating an int every 50 milliseconds -- it's posted on pastie: http://pastie.caboo.se/62924 Although (c) is conceptually simple, I'm concerned it may be a source of evil performance problems -- I have to spawn bazillions of servers, over and over and over again! Is there another way to do it? What are some other approaches to distributed, finite differences computing in Erlang? I tried posting this on comp.lang.functional and they steered me toward shared memory concurrency and mutable state! -- _jsn From olopierpa@REDACTED Sun May 20 06:46:35 2007 From: olopierpa@REDACTED (Pierpaolo Bernardi) Date: Sun, 20 May 2007 06:46:35 +0200 Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Message-ID: <7352e43a0705192146j54a65d33vf750d9dbbdd1ca7@mail.gmail.com> On 5/19/07, Milen Dzhumerov wrote: > Hi all, > > I've recently picked up the "Programming Erlang" book and started > experimenting with Erlang. So I wanted to implement some toy > algorithms - would you believe me that I was kind of stuck for > several days on the train while going to work implementing a simple > bubble sort algorithm? The following is the most straightforward implementation of bubblesort I could come up with: %%%% -module(bubble). -export([sort/1]). sort(List) -> case bubble_pass(List) of {Res,true} -> Res; {Res,false} -> sort(Res) end. %% bubble_pass(List) -> {Bubbled,Done}. bubble_pass([]) -> {[],true}; bubble_pass([A]) -> {[A],true}; bubble_pass([A|Rest]) -> {[B|T],Done} = bubble_pass(Rest), if A =< B -> {[A,B|T],Done}; true -> {[B,A|T],false} end. %%%% Cheers P. From tty.erlang@REDACTED Sun May 20 08:46:30 2007 From: tty.erlang@REDACTED (t ty) Date: Sun, 20 May 2007 02:46:30 -0400 Subject: [erlang-questions] SHA-256 + salting In-Reply-To: <290b3ba10705181054k4d0974c9j7bfd11f05c05afbc@mail.gmail.com> References: <290b3ba10705181054k4d0974c9j7bfd11f05c05afbc@mail.gmail.com> Message-ID: <290b3ba10705192346i2da38275y21f276c029cead3b@mail.gmail.com> Well looks like I made a mistake. crypto:sha_init/sha_update/sha_final deals only with sha1 instead of sha256. To make up for it here are the patches which would rectify my error. The methods to call are sha256_init/sha256_update/sha256_final. Regards t On 5/18/07, t ty wrote: > I'm assuming you're applying the salt after the data. Init a context, > update it with your data, then update with the salt, and finalize. > [snip] -------------- next part -------------- A non-text attachment was scrubbed... Name: patch.crypto.erl Type: application/octet-stream Size: 1807 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: patch.crypto_drv.c Type: text/x-csrc Size: 3750 bytes Desc: not available URL: From sgolovan@REDACTED Sun May 20 09:06:15 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Sun, 20 May 2007 11:06:15 +0400 Subject: [erlang-questions] Adding IPv6 to ssl application Message-ID: Hi! Mikael Magnusson has contributed a patch to Debian GNU/Linux distribution of Erlang/OTP, which adds IPv6 support to ssl application. I hope it will be useful not only for Debian users. Best wishes! -- Sergei Golovan -------------- next part -------------- A non-text attachment was scrubbed... Name: erlang_11.b.4_ssl_ipv6.patch Type: application/octet-stream Size: 14097 bytes Desc: not available URL: From luke.gorrie@REDACTED Sun May 20 09:35:01 2007 From: luke.gorrie@REDACTED (Luke Gorrie) Date: Sun, 20 May 2007 09:35:01 +0200 Subject: [erlang-questions] regexp sux! References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> Message-ID: Robert Virding writes: > There is a new version of regexp in the pipe which: Today I'm in the market for a fast regexp matcher so please send me a copy if you have it handy :-) I had a quick look at the one on trapexit but it crashed on the regexp "^x" in build_nfa (a missing clause). BTW years ago I ported the OTP Erlang regexp matcher to Haskell and John Hughes immediately found a bug with Quickcheck. Now that Quickcheck exists for Erlang too the OTP folks might find it handy. Unfortunately this was on an infernal "Yahoo! Groups" forum and it seems to have garbage collected the source code. From ulf@REDACTED Sun May 20 09:41:45 2007 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 20 May 2007 09:41:45 +0200 Subject: [erlang-questions] kicking my servers all day long... In-Reply-To: <42784f260705191800l3528209en3ea280847518c9fe@mail.gmail.com> References: <42784f260705191800l3528209en3ea280847518c9fe@mail.gmail.com> Message-ID: <8209f740705200041u62da2ce0n2228434f67e28786@mail.gmail.com> Why do you want to spawn a new server each time? How many instances can there be? It takes only a few microseconds to spawn a process, so if the update frequency is 1/50ms (20/sec), the cost of spawning a process is insignificant. It is also possible to leave one process running for each instance. This used to be quite inefficient from a memory usage perspective, but nowadays, there's the nifty little BIF hibernate(M, F, A), which will compress the process while it waits for the next message. This is mainly useful if you expect relatively long idle periods for the process. BR, Ulf W 2007/5/20, Jason Dusek : > > I'm writing a distributed, finite differences heat diffusion > simulation in Erlang. My idea about how to do it goes like this: > a) break the big grid into many little grids > b) assign the grids to individual servers, and connect each > server to those servers with adjacent grids. > c) for each time step, have the servers evolve their state and > then spawn a new server with the updated data > I have sample code which models (c) as updating an int every 50 > milliseconds -- it's posted on pastie: > > http://pastie.caboo.se/62924 > > Although (c) is conceptually simple, I'm concerned it may be a source > of evil performance problems -- I have to spawn bazillions of servers, > over and over and over again! Is there another way to do it? What are > some other approaches to distributed, finite differences computing in > Erlang? > > I tried posting this on comp.lang.functional and they steered me > toward shared memory concurrency and mutable state! > > -- > _jsn > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun May 20 13:51:59 2007 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 20 May 2007 13:51:59 +0200 Subject: [erlang-questions] regexp sux! In-Reply-To: References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> Message-ID: <4650365F.5080500@telia.com> A few comments about that seeing it is my fault. :-) Anchoring, ^ and $, doesn't work when compiling the regexp with compile, but it should work when running it directly or with just parse. If it doesn't then it is bug. I am working on some new regexp modules with both POSIX and PERL style regexps. There will probably be two modules as they don't just have different features but also different semantics, they will find different matches. What features are people mainly interested in? What should I focus on to start with? N.B. I am implementing it all in Erlang and not doing an interface to a "C" library like PCRE. I mean where's the fun in that? Robert Luke Gorrie wrote: > Robert Virding writes: > >> There is a new version of regexp in the pipe which: > > Today I'm in the market for a fast regexp matcher so please send me a > copy if you have it handy :-) > > I had a quick look at the one on trapexit but it crashed on the regexp > "^x" in build_nfa (a missing clause). > > BTW years ago I ported the OTP Erlang regexp matcher to Haskell and > John Hughes immediately found a bug with Quickcheck. Now that > Quickcheck exists for Erlang too the OTP folks might find it handy. > > Unfortunately this was on an infernal "Yahoo! Groups" forum and > it seems to have garbage collected the source code. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Sun May 20 14:14:45 2007 From: chsu79@REDACTED (Christian S) Date: Sun, 20 May 2007 14:14:45 +0200 Subject: [erlang-questions] regexp sux! In-Reply-To: <4650365F.5080500@telia.com> References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> Message-ID: My ordered wishlist: 1. Being able to extract submatches, like gregexp 2. Matching over binaries without binary_to_list 3. Being able to control greedy vs non-greedy matching 4. A syntax transform that transforms regexps into a calls to generated erlang functions that implement the regexp. (Iff this make regexps faster :) On 5/20/07, Robert Virding wrote: > A few comments about that seeing it is my fault. :-) Anchoring, ^ and $, > doesn't work when compiling the regexp with compile, but it should work > when running it directly or with just parse. If it doesn't then it is bug. > > I am working on some new regexp modules with both POSIX and PERL style > regexps. There will probably be two modules as they don't just have > different features but also different semantics, they will find > different matches. > > What features are people mainly interested in? What should I focus on to > start with? > > N.B. I am implementing it all in Erlang and not doing an interface to a > "C" library like PCRE. I mean where's the fun in that? > > Robert > > Luke Gorrie wrote: > > Robert Virding writes: > > > >> There is a new version of regexp in the pipe which: > > > > Today I'm in the market for a fast regexp matcher so please send me a > > copy if you have it handy :-) > > > > I had a quick look at the one on trapexit but it crashed on the regexp > > "^x" in build_nfa (a missing clause). > > > > BTW years ago I ported the OTP Erlang regexp matcher to Haskell and > > John Hughes immediately found a bug with Quickcheck. Now that > > Quickcheck exists for Erlang too the OTP folks might find it handy. > > > > Unfortunately this was on an infernal "Yahoo! Groups" forum and > > it seems to have garbage collected the source code. > > > > > > _______________________________________________ > > 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 luke.gorrie@REDACTED Sun May 20 17:16:23 2007 From: luke.gorrie@REDACTED (Luke Gorrie) Date: Sun, 20 May 2007 17:16:23 +0200 Subject: [erlang-questions] regexp sux! References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> Message-ID: Howdy, In fact my requirements are as simple as: 1. available in the next few hours :-) 2. can't be wedged by bad input (e.g. "x**" infinite loop), since I want to use user-configurable regexps Quick measurement suggests that performance of the OTP regexp module is more than ample as it tuns out. I'm doing very many repetitions of matching short strings (phone numbers) with simple patterns (e.g. 20 permitted prefix'ish patterns). But "x**" divergence is a big problem with regexp.erl. I will have to leave the feature undocumented if I use that module. The existing code I'm trying to optimise is written in a "little language" that's byte-compiled to a virtual machine that's written in Erlang (Working with Tony is never dull :-)). My Plan A is to add an efficient regexp primitive to the language instead of else-if chains. Plan B is to compile it to native Erlang instead of bytecode. From mark@REDACTED Sun May 20 18:32:29 2007 From: mark@REDACTED (Mark Scandariato) Date: Sun, 20 May 2007 12:32:29 -0400 Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <7352e43a0705192146j54a65d33vf750d9dbbdd1ca7@mail.gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> <7352e43a0705192146j54a65d33vf750d9dbbdd1ca7@mail.gmail.com> Message-ID: -module(bubble). -export([sort/1]). sort(L) -> sort(L, [], 0). sort([], R, 0) -> lists:reverse(R); sort([], R, 1) -> sort(lists:reverse(R)); sort([A], R, S) -> sort([], [A|R], S); sort([A,B|T], R, _) when A>B -> sort([A|T], [B|R], 1); sort([A,B|T], R, S) -> sort([B|T], [A|R], S). On 5/20/07, Pierpaolo Bernardi wrote: > > On 5/19/07, Milen Dzhumerov wrote: > > Hi all, > > > > I've recently picked up the "Programming Erlang" book and started > > experimenting with Erlang. So I wanted to implement some toy > > algorithms - would you believe me that I was kind of stuck for > > several days on the train while going to work implementing a simple > > bubble sort algorithm? > > The following is the most straightforward implementation of bubblesort > I could come up with: > > %%%% > -module(bubble). > > -export([sort/1]). > > sort(List) -> > case bubble_pass(List) of > {Res,true} -> Res; > {Res,false} -> sort(Res) > end. > > > %% bubble_pass(List) -> {Bubbled,Done}. > > bubble_pass([]) -> > {[],true}; > bubble_pass([A]) -> > {[A],true}; > bubble_pass([A|Rest]) -> > {[B|T],Done} = bubble_pass(Rest), > if A =< B -> > {[A,B|T],Done}; > true -> > {[B,A|T],false} > end. > > %%%% > > Cheers > P. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcaoyuan@REDACTED Sun May 20 20:14:43 2007 From: dcaoyuan@REDACTED (Caoyuan) Date: Mon, 21 May 2007 02:14:43 +0800 Subject: [erlang-questions] The best way to convert exprs to string that represents this exprs Message-ID: Hi, I need to convert some expressions to code string, then modify it, then erl_eval the new expressions. Currently the code looks like: match_test() -> PatternStr = "{item, _, [{title, Title, _}, {link, Link, _}]}", Item = {item, [], [{title, "TitleTest", []}, {link, "LinkTest", []}]}, %% The new expression I want is something like: %% {item, _, [{title, Title, _}, {link, Link, _}]} = Item ExprsStr = PatternStr ++ " = " ++ erl_prettypr:format(erl_syntax:abstract(Item)) ++ ".", {ok, ExprsTokens, _} = erl_scan:string(ExprsStr), {ok, Exprs} = erl_parse:parse_exprs(ExprsTokens), {value, Value, _} = erl_eval:exprs(Exprs, []), io:format("~p~n", [Value]) . I don't think my code is the best way. Would you please give me some advices? Thanks From andrew@REDACTED Sun May 20 20:20:41 2007 From: andrew@REDACTED (andrew cooke) Date: Sun, 20 May 2007 14:20:41 -0400 (CLT) Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> <7352e43a0705192146j54a65d33vf750d9dbbdd1ca7@mail.gmail.com> Message-ID: <28534.200.120.169.16.1179685241.squirrel@acooke.dyndns.org> sorry, but since this is for someone asking how best to program - using 0 and 1 to signal state (as below) is poor style. in erlang you can use "atoms" for this (they can be matched in patterns and assigned to variables just like any other simple type), and something like "clean" and "swapped" makes the code easier to read so you would have sort(L) -> sort(L, [], clean) for example. andrew > -module(bubble). > -export([sort/1]). > > sort(L) -> sort(L, [], 0). > > sort([], R, 0) -> lists:reverse(R); > sort([], R, 1) -> sort(lists:reverse(R)); > sort([A], R, S) -> sort([], [A|R], S); > sort([A,B|T], R, _) when A>B -> sort([A|T], [B|R], 1); > sort([A,B|T], R, S) -> sort([B|T], [A|R], S). > > > On 5/20/07, Pierpaolo Bernardi wrote: >> >> On 5/19/07, Milen Dzhumerov wrote: >> > Hi all, >> > >> > I've recently picked up the "Programming Erlang" book and started >> > experimenting with Erlang. So I wanted to implement some toy >> > algorithms - would you believe me that I was kind of stuck for >> > several days on the train while going to work implementing a simple >> > bubble sort algorithm? >> >> The following is the most straightforward implementation of bubblesort >> I could come up with: >> >> %%%% >> -module(bubble). >> >> -export([sort/1]). >> >> sort(List) -> >> case bubble_pass(List) of >> {Res,true} -> Res; >> {Res,false} -> sort(Res) >> end. >> >> >> %% bubble_pass(List) -> {Bubbled,Done}. >> >> bubble_pass([]) -> >> {[],true}; >> bubble_pass([A]) -> >> {[A],true}; >> bubble_pass([A|Rest]) -> >> {[B|T],Done} = bubble_pass(Rest), >> if A =< B -> >> {[A,B|T],Done}; >> true -> >> {[B,A|T],false} >> end. >> >> %%%% >> >> Cheers >> P. >> _______________________________________________ >> 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 wglozer@REDACTED Sun May 20 21:15:16 2007 From: wglozer@REDACTED (Will) Date: Sun, 20 May 2007 12:15:16 -0700 Subject: [erlang-questions] regexp sux! In-Reply-To: References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> Message-ID: The current version of oregexp (http://glozer.net/code.html#oregexp) supports matching on both binaries and lists with a wide variety of character encodings, and uses an extended Perl-type syntax (Ruby's syntax to be exact) that supports grouping and greed specifiers. It is a linked-in driver on top of a C library though and perhaps not suitable as far as stability and blocking of the emulator. That said, performance is good and I have an app using it around once per minute, 24x7, and haven't had any problems so far =) From mberrow1@REDACTED Sun May 20 21:55:55 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Sun, 20 May 2007 12:55:55 -0700 Subject: [erlang-questions] How do you define a function using the shell? Message-ID: <001301c79b18$e278b3b0$6401a8c0@rubicon> I can load function in from files using c(modname). But when I try the same thing in the shell I get an error. eg. 10> Prs = [{2,7},{6,2},{4,3},{2,5}]. [{2,7},{6,2},{4,3},{2,5}] 11> totally(L) -> lists:sum([A * B || {A, B} <- L]). ** 1: syntax error before: '->' ** Coming from ruby, I a used experimenting with code fragments in the shell (very useful). Is there a different way to do it? or is it just not possible? Thanks, -- Mike Berrow From andrew@REDACTED Sun May 20 22:03:41 2007 From: andrew@REDACTED (andrew cooke) Date: Sun, 20 May 2007 16:03:41 -0400 (CLT) Subject: [erlang-questions] How do you define a function using the shell? In-Reply-To: <001301c79b18$e278b3b0$6401a8c0@rubicon> References: <001301c79b18$e278b3b0$6401a8c0@rubicon> Message-ID: <21779.200.120.169.16.1179691421.squirrel@acooke.dyndns.org> i don't have a definitive answer, but a quick sunday afternoon fix that may help is to note that you can (i) bind to variables and (ii) the anonymous function definition (fun...end) supports the usual pattern matching clauses. so: 11> F = fun(1) -> "one"; 11> (N) -> "lots" 11> end. #Fun 12> F(3). "lots" andrew > I can load function in from files using > c(modname). > > But when I try the same thing in the shell I get an error. > eg. > > 10> Prs = [{2,7},{6,2},{4,3},{2,5}]. > [{2,7},{6,2},{4,3},{2,5}] > 11> totally(L) -> lists:sum([A * B || {A, B} <- L]). > ** 1: syntax error before: '->' ** > > Coming from ruby, I a used experimenting with code fragments in the shell > (very useful). > Is there a different way to do it? or is it just not possible? > > Thanks, > -- Mike Berrow > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From bob@REDACTED Sun May 20 22:15:17 2007 From: bob@REDACTED (Bob Ippolito) Date: Sun, 20 May 2007 13:15:17 -0700 Subject: [erlang-questions] How do you define a function using the shell? In-Reply-To: <001301c79b18$e278b3b0$6401a8c0@rubicon> References: <001301c79b18$e278b3b0$6401a8c0@rubicon> Message-ID: <6a36e7290705201315v46a347b8jdacad94603d7be05@mail.gmail.com> On 5/20/07, Mike Berrow wrote: > I can load function in from files using > c(modname). > > But when I try the same thing in the shell I get an error. > eg. > > 10> Prs = [{2,7},{6,2},{4,3},{2,5}]. > [{2,7},{6,2},{4,3},{2,5}] > 11> totally(L) -> lists:sum([A * B || {A, B} <- L]). > ** 1: syntax error before: '->' ** > > Coming from ruby, I a used experimenting with code fragments in the shell (very useful). > Is there a different way to do it? or is it just not possible? You have to use an anonymous function if you're doing it directly in the shell. The easiest way is to just create a module though. If you're using Emacs it's just a couple keystrokes to save+compile, which also does the purge+load in the shell. Totally = fun (L) -> lists:sum([A * B || {A, B} <- L]) end. -bob From mberrow1@REDACTED Sun May 20 22:17:10 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Sun, 20 May 2007 13:17:10 -0700 Subject: [erlang-questions] How do you define a function using the shell? References: <001301c79b18$e278b3b0$6401a8c0@rubicon> <21779.200.120.169.16.1179691421.squirrel@acooke.dyndns.org> Message-ID: <002a01c79b1b$dd9b4030$6401a8c0@rubicon> Thanks, that helps a lot. I tried it this way. 14> Totally = fun(L) -> lists:sum([A * B || {A, B} <- L]) end. #Fun 15> Totally(Prs). 48 16> Prs. [{2,7},{6,2},{4,3},{2,5}] I guess I will have to learn not to expect the environment of the shell and compiled-file to be as interchangable as that. -- Mike Berrow > i don't have a definitive answer, but a quick sunday afternoon fix that > may help is to note that you can (i) bind to variables and (ii) the > anonymous function definition (fun...end) supports the usual pattern > matching clauses. > > so: > 11> F = fun(1) -> "one"; > 11> (N) -> "lots" > 11> end. > #Fun > 12> F(3). > "lots" > > andrew From mpquique@REDACTED Sun May 20 23:36:50 2007 From: mpquique@REDACTED (Enrique Marcote) Date: Sun, 20 May 2007 23:36:50 +0200 Subject: [erlang-questions] erlang nodes over a wifi (50% quality) network In-Reply-To: <88A36FA4-214E-41B6-BDC4-5E1645B42536@smartgames.ca> References: <868840700705190749x299c9058ha07175fe2f1540c1@mail.gmail.com> <88A36FA4-214E-41B6-BDC4-5E1645B42536@smartgames.ca> Message-ID: <868840700705201436g63350e71i3f65d59d5e381929@mail.gmail.com> Thanks a lot Toby, sounds like a good alternative. Best regards, Quique On 5/19/07, Toby Thain wrote: > > On 19-May-07, at 10:49 AM, Enrique Marcote wrote: > > > Hi all, > > > > I'm trying to connect several erlang nodes over a wifi network. ... > > > > Any help would be greatly appreciated. > > If you get desperate, you could try setting up a UDP OpenVPN; this > can make an unreliable network appear reliable to applications. > > --Toby > > > Thanks in advance. > > > > Quique > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > From jay@REDACTED Mon May 21 00:51:00 2007 From: jay@REDACTED (Jay Nelson) Date: Sun, 20 May 2007 15:51:00 -0700 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <464F7CD2.8080106@telia.com> References: <464E5723.8070403@duomark.com> <464F7CD2.8080106@telia.com> Message-ID: <4650D0D4.2070003@duomark.com> Robert Virding wrote: > I suppose it really depends on what you are going to do with these > matrices. If you are going to work with them in Erlang then I don't > really see the point of keeping them as binaries. > Binary comprehensions could be very useful if you are doing operations on every element of a vector (e.g. scaling). Also, if you are using a very large data set and normalize from 0-255 the binaries give a very compact representation, plus the comprehensions should have noticeable better memory performance since they can anticipate and preallocate new binaries rather than consing off the heap. All theoretical since I haven't tried, but I would expect a tuple of binaries to dramatically outperform a list of lists for certain operations. jay From saleyn@REDACTED Mon May 21 02:32:19 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 20 May 2007 19:32:19 -0500 Subject: [erlang-questions] buffered io:format in the shell Message-ID: <4650E893.1020803@gmail.com> Hi, I have a driver that delivers messages to a gen_server process using driver_output function. On the Erlang side the messages are received in the form: handle_info({Port, {data, Data}}, #state{port=Port} = State) -> case binary_to_term(Data) of {msg, Subj, [], Msg} -> io:format("To: ~s, Msg: ~s~n", [Subj, Msg]); Other -> error_log:error_msg("Unknown msg from port: ~p~n", [Other]) end, {noreply, State}; The communication between the driver and Erlang process seems to work fine with the exception that the result of io:format/2 call doesn't get printed to the shell immediately after the message from driver is received. It gets printed only after I hit the key on the keyboard. Any idea why? Serge From juneaftn@REDACTED Mon May 21 04:40:08 2007 From: juneaftn@REDACTED (June Kim) Date: Mon, 21 May 2007 11:40:08 +0900 Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> References: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> Message-ID: <6f80c1520705201940u4f2e8953g8df5ec552cf82ac0@mail.gmail.com> Alright. No one has answered my question yet. When an error occurs how do you find the location in the source file(without the information of source line number)? What is the conventional way in Erlang? 2007/5/18, June Kim : > Suppose foo.erl is: > > -module(foo). > -export([bar/1]). > > bar(X)-> > 1+2+3, > 5=X. > > ============== > > 8> foo:bar(5). > > =ERROR REPORT==== 18-May-2007::23:08:44 === > Error in process <0.61.0> with exit value: > {{badmatch,5},[{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {{badmatch,5}, > [{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** > > The report isn't very helpful. Is there any way I can see the line > number of the source code that the error occured? > From jeffm@REDACTED Mon May 21 06:55:49 2007 From: jeffm@REDACTED (jm) Date: Mon, 21 May 2007 14:55:49 +1000 Subject: [erlang-questions] SASL Auth Module Message-ID: <46512655.4060703@ghostgun.com> Does anyone have any recommendations on a good SASL Authentication (RFC2222 or later) Module for Erlang? Tutorials on using SASL would also be welcomed. Jeff. From darius@REDACTED Mon May 21 08:02:43 2007 From: darius@REDACTED (Darius Bacon) Date: Sun, 20 May 2007 23:02:43 -0700 (PDT) Subject: [erlang-questions] regexp sux! In-Reply-To: (message from Luke Gorrie on Sun, 20 May 2007 17:16:23 +0200) References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> Message-ID: <200705210602.l4L62hkT012941@shell.accesscom.com> > Howdy, > > In fact my requirements are as simple as: > 1. available in the next few hours :-) > 2. can't be wedged by bad input (e.g. "x**" infinite loop), > since I want to use user-configurable regexps Here's a lightly-tested hack -- I'm not familiar with the existing libraries so this is from scratch. -module(ergex). -export([fail/0, empty/0, element/1, seq/2, alt/2, optional/1, star/1, plus/1]). -export([all_matches/2, match/2]). % A regex G is a pair {Nullable, R} % where the bool Nullable is true iff the empty string is to be matched, % and other matching is determined by R, one of: % zero never matches anything % one matches the empty string % {element, C} matches one character, C % {seq, R1, R2} matches R1's language followed by R2's % {alt, R1, R2} matches the union of R1 and R2's languages % {plus, R} matches 1 or more R's % where the R's *must not* match the empty string, except that one % subexpression of a seq may when the other does not. % Use only the following constructors, to enforce this invariant. % (Termination of the matcher depends on it.) % (Many of the cases below are optimizations not needed for correctness -- % e.g. the first two seq/2 cases.) fail() -> {false, zero}. empty() -> {true, zero}. element(C) -> {false, {element, C}}. seq({N, zero}, G) -> if N -> G; true -> {false, zero} end; seq(G, {N, zero}) -> if N -> G; true -> {false, zero} end; seq({true, R1}, {N2, R2}) -> {N2, {seq, either(one, R1), R2}}; seq({false, R1}, {true, R2}) -> {false, {seq, R1, either(one, R2)}}; seq({false, R1}, {false, R2}) -> {false, {seq, R1, R2}}. alt({N1, R1}, {N2, R2}) -> {N1 or N2, either(R1, R2)}. optional({_, R}) -> {true, R}. star({_, R}) -> {false, S} = plus({false, R}), {true, S}. plus({N, zero}) -> {N, zero}; plus({N, {plus, R}}) -> {N, {plus, R}}; plus({N, R}) -> {N, {plus, R}}. either(zero, R2) -> R2; either(R1, zero) -> R1; either(R, R) -> R; either(R1, R2) -> {alt, R1, R2}. % all_matches(regex(), list(C)) -> list(list(C)) % returns the tails of the input after all successful matches. all_matches(G, S) -> ll_to_list(match(G, S)). % match(regex(), list(C)) -> lazylist(list(C)) match({true, R}, S) -> m(either(one, R), S); match({false, R}, S) -> m(R, S). m(zero, _) -> []; m(one, S) -> singleton(S); m({element, C}, [C|S]) -> singleton(S); m({element, _}, _) -> []; m({seq, R1, R2}, S) -> ll_flatmap(fun (S1) -> m(R2, S1) end, m(R1, S)); m({alt, R1, R2}, S) -> ll_append(m(R1, S), fun () -> m(R2, S) end); m({plus, R}, S) -> ll_flatmap(fun (S1) -> [S1 | fun () -> m({plus, R}, S1) end] end, m(R, S)). % The type lazylist(X) is [] | [X | fun() -> lazylist(X) end]. ll_to_list([]) -> []; ll_to_list([H|TF]) -> [H | ll_to_list(TF()) ]. singleton(X) -> [X | fun () -> [] end]. ll_append([], F) -> F(); ll_append([H|TF], F) -> [H | fun () -> ll_append(TF(), F) end]. ll_flatmap(_, []) -> []; ll_flatmap(F, [H|TF]) -> ll_append(F(H), fun () -> ll_flatmap(F, TF()) end). -module(ergexparse). -export([parse/1]). -import(ergex, [fail/0, empty/0, element/1, any/0, seq/2, alt/2, optional/1, star/1, plus/1]). % N.B. no proper syntax error messages yet -- we just crash. parse(S) -> {G, ""} = expr(S), G. expr(S) -> case term(S) of {G1, "|"++S1} -> {G2, S2} = expr(S1), {alt(G1, G2), S2}; {G1, S1} -> {G1, S1} end. term(S) -> {G1, S1} = factor(S), case S1 of [C|_] when C /= $", C /= $), C /= $], C /= $| -> {G2, S2} = term(S1), {seq(G1, G2), S2}; _ -> {G1, S1} end. factor(S) -> postfix(thingy(S)). postfix({G, "*"++S}) -> postfix({star(G), S}); postfix({G, "+"++S}) -> postfix({plus(G), S}); postfix({G, "?"++S}) -> postfix({optional(G), S}); postfix({G, S}) -> {G, S}. thingy("") -> {empty(), ""}; thingy("("++S) -> {G1, ")"++S1} = expr(S), {G1, S1}; thingy("["++S) -> {Chars, S1} = charset(S), {make_charset(Chars), S1}; thingy([C|S]) -> case lists:member(C, "*+?|()[]") of true -> {empty(), [C|S]}; false -> {element(C), S} end. charset("]"++S) -> {[], S}; charset([C|S]) -> {Chars, S1} = charset(S), {[C|Chars], S1}. make_charset([]) -> fail(); make_charset([C|Cs]) -> alt(element(C), make_charset(Cs)). From xpdoka@REDACTED Mon May 21 09:08:27 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Mon, 21 May 2007 09:08:27 +0200 (CEST) Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <6f80c1520705201940u4f2e8953g8df5ec552cf82ac0@mail.gmail.com> References: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> <6f80c1520705201940u4f2e8953g8df5ec552cf82ac0@mail.gmail.com> Message-ID: <42313.217.128.75.198.1179731307.squirrel@www.geekisp.com> Hello June, > When an error occurs how do you find the location in the source > file(without the information of source line number)? What is the > conventional way in Erlang? There is no built-in way to get the source line number of an error. If you write small functions, the error report is usually sufficient. Otherwise, there is a tool called smart_exceptions in jungerl, which is a parse transform that does what you want. Regards, Dominic Williams http://dominicwilliams.net ---- From bengt.kleberg@REDACTED Mon May 21 09:13:18 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 21 May 2007 09:13:18 +0200 Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <6f80c1520705201940u4f2e8953g8df5ec552cf82ac0@mail.gmail.com> References: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> <6f80c1520705201940u4f2e8953g8df5ec552cf82ac0@mail.gmail.com> Message-ID: <4651468E.1050101@ericsson.com> On 2007-05-21 04:40, June Kim wrote: ...deleted >> -module(foo). >> -export([bar/1]). >> >> bar(X)-> >> 1+2+3, >> 5=X. >> >> ============== >> >> 8> foo:bar(5). >> >> =ERROR REPORT==== 18-May-2007::23:08:44 === >> Error in process <0.61.0> with exit value: >> {{badmatch,5},[{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} >> >> ** exited: {{badmatch,5}, >> [{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** >> >> The report isn't very helpful. Is there any way I can see the line >> number of the source code that the error occured? i do not know how to get the line number. as an alternative may i suggest that you make your functions short? the error report do tell you which function, and how, the error occurred. in the above example you have a sufficiently short function and the error report says: {{badmatch,5},[{foo,bar,1},.. where badmatch means an error with '='. and 5 means that there is a 5 to the right of the '=' when you get the badmatch. {foo,bar,1} means module foo, function bar (with one argument). this seems impossible to me since the only '=' you have in bar/1 has a 5 to the left which means that is an ok match with a 5 to the right. so in this case it is possible to see from the error report that your example is in error :-) bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From erlang@REDACTED Mon May 21 09:37:58 2007 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 21 May 2007 09:37:58 +0200 Subject: [erlang-questions] Bubble sort in Erlang In-Reply-To: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> References: <2DA744EF-6DA6-4051-8238-1A7F38374668@gmail.com> Message-ID: <9b08084c0705210037h7f768fdeoab1aa111c1f91123@mail.gmail.com> I would do this is steps Whats the problem? To start with here's the *wrong* code bs([A,B|T]) when A =< B -> [A|bs([B|T)]; bs([A,B|T]) -> [B|bs([A|T])]; %% SWAP bs([A]) -> [A]; bs([]) -> []. The problem is that in the line marked "SWAP" we need to somehow record the fact that we have performed a swap so we can "do it again" We modify the first program adding a flag to record if we need to "do it again" and an accumulator (the third argument) to collect the result. Like this: bs([A,B|T], Flag, L) when A =< B -> bs([B|T], Flag, [A|L]); bs([A,B|T], _, L) -> bs([A|T], true, [B|L]); bs([X], Flag, L) -> bs([], Flag, [X|L]); bs([], Flag, L) -> {Flag, reverse(L)}. The flag is changed to true if the arguments in the list are out of order, otherwise it is just passed unchnaged through the function calls. When the initial list is finished we return the flag and the reversed accumulator Now we need an iterator, this is easy. bs(L) -> case bs(L, false, []) of {true, L1} -> bs(L1); %% if the flag is true - do it again {false, L1} -> L1 end. You could actually get rid of the reverse in bs/3 by noting which order the list is in - on the first pass you bubble out of order elements to the right, on the second to the left etc. (ie on the first pass you try to make a list with the smallest element first, on the second pass with the largest element last (since the list is reversed at the end of the first pass)). The library routines for sort use this technique, they also special case sorting short lists. /Joe On 5/19/07, Milen Dzhumerov wrote: > Hi all, > > I've recently picked up the "Programming Erlang" book and started > experimenting with Erlang. So I wanted to implement some toy > algorithms - would you believe me that I was kind of stuck for > several days on the train while going to work implementing a simple > bubble sort algorithm? I think FP really hit my head - that's the > first time I've tried any functional programming. The hardest part > for me was (and still is) maintaining and mutating the state (like > whether a swap has occurred). So I thought because I have to use > recursion instead of iteration, I could maintain the state using > parameter passing. Here it goes, my first Erlang toy program: > > -module(bsort). > -export([bubble_sort/1, bstage/1, bstage/2]). > > bubble_sort([A,B|Tail]) when Tail =/= [] -> > {Status, List} = bstage([A,B|Tail]), > case Status of > sorted -> List; > not_sorted -> bubble_sort(List) > end; > bubble_sort([A,B]) -> > if > A > B -> [B, A]; > true -> [A, B] > end; > bubble_sort([A]) -> [A]; > bubble_sort([]) -> []. > > bstage(L) -> > {Swapped, List} = bstage(L, false), > case Swapped of > false -> {sorted, List}; > true -> {not_sorted, List} > end. > > bstage([A,B|Tail], Swapped) when Tail =/= [] -> > if > A > B -> {_, List1} = bstage([A|Tail], true), > {true, [B] ++ List1}; > true -> {Swap, List} = bstage([B|Tail], Swapped), > {Swap, [A] ++ List} > end; > bstage([A,B], Swapped) -> > if > A > B -> {true, [B,A]}; > true -> {Swapped, [A,B]} > end. > > Any comments are greatly appreciated. > > Kind regards, > Milen > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Mon May 21 09:54:34 2007 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 21 May 2007 09:54:34 +0200 Subject: [erlang-questions] How do you define a function using the shell? In-Reply-To: <001301c79b18$e278b3b0$6401a8c0@rubicon> References: <001301c79b18$e278b3b0$6401a8c0@rubicon> Message-ID: <9b08084c0705210054qd061840w8292108f72f598b8@mail.gmail.com> It's not possible - but it *should be possible* When I was writing the Erlang book Dave Thomas asked be precisely this question "why can't you just type the module code into the shell" I gave my knee-jerk reaction - "because ..." He countered, "but it must be easy - all you have to do is pipe all the shell output into a file and compile it ...." He (and Mike) are right (of course). Module code and "what you can write in a shell" are different and it's been a pain in the arse explaining in the book, in the errata to the book and in this group *why* they are different. Variable in the shell look pretty much like bound variables in parameterized modules. It wouldn't be that difficult to let the shell and module code be interchangable. There are some problems with this. Supppose this was legal in the shell AND in a module > -module(a). > X = foo:bar(...) > foo(A, B) -> > A+B+X. > -end(module) Then foo would have to be available when we compile bar and we would run into version nastyness. A suitable compromise might be "everything you can type in a module can be typed into the shell" but NOT the other way around. On the other hand, if we solved the version nastyness problem then doing shell like things in module would be great for writing efficient code AND we could throw away the parse transform stuff, doing it with regular functions. /Joe On 5/20/07, Mike Berrow wrote: > I can load function in from files using > c(modname). > > But when I try the same thing in the shell I get an error. > eg. > > 10> Prs = [{2,7},{6,2},{4,3},{2,5}]. > [{2,7},{6,2},{4,3},{2,5}] > 11> totally(L) -> lists:sum([A * B || {A, B} <- L]). > ** 1: syntax error before: '->' ** > > Coming from ruby, I a used experimenting with code fragments in the shell (very useful). > Is there a different way to do it? or is it just not possible? > > Thanks, > -- Mike Berrow > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thomasl_erlang@REDACTED Mon May 21 09:59:05 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 21 May 2007 00:59:05 -0700 (PDT) Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <42313.217.128.75.198.1179731307.squirrel@www.geekisp.com> Message-ID: <920304.26415.qm@web38802.mail.mud.yahoo.com> --- Dominic Williams wrote: > Otherwise, there is a tool called smart_exceptions > in jungerl, which > is a parse transform that does what you want. Do note that, while I (the author) use smart_exceptions routinely for my development, it is not quite a complete solution. It has trouble with some erlang constructs, and gives spurious warnings in some cases. (The root cause is that exported variables are a pain.) Alternatives: the macro ?LINE can be used in simple situations, and there is also the various trace facilities, such as dbg as well as more advanced tools, to help with seeing where and why a fault arose. There is also the graphical debugger (which I don't use). As usual, I'll close by saying a compiler-based solution would be preferrable to smart_exceptions, but there isn't one yet. Best, Thomas ____________________________________________________________________________________Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz From erlang@REDACTED Mon May 21 10:10:06 2007 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 21 May 2007 10:10:06 +0200 Subject: [erlang-questions] some language changes Message-ID: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Now the book is done I've been thinking about some language changes. Here's my list (no particular priority) 1. What you type in the shell and what you type in a module/escript should be the same 2. Hashmaps (aka associative arrays) 3. Extended string syntax: idea - put an atom *before the string quote to say what the string means and to *change* the syntax rules that apply to the string content. X = C "......" C = a control atom X = regexp " ... " = html " .... " Then we could write regexps and LaTeX inside strings without all the horrible additional quotes 4. Simple string substitutions X = subst "aaa ${P} bbb ${Q} ccc" *means* X = [<"aaa">, P, <"bbb">, Q, ...] This would be very useful. None of these are large changes - but they would make Erlang a nicer language to program in. The (regexp "....") would be extremely useful to the compiler and allow generating efficient regexp matching code :-) Comments? /Joe From vladdu55@REDACTED Mon May 21 11:18:58 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 21 May 2007 11:18:58 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <95be1d3b0705210218n6bf76ee5s6799501ac2b37cd4@mail.gmail.com> On 5/21/07, Joe Armstrong wrote: > Now the book is done I've been thinking about some language changes. Very smart! You enjoyed writing the book, so now you have to prepare for the second edition! ;-) > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that apply > to the string content. > > X = C "......" > C = a control atom > > X = regexp " ... " > > = html " .... " > > Then we could write regexps and LaTeX inside strings without > all the horrible additional quotes In order to allow unquoted strings, a more general solution would be something similar to HERE documents in the Unix shell. (in the above, double quotes still have to be escaped) Regarding the label prefix, I'm not sure how this could be implemented without hardcoding a few control atoms... Once the can is open, many will find uses beyond the original set. When parsing functions are applied to a constant string, a parse transform (or the compiler itself) could take care of regexps or whatever at compile time. And we're closing in on the topic of metaprogramming again :-) > 4. Simple string substitutions > X = subst "aaa ${P} bbb ${Q} ccc" > *means* X = [<"aaa">, P, <"bbb">, Q, ...] > This would be very useful. Or maybe something like: X = io:format("aaa ~{P}p bbb ~{Q}w ccc") which would be equivalent to X = io:format("aaa ~p bbb ~w ccc", [P, Q]) best regards, Vlad From als@REDACTED Mon May 21 12:07:09 2007 From: als@REDACTED (Anthony Shipman) Date: Mon, 21 May 2007 20:07:09 +1000 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <200705212007.09584.als@iinet.net.au> On Monday 21 May 2007 18:10, Joe Armstrong wrote: > Now the book is done I've been thinking about some language changes. > > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that > apply to the string content. > > X = C "......" > C = a control atom > > X = regexp " ... " > > = html " .... " > Isn't that just a function call C("...") to inject the string into some new type? Being able to define a new abstract type would be a big improvement in the language. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From erlang@REDACTED Mon May 21 12:24:25 2007 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 21 May 2007 12:24:25 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <200705212007.09584.als@iinet.net.au> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> Message-ID: <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> On 5/21/07, Anthony Shipman wrote: > On Monday 21 May 2007 18:10, Joe Armstrong wrote: > > Now the book is done I've been thinking about some language changes. > > > > > 3. Extended string syntax: idea - put an atom *before the string quote > > to say what the string means and to *change* the syntax rules that > > apply to the string content. > > > > X = C "......" > > C = a control atom > > > > X = regexp " ... " > > > > = html " .... " > > > > Isn't that just a function call C("...") to inject the string into some new > type? Being able to define a new abstract type would be a big improvement in > the language. No - it changes the *syntax* of a string - normally you have to quote backspashes Suppose I has a *simple* regexp like this: [.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]* I'd like to say X = regexp "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*" and not the more obvious X = "[.?!][]\\"')}]*\\\\($\\\\| $\\\\|\t\\\\| \\\\)[ \\t\\n]*" \Joe > > -- > 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 kenneth.lundin@REDACTED Mon May 21 14:01:07 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 21 May 2007 14:01:07 +0200 Subject: [erlang-questions] escript questions In-Reply-To: <200705180304.06885.als@iinet.net.au> References: <200705180304.06885.als@iinet.net.au> Message-ID: Hi, The answer is that there is no support in Erlang to produce output to STDERR. Obviously there is need for producing output to STDERR especially when you write escripts and we plan to add support for this later this year (no promise when) /Regards Kenneth (OTP team at Ericsson) On 5/17/07, Anthony Shipman wrote: > How do I write to stderr from a script? The io functions take a standard_io > atom but there does not seem to be a standard_err. > > I tried doing > file:open("/dev/fd/2", [write]) > but erlang appears to refuse to write to device files. > > I get warning messages from unused functions in my script which I would like > to suppress. I tried adding some dummy code: > unused(), ... > > unused() -> > [fun error/1, fun warning/1, fun message/2]. > > But I just get the error: > escript: script failed with error reason undef > when I do that. Is this an escript bug? > > -- > 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 thomasl_erlang@REDACTED Mon May 21 16:02:56 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 21 May 2007 07:02:56 -0700 (PDT) Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <469706.86479.qm@web38803.mail.mud.yahoo.com> --- Joe Armstrong wrote: > Now the book is done I've been thinking about some > language changes. > > Here's my list (no particular priority) > > 1. What you type in the shell and what you type in a > module/escript > should be the same If so, with macros, -include, -record and all that gunk. I'd also recommend looking at the Prolog toploop for a pretty good compromise. > 2. Hashmaps (aka associative arrays) Pure or destructive? > 3. Extended string syntax: idea - put an atom > *before the string quote > to say what the string means and to *change* the > syntax rules that apply > to the string content. This could be a good idea. How would we define such lexer changes? User specified? (However, note that the experience with languages with too user-mutable syntax is not good.) Specifying big blocks of text could be more convenient as well. > 4. Simple string substitutions > > X = subst "aaa ${P} bbb ${Q} ccc" > > *means* X = [<"aaa">, P, <"bbb">, Q, ...] > > This would be very useful. Er, did you intend X = [<"aaa ">, P, <" bbb ">, Q, <" ccc">] ? :-) Anyway, adding user-defined prefix (and infix) operators is fairly straightforward in theory. Prolog, SML and others have done it for ages (20-30 years). The lexer has to detect and classify operators properly before converting them to the proper class of tokens. Haskell has particularly simple infix operators, written as x `op` y which converts to (op x y) without declarations. I think we discussed adding that sort of thing some time ago. It's straightforward. Best, Thomas PS. And where did "!!" go? ____________________________________________________________________________________Pinpoint customers who are looking for what you sell. http://searchmarketing.yahoo.com/ From james.hague@REDACTED Mon May 21 16:29:43 2007 From: james.hague@REDACTED (James Hague) Date: Mon, 21 May 2007 09:29:43 -0500 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: > 2. Hashmaps (aka associative arrays) Yay! > 4. Simple string substitutions > > X = subst "aaa ${P} bbb ${Q} ccc" I agree, this would be nice, especially if it handled automatic conversion from atoms and other non-string values. Honestly, I've grown to hate io:format because it's so cumbersome to use. From andrew@REDACTED Mon May 21 16:36:19 2007 From: andrew@REDACTED (andrew cooke) Date: Mon, 21 May 2007 10:36:19 -0400 (CLT) Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <13848.200.120.169.16.1179758179.squirrel@acooke.dyndns.org> > Now the book is done I've been thinking about some language changes. > > Here's my list (no particular priority) > > 1. What you type in the shell and what you type in a module/escript > should be the same > > 2. Hashmaps (aka associative arrays) > > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that > apply > to the string content. > > X = C "......" > C = a control atom > > X = regexp " ... " > > = html " .... " > > Then we could write regexps and LaTeX inside strings without > all the horrible additional quotes > > 4. Simple string substitutions > > X = subst "aaa ${P} bbb ${Q} ccc" > > *means* X = [<"aaa">, P, <"bbb">, Q, ...] It's a pity that the syntax can't be related to that used in io:format somehow. Also, as well as implicitly using names in the current scope, it might be nice if an explicit map from names to values could be specified. One use case from my own experience that might help here is generating SQL statements from templates. That required that - the template should be a separate entity, that can be re-used with different sets of values (so parsing of the template only occurs once) - there be some way of customizing the conversion from value to string of characters (without an explicit type system that probably means additional names in the template that specify conversion functions). This is probably getting more complex than you intended - perhaps it's only helpful in suggesting some caution before adding syntax that address only a limited use case. Andrew > > This would be very useful. > > None of these are large changes - but they would make Erlang a nicer > language > to program in. The (regexp "....") would be extremely useful to the > compiler > and allow generating efficient regexp matching code :-) > > Comments? > > /Joe > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From 1115201006@REDACTED Mon May 21 16:27:24 2007 From: 1115201006@REDACTED (1115201006@REDACTED) Date: Mon, 21 May 2007 16:27:24 +0200 Subject: [erlang-questions] some language changes References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: Joe Armstrong wrote: > 1. What you type in the shell and what you type in a module/escript > should be the same Hi Joe. Can you elaborate this point, please? regards, Gil From luke.gorrie@REDACTED Mon May 21 17:27:53 2007 From: luke.gorrie@REDACTED (Luke Gorrie) Date: Mon, 21 May 2007 17:27:53 +0200 Subject: [erlang-questions] regexp sux! References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> <200705210602.l4L62hkT012941@shell.accesscom.com> Message-ID: Darius Bacon writes: > Here's a lightly-tested hack -- I'm not familiar with the existing > libraries so this is from scratch. You bloody showoff. :-) Works great! I had to add . (dot) but nothing else really obvious is missing. Feel free to draw my attention to anything I'm overlooking though :-) Can I steal this code and use it at work? NB: I would still feel more comfortable if this were quickcheck'd a bit for divergence etc. I can't help but think that a free quickcheck clone is likely to surface soon. I hope that John & Thomas are happy with this idea or if not that they make their one accessible to us random hackers on the list somehow soon :-) From mberrow1@REDACTED Mon May 21 17:53:32 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Mon, 21 May 2007 08:53:32 -0700 Subject: [erlang-questions] some language changes References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <011d01c79bc0$313dd370$6401a8c0@rubicon> > 1. What you type in the shell and what you type in a module/escript > should be the same Thanks so much for considering this, Joe. As I mentioned in my earlier post, coming from ruby, I was a bit startled that it didn't work that way. I've found that the ability to free-form drop (or type) chunks of code into the shell (exactly as would be used in practice) has been great for quick experiments and prototyping. It also eases the language learning curve. Bob mentioned some emacs trick to get the same effect in a few keystrokes. Nice, but I'm not currently up for another try to learn emacs (very happy with Textpad for now). I think transparency here would produce a big payoff. Actually, isn't the Lisp REPL also this way? BTW, I'm very much enjoying working my way through your book. -- Mike Berrow From darius@REDACTED Mon May 21 17:55:12 2007 From: darius@REDACTED (Darius Bacon) Date: Mon, 21 May 2007 08:55:12 -0700 (PDT) Subject: [erlang-questions] regexp sux! In-Reply-To: (message from Luke Gorrie on Mon, 21 May 2007 17:27:53 +0200) References: <45F27E12.2000102@ericsson.com> <45F47F3F.20009@telia.com> <4650365F.5080500@telia.com> <200705210602.l4L62hkT012941@shell.accesscom.com> Message-ID: <200705211555.l4LFtCjV074597@shell.accesscom.com> Luke Gorrie wrote: > Darius Bacon writes: > > > Here's a lightly-tested hack -- I'm not familiar with the existing > > libraries so this is from scratch. > > You bloody showoff. :-) Works great! Guilty. :-) > I had to add . (dot) but nothing else really obvious is missing. > Feel free to draw my attention to anything I'm overlooking though :-) There's no attempt to conform to any standard, and the regex parser ought to be replaced with a real one that understands char ranges, inverted char classes, escaping, etc. > Can I steal this code and use it at work? Sure, I guess an MIT license would be appropriate. I'd appreciate getting back any improvements/tests -- don't know when I'll get around to the quickcheck tests. > NB: I would still feel more comfortable if this were quickcheck'd a > bit for divergence etc. I can't help but think that a free quickcheck > clone is likely to surface soon. I hope that John & Thomas are happy > with this idea or if not that they make their one accessible to us > random hackers on the list somehow soon :-) Their automatic error-case shrinking sounds really cool and useful. Darius From richardc@REDACTED Mon May 21 18:12:03 2007 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 21 May 2007 18:12:03 +0200 Subject: [erlang-questions] Displaying the line number when error occured In-Reply-To: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> References: <6f80c1520705180712p673f544cvcd50fd70b478b37b@mail.gmail.com> Message-ID: <4651C4D3.20708@it.uu.se> June Kim wrote: > ** exited: {{badmatch,5}, > [{foo,bar,1},{shell,exprs,6},{shell,eval_loop,3}]} ** > > The report isn't very helpful. Is there any way I can see the line > number of the source code that the error occured? As noted by others, once you get a bit of experience with Erlang, the information in the error report is often enough to give you a good idea of where the error occurred. But sometimes, this can be tricky to see, especially in large functions. So, if what you really want to do is find where the error happens (and not necessarily just get a printout with a line number), you can run the debugger (type 'debugger:start()' in your Erlang shell). The modules you want trace need to be compiled with the 'debug_info' compiler option. http://www.erlang.org/doc/doc-5.5.4/lib/debugger-3.1.1/doc/html/index.html http://www.erlang.org/doc/doc-5.5.4/lib/debugger-3.1.1/doc/html/part_frame.html /Richard From brad@REDACTED Mon May 21 18:21:40 2007 From: brad@REDACTED (Brad Anderson) Date: Mon, 21 May 2007 12:21:40 -0400 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 Message-ID: <4651C714.4030103@sankatygroup.com> Hi all, I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, 32bit). I've placed the needed packages on the system so far: gcc 3.4.6 openssl-0.9.8e make-3.81 and their dependencies... Also, I received an 'ar' error in ./configure, so I added Solaris binutils to the path. Any insight would be appreciated. Cheers, Brad Here's what I'm getting: gcc -g -O2 -I/export/home/root/installs/erlang/otp_src_R11B-4/erts/i386-pc-solaris2.10 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DHYBRID -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Ibeam -Isys/unix -Isys/common -Ii386-pc-solaris2.10/opt/hybrid -Ii386-pc-solaris2.10 -Izlib -Ihipe -I../include/internal -I../include/internal/i386-pc-solaris2.10 -c hipe/hipe_x86_glue.S -o obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o Assembler: "/var/tmp//ccdhWGox.s", line 1 : Syntax error Near line: " .section ".text"" "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic Near line: " .global x86_call_to_native" "/var/tmp//ccdhWGox.s", line 8 : Syntax error Near line: " .global x86_call_to_native" "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic Near line: " .global x86_call_to_native" "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic Near line: " .global nbif_return" "/var/tmp//ccdhWGox.s", line 9 : Syntax error Near line: " .global nbif_return" "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic Near line: " .global nbif_return" "/var/tmp//ccdhWGox.s", line 23 : Syntax error Near line: " movl %eax, 80(%ebp) # save retval" "/var/tmp//ccdhWGox.s", line 35 : Syntax error Near line: " movl 32(%esp), %esi # kills HP, if HP_IN_ESI is true" "/var/tmp//ccdhWGox.s", line 37 : Syntax error Near line: " movl 40(%esp), %ebp # kills %ebp" "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic Near line: " .global nbif_callemu" "/var/tmp//ccdhWGox.s", line 41 : Syntax error Near line: " .global nbif_callemu" "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic Near line: " .global nbif_callemu" "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic Near line: " .global nbif_apply" "/var/tmp//ccdhWGox.s", line 51 : Syntax error Near line: " .global nbif_apply" "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic Near line: " .global nbif_apply" "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic Near line: " .global nbif_ccallemu3" "/var/tmp//ccdhWGox.s", line 57 : Syntax error Near line: " .global nbif_ccallemu3" "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic Near line: " .global nbif_ccallemu3" "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic Near line: " .global nbif_ccallemu2" "/var/tmp//ccdhWGox.s", line 70 : Syntax error Near line: " .global nbif_ccallemu2" "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic Near line: " .global nbif_ccallemu2" "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic Near line: " .global nbif_ccallemu1" "/var/tmp//ccdhWGox.s", line 83 : Syntax error Near line: " .global nbif_ccallemu1" "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic Near line: " .global nbif_ccallemu1" "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic Near line: " .global nbif_ccallemu0" "/var/tmp//ccdhWGox.s", line 95 : Syntax error Near line: " .global nbif_ccallemu0" "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic Near line: " .global nbif_ccallemu0" "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic Near line: " .global nbif_suspend_0" "/var/tmp//ccdhWGox.s", line 110 : Syntax error Near line: " .global nbif_suspend_0" "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic Near line: " .global nbif_suspend_0" Too many errors - Goodbye make[3]: *** [obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o] Error 1 make[3]: Leaving directory `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' make[2]: *** [opt] Error 2 make[2]: Leaving directory `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' make[1]: *** [hybrid] Error 2 make[1]: Leaving directory `/export/home/root/installs/erlang/otp_src_R11B-4/erts' make: *** [emulator] Error 2 From mats.cronqvist@REDACTED Mon May 21 18:40:51 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 21 May 2007 18:40:51 +0200 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <4651C714.4030103@sankatygroup.com> References: <4651C714.4030103@sankatygroup.com> Message-ID: <4651CB93.4000701@ericsson.com> Brad Anderson wrote: > Hi all, > > I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, 32bit). I've > placed the needed packages on the system so far: > gcc 3.4.6 > openssl-0.9.8e > make-3.81 > and their dependencies... > > Also, I received an 'ar' error in ./configure, so I added Solaris binutils to > the path. > > Any insight would be appreciated. i'm not sure this qualifies as an insight, but i had a great deal of trouble building anything on solaris 8 (NB). from my notes; binutils ld broken, make sure we use solaris ld/as which as ; which ld ; which cc ; which make ; which gcc /usr/ccs/bin/as /usr/ccs/bin/ld /usr/ucb/cc $ALOCAL/gnu/bin/make $ALOCAL/gnu/bin/gcc it was solaris 8 and probably unrelated to your problem in any case. so this advice is worth what you pay for it... mats From ulf.wiger@REDACTED Mon May 21 18:44:38 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 21 May 2007 18:44:38 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <469706.86479.qm@web38803.mail.mud.yahoo.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <469706.86479.qm@web38803.mail.mud.yahoo.com> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501EA44CF@esealmw115.eemea.ericsson.se> Thomas Lindgren wrote: > > Specifying big blocks of text could be more > convenient as well. I've used Joe's ML9, and think it's a really good way to specify blocks of data with different syntax. BR, Ulf W From rvg@REDACTED Mon May 21 18:54:41 2007 From: rvg@REDACTED (Rudolph van Graan) Date: Mon, 21 May 2007 18:54:41 +0200 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <4651C714.4030103@sankatygroup.com> References: <4651C714.4030103@sankatygroup.com> Message-ID: <6D23854C-FBE3-427B-AF4A-9F5240EF367D@patternmatched.com> Hey, We had to put the gnu gcc in /usr/sfw/bin at the front of the path to get past this error. Rudolph van Graan Software Architect 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 May 21, 2007, at 6:21 PM, Brad Anderson wrote: > Hi all, > > I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, > 32bit). I've > placed the needed packages on the system so far: > gcc 3.4.6 > openssl-0.9.8e > make-3.81 > and their dependencies... > > Also, I received an 'ar' error in ./configure, so I added Solaris > binutils to > the path. > > Any insight would be appreciated. > > Cheers, > Brad > > > Here's what I'm getting: > > gcc -g -O2 > -I/export/home/root/installs/erlang/otp_src_R11B-4/erts/i386-pc- > solaris2.10 > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_THREADS - > D_THREAD_SAFE > -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DHYBRID -DHAVE_CONFIG_H -Wall > -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE > -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Ibeam -Isys/unix -Isys/ > common > -Ii386-pc-solaris2.10/opt/hybrid -Ii386-pc-solaris2.10 -Izlib -Ihipe > -I../include/internal -I../include/internal/i386-pc-solaris2.10 -c > hipe/hipe_x86_glue.S -o obj/i386-pc-solaris2.10/opt/hybrid/ > hipe_x86_glue.o > Assembler: > "/var/tmp//ccdhWGox.s", line 1 : Syntax error > Near line: " .section ".text"" > "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic > Near line: " .global x86_call_to_native" > "/var/tmp//ccdhWGox.s", line 8 : Syntax error > Near line: " .global x86_call_to_native" > "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic > Near line: " .global x86_call_to_native" > "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic > Near line: " .global nbif_return" > "/var/tmp//ccdhWGox.s", line 9 : Syntax error > Near line: " .global nbif_return" > "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic > Near line: " .global nbif_return" > "/var/tmp//ccdhWGox.s", line 23 : Syntax error > Near line: " movl %eax, 80(%ebp) # save retval" > "/var/tmp//ccdhWGox.s", line 35 : Syntax error > Near line: " movl 32(%esp), %esi # kills HP, if HP_IN_ESI is > true" > "/var/tmp//ccdhWGox.s", line 37 : Syntax error > Near line: " movl 40(%esp), %ebp # kills %ebp" > "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic > Near line: " .global nbif_callemu" > "/var/tmp//ccdhWGox.s", line 41 : Syntax error > Near line: " .global nbif_callemu" > "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic > Near line: " .global nbif_callemu" > "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic > Near line: " .global nbif_apply" > "/var/tmp//ccdhWGox.s", line 51 : Syntax error > Near line: " .global nbif_apply" > "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic > Near line: " .global nbif_apply" > "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic > Near line: " .global nbif_ccallemu3" > "/var/tmp//ccdhWGox.s", line 57 : Syntax error > Near line: " .global nbif_ccallemu3" > "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic > Near line: " .global nbif_ccallemu3" > "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic > Near line: " .global nbif_ccallemu2" > "/var/tmp//ccdhWGox.s", line 70 : Syntax error > Near line: " .global nbif_ccallemu2" > "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic > Near line: " .global nbif_ccallemu2" > "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic > Near line: " .global nbif_ccallemu1" > "/var/tmp//ccdhWGox.s", line 83 : Syntax error > Near line: " .global nbif_ccallemu1" > "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic > Near line: " .global nbif_ccallemu1" > "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic > Near line: " .global nbif_ccallemu0" > "/var/tmp//ccdhWGox.s", line 95 : Syntax error > Near line: " .global nbif_ccallemu0" > "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic > Near line: " .global nbif_ccallemu0" > "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic > Near line: " .global nbif_suspend_0" > "/var/tmp//ccdhWGox.s", line 110 : Syntax error > Near line: " .global nbif_suspend_0" > "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic > Near line: " .global nbif_suspend_0" > Too many errors - Goodbye > make[3]: *** [obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o] > Error 1 > make[3]: Leaving directory > `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' > make[2]: *** [opt] Error 2 > make[2]: Leaving directory > `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' > make[1]: *** [hybrid] Error 2 > make[1]: Leaving directory `/export/home/root/installs/erlang/ > otp_src_R11B-4/erts' > make: *** [emulator] Error 2 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From brad@REDACTED Mon May 21 19:01:07 2007 From: brad@REDACTED (Brad Anderson) Date: Mon, 21 May 2007 13:01:07 -0400 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <4651CB93.4000701@ericsson.com> References: <4651C714.4030103@sankatygroup.com> <4651CB93.4000701@ericsson.com> Message-ID: <4651D053.6030900@sankatygroup.com> Mats Cronqvist wrote: > Brad Anderson wrote: >> Hi all, >> >> I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, 32bit). I've >> placed the needed packages on the system so far: >> gcc 3.4.6 >> openssl-0.9.8e >> make-3.81 >> and their dependencies... >> >> Also, I received an 'ar' error in ./configure, so I added Solaris >> binutils to >> the path. >> >> Any insight would be appreciated. > > i'm not sure this qualifies as an insight, but i had a great deal of > trouble building anything on solaris 8 (NB). from my notes; > > binutils ld broken, make sure we use solaris ld/as > which as ; which ld ; which cc ; which make ; which gcc > /usr/ccs/bin/as > /usr/ccs/bin/ld > /usr/ucb/cc > $ALOCAL/gnu/bin/make > $ALOCAL/gnu/bin/gcc > > it was solaris 8 and probably unrelated to your problem in any case. > so this advice is worth what you pay for it... I had no 'as' on the path, and 'ld' was from /usr/ucb/ld, so I changed things around a bit to match your setup. Same result :( And to think, I was going to double what I pay you. Thanks, though for your reply. Cheers, Brad From dot@REDACTED Mon May 21 19:15:31 2007 From: dot@REDACTED (Tony Finch) Date: Mon, 21 May 2007 18:15:31 +0100 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: On Mon, 21 May 2007, Joe Armstrong wrote: > > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that apply > to the string content. This is somewhat reminiscent of Lua's treatment of data. Its usual form for function calls is f(a,b,c) but you can also write constructor-style function calls as f "string" or f {table,literal}. Lua also has a "long string" syntax (using [[ ]] delimiters) which does not support any escape sequences. Combining these features, you can write your example as: X = regexp[[[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*]] Tony. -- f.a.n.finch http://dotat.at/ SOLE: VARIABLE BECOMING MAINLY WESTERLY 3 OR 4. SLIGHT OR MODERATE. FAIR. GOOD. From per@REDACTED Mon May 21 19:30:36 2007 From: per@REDACTED (Per Hedeland) Date: Mon, 21 May 2007 19:30:36 +0200 (CEST) Subject: [erlang-questions] escript questions In-Reply-To: Message-ID: <200705211730.l4LHUaws082853@pluto.hedeland.org> "Kenneth Lundin" wrote: > >The answer is that there is no support in Erlang to produce output to STDERR. Hm, maybe not "support", but it's certainly possible (I assume in escript too though I haven't tried it): $ erl -eval 'stderr:format("hello\n", []), halt()' > /dev/null hello $ cat stderr.erl -module(stderr). -export([format/2]). format(Fmt, Args) -> Port = open_port({fd, 2, 2}, [out]), port_command(Port, io_lib:format(Fmt, Args)), port_close(Port). (In real code you might want to keep the port open rather than doing open/close each time - should be pretty cheap though, and you never print much on stderr, right?:-) --Per Hedeland From brad@REDACTED Mon May 21 19:50:17 2007 From: brad@REDACTED (Brad Anderson) Date: Mon, 21 May 2007 13:50:17 -0400 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <6D23854C-FBE3-427B-AF4A-9F5240EF367D@patternmatched.com> References: <4651C714.4030103@sankatygroup.com> <6D23854C-FBE3-427B-AF4A-9F5240EF367D@patternmatched.com> Message-ID: <4651DBD9.4080509@sankatygroup.com> Rudolph van Graan wrote: > Hey, > > We had to put the gnu gcc in /usr/sfw/bin at the front of the path to > get past this error. Ding ding ding! This worked. Thank you! Full disclosure to help others in the future: # which as ; which ld ; which cc ; which make ; which gcc /usr/ccs/bin/as /usr/ucb/ld /usr/ucb/cc /usr/local/bin/make /usr/sfw/bin/gcc # echo $PATH /usr/bin:/usr/openwin/bin:/usr/ucb:/usr/sfw/bin:/opt/sfw/bin:/usr/local/bin:/usr/ccs/bin I kind of have a mess of toolsets on the box now, and I'm not even sure I needed to install much more than GNU Make (as the /usr/ccs/bin/make did not work) and OpenSSL above and beyond the 11/06 Solaris DVD. Thank you, Rudolph & Mats Cheers, Brad > > Rudolph van Graan > > Software Architect > 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 May 21, 2007, at 6:21 PM, Brad Anderson wrote: > >> Hi all, >> >> I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, 32bit). I've >> placed the needed packages on the system so far: >> gcc 3.4.6 >> openssl-0.9.8e >> make-3.81 >> and their dependencies... >> >> Also, I received an 'ar' error in ./configure, so I added Solaris >> binutils to >> the path. >> >> Any insight would be appreciated. >> >> Cheers, >> Brad >> >> >> Here's what I'm getting: >> >> gcc -g -O2 >> -I/export/home/root/installs/erlang/otp_src_R11B-4/erts/i386-pc-solaris2.10 >> >> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_THREADS -D_THREAD_SAFE >> -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DHYBRID -DHAVE_CONFIG_H -Wall >> -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE >> -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Ibeam -Isys/unix -Isys/common >> -Ii386-pc-solaris2.10/opt/hybrid -Ii386-pc-solaris2.10 -Izlib -Ihipe >> -I../include/internal -I../include/internal/i386-pc-solaris2.10 -c >> hipe/hipe_x86_glue.S -o >> obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o >> Assembler: >> "/var/tmp//ccdhWGox.s", line 1 : Syntax error >> Near line: " .section ".text"" >> "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic >> Near line: " .global x86_call_to_native" >> "/var/tmp//ccdhWGox.s", line 8 : Syntax error >> Near line: " .global x86_call_to_native" >> "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic >> Near line: " .global x86_call_to_native" >> "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic >> Near line: " .global nbif_return" >> "/var/tmp//ccdhWGox.s", line 9 : Syntax error >> Near line: " .global nbif_return" >> "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic >> Near line: " .global nbif_return" >> "/var/tmp//ccdhWGox.s", line 23 : Syntax error >> Near line: " movl %eax, 80(%ebp) # save retval" >> "/var/tmp//ccdhWGox.s", line 35 : Syntax error >> Near line: " movl 32(%esp), %esi # kills HP, if HP_IN_ESI is true" >> "/var/tmp//ccdhWGox.s", line 37 : Syntax error >> Near line: " movl 40(%esp), %ebp # kills %ebp" >> "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic >> Near line: " .global nbif_callemu" >> "/var/tmp//ccdhWGox.s", line 41 : Syntax error >> Near line: " .global nbif_callemu" >> "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic >> Near line: " .global nbif_callemu" >> "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic >> Near line: " .global nbif_apply" >> "/var/tmp//ccdhWGox.s", line 51 : Syntax error >> Near line: " .global nbif_apply" >> "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic >> Near line: " .global nbif_apply" >> "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic >> Near line: " .global nbif_ccallemu3" >> "/var/tmp//ccdhWGox.s", line 57 : Syntax error >> Near line: " .global nbif_ccallemu3" >> "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic >> Near line: " .global nbif_ccallemu3" >> "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic >> Near line: " .global nbif_ccallemu2" >> "/var/tmp//ccdhWGox.s", line 70 : Syntax error >> Near line: " .global nbif_ccallemu2" >> "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic >> Near line: " .global nbif_ccallemu2" >> "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic >> Near line: " .global nbif_ccallemu1" >> "/var/tmp//ccdhWGox.s", line 83 : Syntax error >> Near line: " .global nbif_ccallemu1" >> "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic >> Near line: " .global nbif_ccallemu1" >> "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic >> Near line: " .global nbif_ccallemu0" >> "/var/tmp//ccdhWGox.s", line 95 : Syntax error >> Near line: " .global nbif_ccallemu0" >> "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic >> Near line: " .global nbif_ccallemu0" >> "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic >> Near line: " .global nbif_suspend_0" >> "/var/tmp//ccdhWGox.s", line 110 : Syntax error >> Near line: " .global nbif_suspend_0" >> "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic >> Near line: " .global nbif_suspend_0" >> Too many errors - Goodbye >> make[3]: *** [obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o] Error 1 >> make[3]: Leaving directory >> `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' >> make[2]: *** [opt] Error 2 >> make[2]: Leaving directory >> `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' >> make[1]: *** [hybrid] Error 2 >> make[1]: Leaving directory >> `/export/home/root/installs/erlang/otp_src_R11B-4/erts' >> make: *** [emulator] Error 2 >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From diginux@REDACTED Tue May 22 02:04:48 2007 From: diginux@REDACTED (Jordan Wilberding) Date: Mon, 21 May 2007 19:04:48 -0500 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <465233A0.40609@diginux.net> It would be nice to have pattern matching with lists/atoms in between variables, like this: fcn(String1 + "::" + String2) -> ...; fcn(String1 + "==" + String2) -> ...; fcn(OtherString) -> ... . Thanks! Jordan Wilberding From toby@REDACTED Tue May 22 02:12:54 2007 From: toby@REDACTED (Toby Thain) Date: Mon, 21 May 2007 21:12:54 -0300 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <4651DBD9.4080509@sankatygroup.com> References: <4651C714.4030103@sankatygroup.com> <6D23854C-FBE3-427B-AF4A-9F5240EF367D@patternmatched.com> <4651DBD9.4080509@sankatygroup.com> Message-ID: On 21-May-07, at 2:50 PM, Brad Anderson wrote: > Rudolph van Graan wrote: >> Hey, >> >> We had to put the gnu gcc in /usr/sfw/bin at the front of the path to >> get past this error. > > Ding ding ding! This worked. Thank you! > > Full disclosure to help others in the future: > > # which as ; which ld ; which cc ; which make ; which gcc > /usr/ccs/bin/as > /usr/ucb/ld > /usr/ucb/cc > /usr/local/bin/make > /usr/sfw/bin/gcc > > # echo $PATH > /usr/bin:/usr/openwin/bin:/usr/ucb:/usr/sfw/bin:/opt/sfw/bin:/usr/ > local/bin:/usr/ccs/bin I use something like: /usr/bin:/usr/openwin/bin:/usr/perl5/5.8.4/bin:/usr/apache2/bin:/usr/ sfw/bin:/usr/ccs/bin:/opt/sfw/bin:/usr/local/bin:/usr/sbin:/opt/ SUNWspro/bin > > I kind of have a mess of toolsets on the box now, and I'm not even > sure I > needed to install much more than GNU Make You don't need to install that; it's bundled as 'gmake'. > (as the /usr/ccs/bin/make did not > work) and OpenSSL above and beyond the 11/06 Solaris DVD. > I don't believe anything more than bundled packages are required to build Erlang/OTP (incl openssl) on Solaris 10; I've done it several times. --Toby > Thank you, Rudolph & Mats > > Cheers, > Brad > > >> >> Rudolph van Graan >> >> Software Architect >> 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 May 21, 2007, at 6:21 PM, Brad Anderson wrote: >> >>> Hi all, >>> >>> I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, >>> 32bit). I've >>> placed the needed packages on the system so far: >>> gcc 3.4.6 >>> openssl-0.9.8e >>> make-3.81 >>> and their dependencies... >>> >>> Also, I received an 'ar' error in ./configure, so I added Solaris >>> binutils to >>> the path. >>> >>> Any insight would be appreciated. >>> >>> Cheers, >>> Brad >>> >>> >>> Here's what I'm getting: >>> >>> gcc -g -O2 >>> -I/export/home/root/installs/erlang/otp_src_R11B-4/erts/i386-pc- >>> solaris2.10 >>> >>> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_THREADS - >>> D_THREAD_SAFE >>> -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DHYBRID -DHAVE_CONFIG_H - >>> Wall >>> -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS - >>> D_THREAD_SAFE >>> -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Ibeam -Isys/unix -Isys/ >>> common >>> -Ii386-pc-solaris2.10/opt/hybrid -Ii386-pc-solaris2.10 -Izlib -Ihipe >>> -I../include/internal -I../include/internal/i386-pc-solaris2.10 -c >>> hipe/hipe_x86_glue.S -o >>> obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o >>> Assembler: >>> "/var/tmp//ccdhWGox.s", line 1 : Syntax error >>> Near line: " .section ".text"" >>> "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic >>> Near line: " .global x86_call_to_native" >>> "/var/tmp//ccdhWGox.s", line 8 : Syntax error >>> Near line: " .global x86_call_to_native" >>> "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic >>> Near line: " .global x86_call_to_native" >>> "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic >>> Near line: " .global nbif_return" >>> "/var/tmp//ccdhWGox.s", line 9 : Syntax error >>> Near line: " .global nbif_return" >>> "/var/tmp//ccdhWGox.s", line 9 : Illegal mnemonic >>> Near line: " .global nbif_return" >>> "/var/tmp//ccdhWGox.s", line 23 : Syntax error >>> Near line: " movl %eax, 80(%ebp) # save retval" >>> "/var/tmp//ccdhWGox.s", line 35 : Syntax error >>> Near line: " movl 32(%esp), %esi # kills HP, if HP_IN_ESI >>> is true" >>> "/var/tmp//ccdhWGox.s", line 37 : Syntax error >>> Near line: " movl 40(%esp), %ebp # kills %ebp" >>> "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic >>> Near line: " .global nbif_callemu" >>> "/var/tmp//ccdhWGox.s", line 41 : Syntax error >>> Near line: " .global nbif_callemu" >>> "/var/tmp//ccdhWGox.s", line 41 : Illegal mnemonic >>> Near line: " .global nbif_callemu" >>> "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic >>> Near line: " .global nbif_apply" >>> "/var/tmp//ccdhWGox.s", line 51 : Syntax error >>> Near line: " .global nbif_apply" >>> "/var/tmp//ccdhWGox.s", line 51 : Illegal mnemonic >>> Near line: " .global nbif_apply" >>> "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu3" >>> "/var/tmp//ccdhWGox.s", line 57 : Syntax error >>> Near line: " .global nbif_ccallemu3" >>> "/var/tmp//ccdhWGox.s", line 57 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu3" >>> "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu2" >>> "/var/tmp//ccdhWGox.s", line 70 : Syntax error >>> Near line: " .global nbif_ccallemu2" >>> "/var/tmp//ccdhWGox.s", line 70 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu2" >>> "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu1" >>> "/var/tmp//ccdhWGox.s", line 83 : Syntax error >>> Near line: " .global nbif_ccallemu1" >>> "/var/tmp//ccdhWGox.s", line 83 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu1" >>> "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu0" >>> "/var/tmp//ccdhWGox.s", line 95 : Syntax error >>> Near line: " .global nbif_ccallemu0" >>> "/var/tmp//ccdhWGox.s", line 95 : Illegal mnemonic >>> Near line: " .global nbif_ccallemu0" >>> "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic >>> Near line: " .global nbif_suspend_0" >>> "/var/tmp//ccdhWGox.s", line 110 : Syntax error >>> Near line: " .global nbif_suspend_0" >>> "/var/tmp//ccdhWGox.s", line 110 : Illegal mnemonic >>> Near line: " .global nbif_suspend_0" >>> Too many errors - Goodbye >>> make[3]: *** [obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o] >>> Error 1 >>> make[3]: Leaving directory >>> `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' >>> make[2]: *** [opt] Error 2 >>> make[2]: Leaving directory >>> `/export/home/root/installs/erlang/otp_src_R11B-4/erts/emulator' >>> make[1]: *** [hybrid] Error 2 >>> make[1]: Leaving directory >>> `/export/home/root/installs/erlang/otp_src_R11B-4/erts' >>> make: *** [emulator] Error 2 >>> >>> >>> _______________________________________________ >>> 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 me@REDACTED Tue May 22 03:58:04 2007 From: me@REDACTED (Vladislav Titov) Date: Tue, 22 May 2007 02:58:04 +0100 Subject: [erlang-questions] some language changes Message-ID: <8f4efcb10705211858r19f6a843oabf79c473e1f35f@mail.gmail.com> On 5/21/07, Joe Armstrong wrote: > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that apply > to the string content. > 4. Simple string substitutions These two sound like they'd be perfectly matched by something like CL's reader macro concept. This can be done by, for example, extending the code preprocessor to allow specifying "reader atoms" and a callback module to handle them (so it's just a fancy code transform). Upon encountering such atom (prefixed by some kind of a control character, presumably) the preprocessor would call into the callback, passing in an epp handle. The epp module can then be extended with something along the lines of peek_form/peek_char, pop_form/pop_char/pop_space, push_form/push_char. Then, for example, the regexp example can be implemented (in a perl way, so that code can do :regexp /"(\w+)"/) as: callback(Epp) -> epp:pop_spaces(Epp), StartChar = epp:pop_char(Epp), RegexpStr = find_end(Epp, StartChar, []), epp:push_form({string, epp:get_line(Epp), RegexpStr}). find_end(Epp, X, Acc) -> Y = epp:pop_char(Epp), if Y /= X -> find_end(Epp, X, [Y | Acc]); true -> lists:reverse(Acc). Likewise, string substitution would be fairly straightforward (apart from manually parsing the string). This would allow for a range of nice features, from extending the language with new literal type (:pid <0,1,2>), to some fancy metaprogramming tricks (:bitcount(X) would turn into element(X, {0,1,1,2,1,...})). It brings in some of the functionality of CL macros without all the nasty AST stuff. I'll stop now. vlad From m5@REDACTED Tue May 22 05:40:25 2007 From: m5@REDACTED (Mike McNally) Date: Mon, 21 May 2007 22:40:25 -0500 Subject: [erlang-questions] some language changes Message-ID: <20070522034025.GD20556@works.com> I just subscribed and so can't hook directly into the "some language changes thread", but hopefully this won't be lost: I think it'd be really (REALLY) nice to have a "letrec" facility for "fun" expressions, so that they could more easily recurse (kind-of important in Erlang!). Maybe something like "fun (...) -> ... end" so that "" would be bound in the function appropriately. -- [ I love pre-moistened towelettes ] Mike McNally -- m5@REDACTED From beepblip@REDACTED Tue May 22 07:10:46 2007 From: beepblip@REDACTED (beepblip@REDACTED) Date: Mon, 21 May 2007 22:10:46 -0700 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <7cb7cf500705212210y1f618681y50107c25e7ca5b50@mail.gmail.com> good stuff On 5/21/07, Joe Armstrong wrote: > > > 2. Hashmaps (aka associative arrays) Yes! This would be a great addition. 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules that > apply > to the string content. > > X = C "......" > C = a control atom > > X = regexp " ... " > > = html " .... " > > Then we could write regexps and LaTeX inside strings without > all the horrible additional quotes How about this as well. Allow us to declare a list as a string with some metadata on the listobject. I don't mind the linked-list structure. I just want an easy way for an RPC system to know the difference when communicating with some other language or data representation (aka JSON, Ruby, Python, ...). All the implementations that try to distinguish between a string and a list have clumsy techniques. Something using a literal like: S = "some string here" Would set that bit.. and Ah, but these are just cells. How could that be done? Mark all the cells. Have new constructors for binary to string conversion. Of course we would need that is_string() function as well. BTW, thanks for opening this up for discussion. cheers! -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberlync@REDACTED Tue May 22 07:40:49 2007 From: cyberlync@REDACTED (Eric Merritt) Date: Mon, 21 May 2007 22:40:49 -0700 Subject: [erlang-questions] some language changes In-Reply-To: <7cb7cf500705212210y1f618681y50107c25e7ca5b50@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <7cb7cf500705212210y1f618681y50107c25e7ca5b50@mail.gmail.com> Message-ID: I agree with most of these. Why not write up EEPs for these. On 5/21/07, beepblip@REDACTED wrote: > > good stuff > > > On 5/21/07, Joe Armstrong wrote: > > > > 2. Hashmaps (aka associative arrays) > > > Yes! This would be a great addition. > > > > 3. Extended string syntax: idea - put an atom *before the string quote > > to say what the string means and to *change* the syntax rules that > apply > > to the string content. > > > > X = C "......" > > C = a control atom > > > > X = regexp " ... " > > > > = html " .... " > > > > Then we could write regexps and LaTeX inside strings without > > all the horrible additional quotes > > > > How about this as well. Allow us to declare a list as a string with some > metadata > on the listobject. I don't mind the linked-list structure. I just want an > easy > way for an RPC system to know the difference when communicating with > some other language or data representation (aka JSON, Ruby, Python, ...). > All the implementations > that try to distinguish between a string and a list have clumsy techniques. > > Something using a literal like: > > S = "some string here" > > Would set that bit.. and > > Ah, but these are just cells. How could that be done? Mark all the cells. > Have new > constructors for binary to string conversion. Of course we would need that > is_string() function as well. > > > BTW, thanks for opening this up for discussion. > > cheers! > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From bengt.kleberg@REDACTED Tue May 22 08:16:32 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 22 May 2007 08:16:32 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <011d01c79bc0$313dd370$6401a8c0@rubicon> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <011d01c79bc0$313dd370$6401a8c0@rubicon> Message-ID: <46528AC0.2020604@ericsson.com> On 2007-05-21 17:53, Mike Berrow wrote: ...deleted > I've found that the ability to free-form drop (or type) chunks of code > into the shell (exactly as would be used in practice) has been great > for quick experiments and prototyping. It also eases the language > learning curve. ...deleted > Actually, isn't the Lisp REPL also this way? yes, it is. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From mikpe@REDACTED Tue May 22 10:28:14 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Tue, 22 May 2007 10:28:14 +0200 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <4651C714.4030103@sankatygroup.com> References: <4651C714.4030103@sankatygroup.com> Message-ID: <18002.43422.646229.925550@alkaid.it.uu.se> Brad Anderson writes: > Hi all, > > I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, 32bit). I've > placed the needed packages on the system so far: > gcc 3.4.6 > openssl-0.9.8e > make-3.81 > and their dependencies... > > Also, I received an 'ar' error in ./configure, so I added Solaris binutils to > the path. > > Any insight would be appreciated. > > Cheers, > Brad > > > Here's what I'm getting: > > gcc -g -O2 > -I/export/home/root/installs/erlang/otp_src_R11B-4/erts/i386-pc-solaris2.10 > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_THREADS -D_THREAD_SAFE > -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DHYBRID -DHAVE_CONFIG_H -Wall > -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE > -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Ibeam -Isys/unix -Isys/common > -Ii386-pc-solaris2.10/opt/hybrid -Ii386-pc-solaris2.10 -Izlib -Ihipe > -I../include/internal -I../include/internal/i386-pc-solaris2.10 -c > hipe/hipe_x86_glue.S -o obj/i386-pc-solaris2.10/opt/hybrid/hipe_x86_glue.o > Assembler: > "/var/tmp//ccdhWGox.s", line 1 : Syntax error > Near line: " .section ".text"" > "/var/tmp//ccdhWGox.s", line 8 : Illegal mnemonic etc You MUST use the GNU assembler if you want HiPE support on x86. Sun's x86 assemblers are and have always been broken beyond repair. That means using a gcc that's been configured to use gas. If you don't want to install or build a fixed gcc, then you can avoid this error by doing ./configure --disable-hipe before building OTP. /Mikael From francesco@REDACTED Tue May 22 11:52:59 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Tue, 22 May 2007 10:52:59 +0100 Subject: [erlang-questions] Any Erlang IMAP Servers out there? Message-ID: <4652BD7B.3010702@erlang-consulting.com> Hi All, I was looking around for an Erlang based IMAP server implementation. I came across a few mentions of projects in various blogs, IMAP client implementations and similar, but was not able to locate anything concrete on the server side. Has anyone worked on an IMAP server implementation and would care to share their experiences and / or the source code? Francesco -- http://www.erlang-consulting.com From saleyn@REDACTED Tue May 22 13:19:20 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Tue, 22 May 2007 06:19:20 -0500 Subject: [erlang-questions] FIX protocol Message-ID: <4652D1B8.3020509@gmail.com> Hi, Does anyone have an implementation of a FIX protocol (http://fixprotocol.org) in Erlang? I'd like to do a proof of concept model in order to see if Erlang can handle a heavy stream of financial market data sent using FIX. Serge From dot@REDACTED Tue May 22 12:39:01 2007 From: dot@REDACTED (Tony Finch) Date: Tue, 22 May 2007 11:39:01 +0100 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: On Mon, 21 May 2007, Joe Armstrong wrote: > > 2. Hashmaps (aka associative arrays) How would this be different from ets? Tony. -- f.a.n.finch http://dotat.at/ TYNE: SOUTHWEST 4 OR 5, BECOMING VARIABLE 3 OR LESS FOR A TIME. SMOOTH OR SLIGHT. FAIR. GOOD. From saleyn@REDACTED Tue May 22 14:07:52 2007 From: saleyn@REDACTED (Serge Aleynikov) Date: Tue, 22 May 2007 07:07:52 -0500 Subject: [erlang-questions] buffered io:format in the shell Message-ID: <4652DD18.3010708@gmail.com> I modified the code to include spawning two processes (test1 and test2) that both write output to the shell. When gen_server receives messages from the driver via handle_info and sends them to test1 they are not printed to the console until *any* key is pressed in the shell. However when I send messages to 'test2' (i.e. test2 ! "some msg") the message gets printed immediately. Any hint on what may be causing such an oddity? test1() -> spawn(fun() -> register(test1, self()), loop() end), start_server(). test2() -> spawn(fun() -> register(test2, self()), loop() end), loop() -> receive Msg -> io:format("~p: ~p\n", [self(), Msg]), loop() end. start_server() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). ... handle_info({Port, {data, Data}}, #state{port=Port} = State) -> (catch test1 ! binary_to_term(Data)}, {noreply, State}; The driver generates messages via: driver_output(data->port, x.buff, x.buffsz); > Hi, > > I have a driver that delivers messages to a gen_server process using > driver_output function. On the Erlang side the messages are received > in the form: > handle_info({Port, {data, Data}}, #state{port=Port} = State) -> > case binary_to_term(Data) of > {msg, Subj, [], Msg} -> > io:format("To: ~s, Msg: ~s~n", [Subj, Msg]); > Other -> > error_log:error_msg("Unknown msg from port: ~p~n", [Other]) > end, > {noreply, State}; > > > The communication between the driver and Erlang process seems to work > fine with the exception that the result of io:format/2 call doesn't > get printed to the shell immediately after the message from driver is > received. It gets printed only after I hit the key on the > keyboard. Any idea why? From chsu79@REDACTED Tue May 22 14:08:05 2007 From: chsu79@REDACTED (Christian S) Date: Tue, 22 May 2007 14:08:05 +0200 Subject: [erlang-questions] some language changes In-Reply-To: References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: On 5/22/07, Tony Finch wrote: > On Mon, 21 May 2007, Joe Armstrong wrote: > > 2. Hashmaps (aka associative arrays) > How would this be different from ets? Is this item the records-that-you-can-query-the-fields-of ? Replacing our current compile time macro records? A tiny though about records. Would this be too over engineered or heavy: Often when one deal with records, one deal with more than one records of the same kind. Imagine then that instead of adding better records to the language, we add a table type (or just hide it behind tagged tuples, the interesting part is that it, the table, is reflective). Having a table type one can begin adding higher level features to it. Such as indexing two ways. Imagine a protocol where you have numeric codes but you want to use atoms in your code. You have a mapping like: [{ok, 0}, {error, 1}, {foo_reply, 2}, ..., {baz_reply, 2324}] It is common that when you encode protocol messages you have the atom names, and want the numeric code, and the opposite when decoding messages. This magic table type of ours can then support indexing for faster lookup of either numeric to atoms or atoms to numeric. Lookup could be made quite pretty with list comprehensions, looking similar to a list of tuples: <> = Msg, [MsgType] = [Name || ?{atom=Name, numeric=Code} <- Table], Client ! decode(MsgType, Data), The question mark being some syntax for matching a table. The efficiency of the code depends on if the programmer has added the following or not when constructing the table: Table1 = tables:constraint(Table, [{unique_index, atom}, {unique_index, numeric}]) It would be a bit more heavy weight than the typical gen_server emacs skeleton's state-record. But I think it can be afforded. It would be natural for mnesia queries to be returned as a table object. Various goodies that QLC do can be moved into properties of the table object, and ordinary LCs can be made aware of tables to take advantage of any indexing maintained by them. A code switch modification of a table would be as simple as Table1 = [?{apple=A, banana=bend(B), coconut=C} || ?{a=A, b=B, c=C} <- Table] I begin to ask myself if the QLC stuff deserves more attention and first-class citizenship. I also ask myself if this is the stuff better suited for a programming language for stored procedures in an rdbm, than a language for telecom and 3d modelling software. From dmitriid@REDACTED Tue May 22 14:10:55 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Tue, 22 May 2007 15:10:55 +0300 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <4652DDCF.7080901@gmail.com> Joe Armstrong wrote: > Comments? > I wonder if better record manipulation could be added to the language. See http://yarivsblog.com/articles/2006/10/11/recless-a-type-inferring-parse-transform-for-erlang-experimental/ Example from tha post: [quote] The Erlang record syntax gets even more cumbersome when working with nested records. Let?s say we want to get the city of the owner of Project. This is how we go about it using the record syntax: | City = ((Project#project.owner) #person.address)#address.city | If you think that?s an eyesore, consider *changing* the value of the city: | NewProject = Project#project{owner = (Project#project.owner)#person{address = ((Project#project.owner) #person.address)#address{city = "Boston"}}}. | Yes, I know. Ugly. That?s why I created Recless. Recless is a parse transform that uses a type inference algorithm to figure out what kinds of records your variables are holding, and then lets you write much less code to work with their elements. For example, with Recless, the above two examples could be written as | City = Project.owner.city. | and | NewProject = Project.owner.address.city = "Boston".| [/unquote] -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Tue May 22 14:39:35 2007 From: gleber.p@REDACTED (Gleber) Date: Tue, 22 May 2007 13:39:35 +0100 Subject: [erlang-questions] Spatial indexing in mnesia References: Message-ID: <20070522123935.554945A1FB@mail.erlangsystems.com> Hello, I would like to revive this thread, because I'm interested in spatial indexing in mnesia. I've searched a lot of resources about Erlang and mnesia, and found nothing about R-trees implementation in Erlang or extending mnesia with spatial indexing. I've done no hacking into mnesia yet. I'm not interested in full-blown spatial extension for mnesia, though my thoughts go into the following direction: - let have two tables - "header" table and "data" table - header table will have at least two columns - one with tuple of four floats (bounding box of given spatial object) and one with ID of row in "data" table - a spatial index (using R-tree) will be built in memory (without writing to disk), thus this index will be available only for ram-only and ram-disk tables - spatial queries will be run using this index on "header" table and list of IDs will be returned, it will be filtered on client side and then proper spatial data will be fetched from "data" table If I'm not mistaken mnesia is capable of storing list of tuples in a single column, i.e. [{0, 0}, {99.5, 111.33333}, ...], so it is suitable for simple spatial objects. Am I right? Now my questions. Does anyone done anything similar before? Is it possible to implement at all? Will this architecture be efficient? May anyone point me some documentation about an implementation of indecies in mnesia? I will be thankful for any information about this topic. Shawn, David, have you done any research on the topic? Regards, Gleb Peregud _________________________________________________________ Post sent from http://www.trapexit.org From toby@REDACTED Tue May 22 14:51:16 2007 From: toby@REDACTED (Toby Thain) Date: Tue, 22 May 2007 09:51:16 -0300 Subject: [erlang-questions] Solaris 10 build issues - R11B-4 In-Reply-To: <18002.43422.646229.925550@alkaid.it.uu.se> References: <4651C714.4030103@sankatygroup.com> <18002.43422.646229.925550@alkaid.it.uu.se> Message-ID: <35528939-A0EE-4287-9A86-BE912C2807AA@smartgames.ca> On 22-May-07, at 5:28 AM, Mikael Pettersson wrote: > Brad Anderson writes: >> Hi all, >> >> I'm trying to get OTP R11B-4 to compile on Solaris 10 (x86, >> 32bit). ... > > You MUST use the GNU assembler if you want HiPE support on x86. > Sun's x86 assemblers are and have always been broken beyond repair. > That means using a gcc that's been configured to use gas. > > If you don't want to install or build a fixed gcc, A suitable gcc is bundled with Solaris 10, as far as I know; it's just not on default $PATH. --Toby > then you can avoid > this error by doing ./configure --disable-hipe before building OTP. > > /Mikael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Tue May 22 16:02:02 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 22 May 2007 16:02:02 +0200 Subject: [erlang-questions] some language changes In-Reply-To: References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <9b08084c0705220702o4a51e2cdmd1646035f96c8171@mail.gmail.com> On 5/22/07, Tony Finch wrote: > On Mon, 21 May 2007, Joe Armstrong wrote: > > > > 2. Hashmaps (aka associative arrays) > > How would this be different from ets? > > Tony. Syntax - you could pattern match them in function heads foo(#{x=Pattern,y=Pattern, ...}, ...) -> This has been discussed many times before but not implemented (not quite true :-) - but any implementation didn't make it to the release /Joe > -- > f.a.n.finch http://dotat.at/ > TYNE: SOUTHWEST 4 OR 5, BECOMING VARIABLE 3 OR LESS FOR A TIME. SMOOTH OR > SLIGHT. FAIR. GOOD. > From jsnx@REDACTED Tue May 22 19:23:38 2007 From: jsnx@REDACTED (Jason Dusek) Date: Tue, 22 May 2007 10:23:38 -0700 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <4650D0D4.2070003@duomark.com> References: <464E5723.8070403@duomark.com> <464F7CD2.8080106@telia.com> <4650D0D4.2070003@duomark.com> Message-ID: <42784f260705221023h41a2281eld6b37c07d1116d99@mail.gmail.com> I just joined the list, so I've had to follow most of this thread from the web interface. The earlier post about interfacing Erlang with Fortran seems to be spot on to me -- I'm a big fan of sharp tools doing one job well. Why try to re-implement Fortran's many achievements in Erlang? I see a couple of 'patterns' for developing Fortran-backed Erlang applications: a) write single machine Fortran 'servers' that talk with an Erlang node through a socket connection. That way, you can take full advantage of Fortran's multi-processor support without having to deal with it's approach to concurrency/parallelization. The Erlang node on the server is responsible for restarting the Fortran app as needed, as well as feeding it work and data. b) write Fortran math libraries and work out a solid FFI for Fortran stuff. I personally think of this as the ugly way, although it does protect one from the data replication and complicated request translation that might result from (a). I'm interested in developing distributed game engines with Erlang. As things stand now, numerical performance in Erlang is not a strong selling point -- nor is the FFI. However, (a) demands only a nice way to send data -- presumably binary is okay -- from one process to another. What does the list think? I don't have a lot of experience with this stuff, so criticism is definitely appreciated. -- _jsn From w.a.de.jong@REDACTED Tue May 22 21:26:38 2007 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Tue, 22 May 2007 21:26:38 +0200 Subject: [erlang-questions] Erlsom 1.0.0 has been released Message-ID: <407d9ef80705221226m263aed40y91f872f6763dcd66@mail.gmail.com> Hi, I have released a new version of erlsom. erlsom is an XML parser that translates XML documents to Erlang records (and vice versa). The information required to determine the format of the record is taken from an XML Schema (and the XML document is checked against this schema during parsing). You can find more information on Erlsom, including a simple example, on http://forum.trapexit.org/viewtopic.php?t=8604 If you have any problems, questions or suggestions regarding erlsom, please let me know. Regards, Willem -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Tue May 22 21:28:43 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 22 May 2007 21:28:43 +0200 Subject: [erlang-questions] Erlang math libraries In-Reply-To: <42784f260705221023h41a2281eld6b37c07d1116d99@mail.gmail.com> References: <464E5723.8070403@duomark.com> <464F7CD2.8080106@telia.com> <4650D0D4.2070003@duomark.com> <42784f260705221023h41a2281eld6b37c07d1116d99@mail.gmail.com> Message-ID: Hi, See comments below. On 5/22/07, Jason Dusek wrote: > I just joined the list, so I've had to follow most of this thread from > the web interface. The earlier post about interfacing Erlang with > Fortran seems to be spot on to me -- I'm a big fan of sharp tools > doing one job well. Why try to re-implement Fortran's many > achievements in Erlang? I agree with you in this. > > I see a couple of 'patterns' for developing Fortran-backed Erlang applications: > > a) write single machine Fortran 'servers' that talk with an Erlang node > through a socket connection. That way, you can take full advantage > of Fortran's multi-processor support without having to deal with it's > approach to concurrency/parallelization. The Erlang node on the > server is responsible for restarting the Fortran app as needed, as > well as feeding it work and data. > > b) write Fortran math libraries and work out a solid FFI for Fortran stuff. > I personally think of this as the ugly way, although it does protect one > from the data replication and complicated request translation that might > result from (a). If you can call Fortran from C which I assume there are lots of solutions for, there should be no problem making a linked in driver which does the job. > > I'm interested in developing distributed game engines with Erlang. As > things stand now, numerical performance in Erlang is not a strong > selling point -- nor is the FFI. However, (a) demands only a nice way > to send data -- presumably binary is okay -- from one process to > another. What does the list think? I don't have a lot of experience > with this stuff, so criticism is definitely appreciated. I don't really understand why you think you need more numerical performance than Erlang can handle for a distributed game engine. What about the FFI?, I agree that the linked in driver interface (C) or the Erl_interface (C over socket) or the Jinterface (Java over socket) are not the easiest to use or program for. But a generic FFI like you have for other languages where you can call almost any function residing in a shared library is not suitable for Erlang since we have to think about concurrency and overall performance as well. A call to a foreign language function might take a long time before it returns and during that time the whole Erlang VM must not block. To be sure that this does not happen each call which potentially can execute for a long time must be run in a separate thread. > > -- > _jsn > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > /Kenneth (OTP Team at Ericsson) From darius@REDACTED Tue May 22 23:55:15 2007 From: darius@REDACTED (Darius Bacon) Date: Tue, 22 May 2007 14:55:15 -0700 (PDT) Subject: [erlang-questions] some language changes In-Reply-To: <20070522034025.GD20556@works.com> (message from Mike McNally on Mon, 21 May 2007 22:40:25 -0500) References: <20070522034025.GD20556@works.com> Message-ID: <200705222155.l4MLtF59024142@shell.accesscom.com> Mike McNally wrote: > I think it'd be really (REALLY) nice to have a "letrec" facility for > "fun" expressions, so that they could more easily recurse (kind-of > important in Erlang!). Maybe something like "fun (...) -> ... end" > so that "" would be bound in the function appropriately. It may be a bad idea to encourage code with substantial nested functions in Erlang. When you say "X = foo()", its meaning depends on the context -- whether X is already bound. The more context the expression is nested within, the more this would matter. We're used to lots of nesting in e.g. Scheme or Haskell, but in those languages the scope rules are different. Darius From ok@REDACTED Wed May 23 01:17:06 2007 From: ok@REDACTED (ok) Date: Wed, 23 May 2007 11:17:06 +1200 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> When it comes to discussing Erlang language changes, it seems impertinent to disagree with Joe Armstrong, but I must protest. On 21 May 2007, at 8:10 pm, Joe Armstrong wrote: > 1. What you type in the shell and what you type in a module/escript > should be the same This one I don't care about so much, but it is worth examining. This has never been the case in Smalltalk, and nobody seems to notice any problem. The cases are precisely analogous: if you want to define a class (think "module") or method (think "named function") in Smalltalk you have to do it in a Browser (think "editor"), not a Workspace (think "shell"). (There _is_ a way to do it, but it's about 100 times harder. It has never been the case in Prolog. If you want to define a module or predicate in Prolog, consult it from a file. Again, there is an alternative. In Prolog's case, it's quite an easy one. One of the files you can consult is 'user' (think "/dev/tty") so instead of typing ?- p(X) :- X = 1 ; X = 2. ?- at the prompt ("?- " is the prompt), you do this: ?- [user]. % load code from /dev/tty p(X) :- X = 1 ; X = 2. end_of_file. ?- Experienced Prolog programmers know that it is almost always a bad idea to do this, because stuff you enter that way disappears from sight. You can call it, but not edit it. And that's a really important point. Joe is suggesting that the Erlang shell should be changed to make it easier for beginners to shoot themselves in the foot, instead of learning practices that will help to keep them out of trouble. I cannot think that a good idea. While you can indeed do this in Lisp and Scheme, bear in mind that Lisp and Scheme originally had no modules. Scheme still has none, and Lisp modules are, um, unusual in that they are never closed, so it is always possible to add new stuff inside a module. Nor have Lisp's modules ever been as closely associated with files as Erlang's. I would also instance Haskell as an Erlang-related language in which the language used in modules and the language used in a shell (as in hugs, ghci, hbi, ...) are quite different. For example, f x = x + 1 is a perfectly good function definition in a file, but in a shell it is a syntax error (double-checked in hbi just now). (Yes, I know that hbi does allow function definitions in the shell. My point is that the syntax used for that purpose is drastically different from normal Haskell syntax.) > > 2. Hashmaps (aka associative arrays) It's not clear quite what is being proposed here. I am very keen to have psi-terms where the "keys" can be atoms and atoms ONLY, because that will permit an EFFICIENT replacement for records. (Not as efficient as records, but a heck of a lot more efficient than a-lists or general hash tables.) Hash tables where the keys can be just about anything are another matter, not least because Erlang/OTP already has them. > > 3. Extended string syntax: idea - put an atom *before the string quote > to say what the string means and to *change* the syntax rules > that apply > to the string content. > > X = C "......" > C = a control atom > > X = regexp " ... " > > = html " .... " > > Then we could write regexps and LaTeX inside strings without > all the horrible additional quotes This is the one that stung me into writing. Can Joe really be serious here? HOW are the syntax rules to be changed? Is there any limit at all? Amongst other things, consider this: there is not just ONE regexp syntax, there are MANY. - Classic sh wildcards (? = ., * = [^/]*, [...] = [...]) - Csh wildcards (as above but including {...,...,...} - ed(1) regular expressions - grep(1) regular expressions - egrep(1) regular expressions - awk(1) regular expressions - POSIX regular expressions (at least two kinds) ... and then of course there are Perl and Java regular expressions, whose designers missed the point of regular expressions, namely EFFICIENT matching. So either you build at least a dozen regular expression syntaxes into the Erlang lexical analyser, or you define one single regular expression syntax (possibly a new one) and find that practically everyone can make no use of the feature because they need one of the other syntaxes. I'm old enough to have used (and loved, for all its quirkiness) SNOBOL. I'm crazy enough to still have and occasionally use a copy of SNOBOL on my Solaris box. And if I am not going to get linear time matching (thank you Perl, NOT!) then I don't see why I should have to put up with the limitations of regexp syntax. Give me SNOBOL! More seriously, Erlang HAS leex and yecc. So Erlang HAS means of expressing pattern matches. Again, if I want HTML, I want HTML, *not* strings. Strings are just about the worst possible way to represent HTML, with or without funny rules. More precisely, I want one of two things. (a) I want something that looks just like HTML, with the ability to plug stuff into it. And yes, it would be entirely possible to extend Erlang syntax to include an XML-like form. ::= ::= '<' { '=' }... ::= | | '(' ')' ::= ::= '/>' | '>' [ {',' }... ['||' | '|' ]] ::= '] '>' So instead of X = html "
$(X)$(Y)
" we would have X =
XY
This is not idle speculation. I have a preprocessor for C that lets me do this kind of stuff in C. Here is an extract from an actual C program: . . .
for_each_named_child(e1, i2, "PERSONA", j2, e2) . ^e2
end_each_named_child .
"\240" . ^first_child_named(e1, "GRPDESCR")
The preprocessor is amazingly simple too. I was an idiot; I should have written the preprocessor in AWK, not C. Here's what that could look like in Erlang: T = , ,
E2,
|| E2 <- named_children(E1, 'PERSONA')
"\240" first_named_child(E1, 'GRPDESCR') ,
, Why would you want to make this look like a string? I add here an extremely important note. The easy way to try out an extension like this is to write a preprocessor. Erlang would not necessarily be the best language to do that in. Haskell is far more compact (about a factor of 2). However, every extra complication added to the language (like 'html "..."') makes it harder to write a preprocessor. Yes, this is a paradox, but like all good paradoxes it's true: the simpler the language is, the easier it is to experiment with extensions to it. (b) I want to process (X(HT)?|HT)ML in a declarative language using a natural data structure in that language. In this case, I need to know what the data structure actually *is*, and since with the 'html "..."' notation I *don't* know that, it is only another banana skin in my path. Now the notation I outlined above can be adapted to patterns as well. Once the language is extended with psi-terms we can treat the attributes of an XML element as a psi-term and the children as a list. So we could have stuff like rows(|T
) -> reverse(rows_aux(T, [])). rows_aux([], R) -> R; rows_aux([X|Xs], R) -> rows_aux(Xs, rows_one(X, R)). rows_one(|_, R) -> R; rows_one(|_, R) -> R; rows_one(|_, R) -> R; rows_one(|T, R) -> rows_aux(T, R); rows_one(|T, R) -> rows_aux(T, R); rows_one(|T, R) -> rows_aux(T, R); rows_one(X = |_, R) -> [X|R]. This is enough to compensate for not knowing what the data structure is; with this notation (mapped onto some Erlang data) I would be able to write Erlang code *as if* XML were a native data type. Given that we could have something like this, what would be the point of saddling ourselves with anything less capable. > > 4. Simple string substitutions > > X = subst "aaa ${P} bbb ${Q} ccc" > > *means* X = [<"aaa">, P, <"bbb">, Q, ...] > > This would be very useful. Not really. There is no string substitution in AWK. So how does that make AWK string expressions compared with Perl? SHORTER! Perl: "aaa ${P} bbb ${Q} ccc" AWK: "aaa "P" bbb "Q" ccc" Haskell: "aaa "++p++" bbb "++q++" ccc" But wait! Joe says that the translation of 'subst "aaa ${P} bbb ${Q} ccc"' is [<"aaa ">, P, <" bbb ">, Q, <" ccc">] instead of the expected ("aaa " ++ P ++ " bbb " ++ Q ++ " ccc") I must say that to anyone used to string interpolation in UNIX shells, in Perl, in TCL, or practically anything I can think of that has it, this is extremely surprising. In all such languages, string interpolation gives you a string, the same kind of string you would normally get without any $() magic. So let's amend this proposal: subst "aaa ${P} bbb ${Q} ccc" => ["aaa ", P, " bbb ", Q, " ccc"] subst <"aaa ${P} bbb ${Q} ccc"> => [<"aaa ">, P, <" bbb ">, Q, <" ccc">] subst 'aaa ${P} bbb ${Q} ccc' => ['aaa ', P, ' bbb ', Q, ' ccc'] Ask for a string and you GET an I/O list of strings. Ask for a binary and you GET an I/O list of binaries. Ask for an atom and you get a list of atoms. There is another way in which this is confusing. In other languages with string interpolation, what is interpolated must be a string. In this proposal it can apparently be any data structure whatever, not excluding process IDs and funs. If you are going to work with I/O lists, it makes sense to interpolate I/O lists, but just how much generality do we actually want? Is string interpolation to be confined to the values of variables, or will it allow arbitrary expressions between '${' and '}'. If only variables are allowed, why? If expressions are allowed, I have learned from the XML world that embedding languages inside each other makes something very unpleasant to use, even when (as in the case of XPath embedded in XSLT) one of them was *designed* to be embedded. Let's look at the example again: subst "aaa ${P} bbb ${Q} ccc" 29 characters ["aaa ",P," bbb ",Q," ccc"] 27 characters subst <"aaa ${P} bbb ${Q} ccc"> 31 characters [<"aaa ">,P,<" bbb ">,Q,<" ccc">] 33 characters I'm not seeing any big savings here. (I've been using <"xxx"> even though the actual Erlang syntax is <<"xxx">> on the assumption that Joe is proposing that change as well.) There are two different issues that one might want to consider. - How can we make it easier to key programs in? The proposed change will sometimes do this. - How can we make it easier to write working programs? That often requires good tool support. Anything that makes it harder for an editor to find a variable (my editor knows how to find all the variables in a Prolog clause; I keep meaning to adapt that to Erlang) is something that will make it HARDER to write working programs. > > None of these are large changes - but they would make Erlang a > nicer language > to program in. The (regexp "....") would be extremely useful to the > compiler > and allow generating efficient regexp matching code :-) I'm teaching a 4th year functional programming paper. (Haskell, sorry. Not Erlang.) There is a programming language for Lego robots called Not Quite C. The third assignment for the functional programming students is to write a program that reads NQC programs and reports on which global variables are used and set by which tasks. In order to make this a reasonable assignment, I have provided the students with - a lexical analyser - an abstract syntax tree - a parser which constructs ASTs - some functions for enumerating things in ASTs The lexical structure of NQC is very close to C. The lexical analyser in Haskell was 190 SLOC, for 69 token types. That's 2.75 SLOC per token type. One of those lines is the declaration of the token kind (equivalent to a %token declaration in Yacc/Lex) and I could have packed more on a line if I wanted. Another line is the one that reports what kind of token has been bound. Given my layout style, the minimum imaginable cost is 2.00 SLOC per token type. Some of the overhead is due to writing for clarity. With a bit of effort, I just got the SLOC count down to 107, or 1.55 SLOC per token type. (Fair enough to pack the token declarations together because in Erlang, Lisp, or Prolog there wouldn't be any.) All in all, as I pointed out to the students, if you want to tokenise a language similar to C and have a decent functional language, who the heck NEEDS lex, or regular expressions? Oddly enough, if you want a lexical analyser for Haskell, it's easy enough to do in Haskell, but you CAN'T do it with regular expressions! So I simply do not believe that some vaguely described 'regexp "..."' syntax would make compiler writing easier. One thing we can be sure of is that it would make the writing of Erlang processing tools HARDER. From ok@REDACTED Wed May 23 02:04:45 2007 From: ok@REDACTED (ok) Date: Wed, 23 May 2007 12:04:45 +1200 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> Message-ID: On 21 May 2007, at 10:24 pm, Joe Armstrong wrote: No - it changes the *syntax* of a string - normally you have to quote backspashes Suppose I had a *simple* regexp like this: [.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]* I'd like to say X = regexp "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*" and not the more obvious X = "[.?!][]\\"')}]*\\\\($\\\\| $\\\\|\t\\\\| \\\\)[ \\t\\n]*" Let's look at this in two different ways. First, let's break the regexp up: [.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]* AAAAABBBBBBBBBCC(IJJ| KLL|MMOO|RSTT)UUUUUUUU Note that regular expression syntax has weird quoting of its own. (One reason I want to write regexps in Erlang AS Erlang!) It looks as though [].... starts with an empty set, but in fact the right bracket is an element of the set. It looks as though there are lots of backslashes, but (CC,JJ,LL,OO,TT), but on close inspection (how HARD this is to read!) this appears to presuppose a regular expression syntax in which the special meaning of (|) has to be turned ON with backslashes, instead of the usual syntax where backslashes turn the special meaning OFF. (Just more reason NOT to want this construction. Which of the many regular expression syntaxes do we actually get?) Not only that, instead of \( \| \) we find doubled backslashes! I don't know any regexp syntax that requires \\(...\\|...\\) for an alternation, and if I did, I would not want to use it. So here's how I would like to write that: X = seq(any(".?!"), span("\"')]}"), alt("\n", "\t", seq(" ",any(" \t\n"))), span(" \t\n")) This is BETTER than fancy regexp syntax, because it's just normal Erlang syntax that can include *any* computations we find useful. For example, Stops = ".?!", Closers = "\"')]}", BigSpace = "\t\n", Space = " "++BigSpace, X = seq(any(Stops),span(Closers), alt(any(BigSpace),seq(" ",any(Space)), span(Space)) Second, suppose for some reason we don't like function calls, and we do like regular expression syntax, with all the backslashes *that* requires. Let me introduce you to the idea of a preprocessor. Our input syntax will be // on one line by itself, possibly followed by a comma or semicolon, possibly followed by a comment. We want to replace this by regexp:compile("") where is with appropriate backslashes added, putting the comma or semicolon back if there was one. What do we need to quote? - double quotes - backslashes Here we go. #!/bin/awk -f $0 ~ /^[ \t]*\/.*\/[,;]?[ \t]*(%.*)?$/ { x = $0 match(x, /^[ \t]*\//) head = substr(x, 1, RLENGTH-1) x = substr(x, RLENGTH+1) sub(/[ \t]*(%.*)?$/, "", x) if (x ~ /[,;]$/) { tail = substr(x, length(x), 1) x = substr(x, 1, length(x) - 1) } else { tail = "" } sub(/\/$/, "", x) gsub(/["\\]/, "\\\\&", x) print head "regexp:compile(\"" x "\")" tail next } { print } I have tested this on some small examples and it seems to work. It took some doing, precisely because regular expression syntax is so hard to work with, compared with normal Erlang syntax. This preprocessor is just 16 SLOC of AWK. For *THIS* we are to make Erlang lexical structure more complicated and to break editor support for the language? From ok@REDACTED Wed May 23 02:13:46 2007 From: ok@REDACTED (ok) Date: Wed, 23 May 2007 12:13:46 +1200 Subject: [erlang-questions] escript questions In-Reply-To: References: <200705180304.06885.als@iinet.net.au> Message-ID: <51A72600-A64F-4BA8-877F-FC094935FCCD@cs.otago.ac.nz> >> How do I write to stderr from a script? Open an output stream to the Unix command 'cat 1>&2'. From darius@REDACTED Wed May 23 02:10:46 2007 From: darius@REDACTED (Darius Bacon) Date: Tue, 22 May 2007 17:10:46 -0700 (PDT) Subject: [erlang-questions] some language changes In-Reply-To: (message from ok on Wed, 23 May 2007 12:04:45 +1200) References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> Message-ID: <200705230010.l4N0Ak5j044241@shell.accesscom.com> ok wrote: > So here's how I would like to write that: > > X = seq(any(".?!"), span("\"')]}"), > alt("\n", "\t", seq(" ",any(" \t\n"))), > span(" \t\n")) I would, too -- the regexp code I posted the other day exported constructor functions along these lines (even named seq and alt), with the regexp syntax exiled to a separate parser module. It'd be nice if the standard regexp module did this. Darius From ok@REDACTED Wed May 23 02:48:56 2007 From: ok@REDACTED (ok) Date: Wed, 23 May 2007 12:48:56 +1200 Subject: [erlang-questions] some language changes In-Reply-To: <8f4efcb10705211858r19f6a843oabf79c473e1f35f@mail.gmail.com> References: <8f4efcb10705211858r19f6a843oabf79c473e1f35f@mail.gmail.com> Message-ID: <2A82746E-0CC8-4035-A292-113098686EAD@cs.otago.ac.nz> About ' "", including 'subst', On 22 May 2007, at 1:58 pm, Vladislav Titov wrote: > These two sound like they'd be perfectly matched by something like > CL's reader macro concept. The problem with read-macros is that they tie the *syntax* of the programming language to *user-defined* functions in the *same* language. As a result, it is technically impossible to write a program (such as a helpful editor!) which can decipher Common Lisp source files without providing a full implementation of Common Lisp. You can't even lexically analyse Common Lisp without *being* Common Lisp. The only thing that saves Common Lisp in practice is that these days people tend to be very very wary of using this facility. Common uses are - using ? to introduce some kind of logical or pattern variable (or, of course, to provide some degree of compatibility with Emacs Lisp) - defining [...] and/or {...} to do something useful (example in CLtL) One reason they are reluctant to make larger changes is that they would have to abandon editor support. (Not every CL programmer uses an editor written in CL.) Common Lisp read macros are of course far worse than Erlang parse transforms, because (a) you can't even *lex* Common Lisp without being Common Lisp and (b) the (re)definition of a read-macro character may be in the very same file that you are reading. All of this stuff was present in Pop-2 years and years ago. It's easy enough to implement. The problem is what it does to you when you USE it. I suspect that most Pop programmers were delighted to abandon Pop's low-level macrology for the 'forms' facility; I know I was. > This would allow for a range of nice features, from extending the > language with new literal type (:pid <0,1,2>), to some fancy > metaprogramming tricks (:bitcount(X) would turn into element(X, > {0,1,1,2,1,...})). It brings in some of the functionality of CL macros > without all the nasty AST stuff. > This is completely back to front. The "AST stuff" is *far* less trouble to tools than read-level stuff. At least you can *lex* the stuff; at least parenthesis-balancing still works! From jsnx@REDACTED Wed May 23 02:53:34 2007 From: jsnx@REDACTED (Jason Dusek) Date: Tue, 22 May 2007 17:53:34 -0700 Subject: [erlang-questions] Erlang math libraries In-Reply-To: References: <464E5723.8070403@duomark.com> <464F7CD2.8080106@telia.com> <4650D0D4.2070003@duomark.com> <42784f260705221023h41a2281eld6b37c07d1116d99@mail.gmail.com> Message-ID: <42784f260705221753h7dc6a459ta5a038a76f7a02a9@mail.gmail.com> On 5/22/07, Kenneth Lundin wrote: > On 5/22/07, Jason Dusek wrote: > > I see a couple of 'patterns' for developing Fortran-backed Erlang applications: > > > > a) write single machine Fortran 'servers' that talk with an Erlang node > > through a socket connection. That way, you can take full advantage > > of Fortran's multi-processor support without having to deal with it's > > approach to concurrency/parallelization. The Erlang node on the > > server is responsible for restarting the Fortran app as needed, as > > well as feeding it work and data. > > > > b) write Fortran math libraries and work out a solid FFI for Fortran stuff. > > I personally think of this as the ugly way, although it does protect one > > from the data replication and complicated request translation that might > > result from (a). > > What about the FFI?, I agree that the linked in driver interface (C) or the > Erl_interface (C over socket) or the Jinterface (Java over socket) are > not the easiest to use or program for. These are complicated and they don't hook to Fortran. What is the best way to handle communication with an independent process, following the Fortran server pattern I outlined above? Is that just a bad idea? The thing I like about an independent Fortran server approach is a) independence from Erlang -- I can test and run the Fortran by itself b) repeatable, generic technique -- I can use this technique later for Erlang & C, Erlang & Ruby, &c. > > I'm interested in developing distributed game engines with Erlang. As > > things stand now, numerical performance in Erlang is not a strong > > selling point... > > I don't really understand why you think you need more numerical performance > than Erlang can handle for a distributed game engine. Basically, game engines as a rule need as much numerical performance as you can get. Of course, there are some game engines that are pretty light on that stuff -- distributed gaming used to be a pretty much 2d affair -- but it's not that way any more. I need an engine that will handle all the collision detection, fluid dynamics and rigid body dynamics of the whole world, at once. So high numerical performance, and good multi-processor support, is an absolute must. For the term 'game engine' you may substitute 'flight simulator'. > ...a generic FFI like you have for other languages where you can > call almost any function residing in a shared library is not suitable > for Erlang since we have to think about concurrency and overall > performance as well. A call to a foreign language function might > take a long time before it returns and during that time the whole > Erlang VM must not block. To be sure that this does not happen > each call which potentially can execute for a long time must be > run in a separate thread. Thanks for explaining that. -- _jsn From bengt.kleberg@REDACTED Wed May 23 09:00:44 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 23 May 2007 09:00:44 +0200 Subject: [erlang-questions] escript questions In-Reply-To: <51A72600-A64F-4BA8-877F-FC094935FCCD@cs.otago.ac.nz> References: <200705180304.06885.als@iinet.net.au> <51A72600-A64F-4BA8-877F-FC094935FCCD@cs.otago.ac.nz> Message-ID: <4653E69C.7040609@ericsson.com> On 2007-05-23 02:13, ok wrote: >>> How do I write to stderr from a script? > > Open an output stream to the Unix command 'cat 1>&2'. note that this mean that _everything_ written to stdout goes to stderr. if you want to write to both stdout and stderr you have to wait for a new OTP. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From vladdu55@REDACTED Wed May 23 10:01:29 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 23 May 2007 10:01:29 +0200 Subject: [erlang-questions] some language changes In-Reply-To: References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> Message-ID: <95be1d3b0705230101i207f6adt7d39e31cf67bc074@mail.gmail.com> Hi, On 5/23/07, ok wrote: > This preprocessor is just 16 SLOC of AWK. For *THIS* we are to > make Erlang lexical structure more complicated and to break editor > support for the language? Cold you please elaborate on why a preprocessor doesn't break the editor support for the language? The way I see it is that if the said editor is to provide advanced support, it needs to be able to work with the textual raw representation, not the preprocessed one, because that is the one the developer sees and uses. For example, I might be interested in renaming a normal -define() macro and get all uses replaced with the new name. This means that the lexer and parser used by the editor need to include the concept of a macro. At the same time, the editor needs to be able to map back the final AST to the actual concrete syntax, for example in order to map compile errors to the right place in the code even if that code contains macros and parse transforms. [*] So IMHO if the language is extended in any way, via preprocessor or not, the editor still needs to be updated if it is going to be able to understand the changes. [*] the difficulty of this backward mapping is also one reasonfor which line numbers in errors wouldn't be meaningful in the general case. best regards, Vlad From tobbe@REDACTED Wed May 23 10:33:29 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 23 May 2007 10:33:29 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <200705230010.l4N0Ak5j044241@shell.accesscom.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> <200705230010.l4N0Ak5j044241@shell.accesscom.com> Message-ID: Darius Bacon wrote: > ok wrote: >> So here's how I would like to write that: >> >> X = seq(any(".?!"), span("\"')]}"), >> alt("\n", "\t", seq(" ",any(" \t\n"))), >> span(" \t\n")) > > I would, too -- the regexp code I posted the other day exported > constructor functions along these lines (even named seq and alt), with > the regexp syntax exiled to a separate parser module. It'd be nice if > the standard regexp module did this. > > Darius Very nice! However, it would be even nicer with some included examples on how to run the code... :-) Let's say I have the following regexp: "^now/(plus|minus)(\d{1,2})hours/$" then: In: "now/plus42hours/" Out: ["plus, "42"] (or something like that) In: "now/plus100hours/" Out: nomatch Can I do it with 'ergex' ? Can I do it with any other of the various regexp modules that are floating around ? Cheers, Tobbe From petter.xa.larsson@REDACTED Wed May 23 10:36:06 2007 From: petter.xa.larsson@REDACTED (Petter Larsson XA (TN/EAB)) Date: Wed, 23 May 2007 10:36:06 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang Message-ID: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> I have a file browser in yaws that I look at erlang code with. I would like to syntax highlight this code. What is the best way to view a erlang source code with syntax highlighting? I can parse the code with functions in Syntax_Tools I guess, but does anyone have any example code for this? BR Petter Larsson From tobbe@REDACTED Wed May 23 10:52:50 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 23 May 2007 10:52:50 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> Message-ID: Petter Larsson XA (TN/EAB) wrote: > I have a file browser in yaws that I look at erlang code with. > I would like to syntax highlight this code. > > What is the best way to view a erlang source code with syntax > highlighting? > I can parse the code with functions in Syntax_Tools I guess, but does > anyone have any example code for this? > > BR > Petter Larsson > Perhaps you could do it with Chili ? Chili is the jQuery code highlighter plugin. http://noteslog.com/chili/ Would be nice if you could post the setup of Chili when you're done... :-) --Tobbe From lenartlad@REDACTED Wed May 23 11:23:48 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 23 May 2007 11:23:48 +0200 Subject: [erlang-questions] [Q] Copying memory between processes Message-ID: <46540824.7030905@volny.cz> Hello, I encountered a very odd problem that I think is related to how a term is copied from sender's heap to the heap of the receiver... I have a "complex" data structure Structure = [{Key, Item}] Item = term that among other things references all items that are in Structure before it. During the construction of this structure (in one process) memory allocated by the whole Erlang runtime is about 15MB, because all the items are shared. But as soon as this structure is sent to one other process the system is suddenly out of resources. The only reason this could happen (that I could think of) is: When the structure is copied to the heap of the other process, the identity is not preserved, that is each item references its own list of previous items (though equal). This would explain expontential growth of the memory. Am I right? And if it so, what is the reason (performance)? Thanks, Ladislav Lenart From bjorn@REDACTED Wed May 23 11:34:52 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 23 May 2007 11:34:52 +0200 Subject: [erlang-questions] [Q] Copying memory between processes In-Reply-To: <46540824.7030905@volny.cz> References: <46540824.7030905@volny.cz> Message-ID: Ladislav Lenart writes: > > But as soon as this structure is sent to one other process > the system is suddenly out of resources. The only reason > this could happen (that I could think of) is: When the > structure is copied to the heap of the other process, the > identity is not preserved, that is each item references its > own list of previous items (though equal). This would explain > expontential growth of the memory. Yes. > Am I right? And if it so, what is the reason (performance)? Yes. In typical applications, shared data structures are uncommon. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From petter.xa.larsson@REDACTED Wed May 23 11:56:01 2007 From: petter.xa.larsson@REDACTED (Petter Larsson XA (TN/EAB)) Date: Wed, 23 May 2007 11:56:01 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> Message-ID: <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> I would actually prefer doing it in erlang code, soo I can create links fo other filer etc. when possible. Doesn't anyone have an example code of highligting erlang code with erl_syntax etc. /Petter > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Torbjorn Tornkvist > Sent: den 23 maj 2007 10:53 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Syntax highlight erlang code > with erlang > > Petter Larsson XA (TN/EAB) wrote: > > I have a file browser in yaws that I look at erlang code with. > > I would like to syntax highlight this code. > > > > What is the best way to view a erlang source code with syntax > > highlighting? > > I can parse the code with functions in Syntax_Tools I > guess, but does > > anyone have any example code for this? > > > > BR > > Petter Larsson > > > > Perhaps you could do it with Chili ? > Chili is the jQuery code highlighter plugin. > > http://noteslog.com/chili/ > > Would be nice if you could post the setup of Chili when > you're done... :-) > > --Tobbe > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Wed May 23 12:32:06 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 23 May 2007 12:32:06 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> Message-ID: <46541826.30804@it.uu.se> Petter Larsson XA (TN/EAB) wrote: > I would actually prefer doing it in erlang code, soo I can create links > fo other filer etc. when possible. > > Doesn't anyone have an example code of highligting erlang code with > erl_syntax etc. I don't have any example code at hand, but you can do it fairly easily, the following way: 1. Traverse the syntax tree (use erl_syntax:subtrees/1) and add annotations (erl_syntax:add_ann/2) on nodes of interest. 2. Use erl_prettypr:format/2 and pass it a hook function that adds additional markup depending on the annotation. (See the documentation for a trivial example.) You might be able to put all the functionality directly in the hook, but it's cleaner to separate the analysis and format phases like above. (I've mainly used this to visualize the results of data flow analyses, which typically just involved colouring certain subexpressions red. If you write a larger example that could be useful for the general public, it would be nice if you posted it here.) /Richard From andrew@REDACTED Wed May 23 13:18:57 2007 From: andrew@REDACTED (andrew cooke) Date: Wed, 23 May 2007 07:18:57 -0400 (CLT) Subject: [erlang-questions] some language changes In-Reply-To: References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <200705212007.09584.als@iinet.net.au> <9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com> <200705230010.l4N0Ak5j044241@shell.accesscom.com> Message-ID: <19284.200.120.169.16.1179919137.squirrel@acooke.dyndns.org> any combinator library (not sure from the context if this is what you are referring to or not - i would expect a regexp library to compile state machines and so be more efficient than a typical combinator lib) should be able to do this - here's the equivalent based on code at https://acooke.dyndns.org:4443/repos/default/src/erlang/lib/trunk/ test_torbjorn() -> io:fwrite("torbjorn~n"), T = either(string("now"), all_([either(string("plus"), string("minus")), all_([digit(), optional(digit())]), ignore(string("hours"))])), assert_equals({ok, ["plus", "42"], ""}, T("plus42hours")), assert_equals({fail, equal}, T("plus100hours")). i wouldn't suggest people use this code (i change it regularly and it has no documentation!), but if this is unusual and useful i can make something more "polished". andrew ps the "_" in "all_" implies string list contents are concatenated rather than appended (so the "words" remain separate; digit() matches characters not strings). > Darius Bacon wrote: >> ok wrote: >>> So here's how I would like to write that: >>> >>> X = seq(any(".?!"), span("\"')]}"), >>> alt("\n", "\t", seq(" ",any(" \t\n"))), >>> span(" \t\n")) >> >> I would, too -- the regexp code I posted the other day exported >> constructor functions along these lines (even named seq and alt), with >> the regexp syntax exiled to a separate parser module. It'd be nice if >> the standard regexp module did this. >> >> Darius > > Very nice! > However, it would be even nicer with some included examples on how to > run the code... :-) > > Let's say I have the following regexp: > > "^now/(plus|minus)(\d{1,2})hours/$" > > then: > > In: "now/plus42hours/" > Out: ["plus, "42"] (or something like that) > > In: "now/plus100hours/" > Out: nomatch > > Can I do it with 'ergex' ? > Can I do it with any other of the various regexp modules that are > floating around ? > > Cheers, Tobbe > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From petter.xa.larsson@REDACTED Wed May 23 13:41:54 2007 From: petter.xa.larsson@REDACTED (Petter Larsson XA (TN/EAB)) Date: Wed, 23 May 2007 13:41:54 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: <46541826.30804@it.uu.se> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> <46541826.30804@it.uu.se> Message-ID: <00E47B21F2156640838B288A86560DB6020BA597@esealmw107.eemea.ericsson.se> > Petter Larsson XA (TN/EAB) wrote: > > I would actually prefer doing it in erlang code, soo I can create > > links fo other filer etc. when possible. > > > > Doesn't anyone have an example code of highligting erlang code with > > erl_syntax etc. > > I don't have any example code at hand, but you can do it > fairly easily, the following way: > > 1. Traverse the syntax tree (use erl_syntax:subtrees/1) and add > annotations (erl_syntax:add_ann/2) on nodes of interest. How do I get this syntax tree in the first place, if I use epp_dogder:parse_file all comments in the file is lost. What is the correct function to create a full syntax tree from a source code? /Petter From als@REDACTED Wed May 23 13:48:31 2007 From: als@REDACTED (Anthony Shipman) Date: Wed, 23 May 2007 21:48:31 +1000 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <200705232148.31635.als@iinet.net.au> On Monday 21 May 2007 18:10, Joe Armstrong wrote: > Now the book is done I've been thinking about some language changes. > How about a straightforward if then else end expression? The condition would allow any boolean expression. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From lestat@REDACTED Wed May 23 14:09:57 2007 From: lestat@REDACTED (Tamas Nagy) Date: Wed, 23 May 2007 14:09:57 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: <00E47B21F2156640838B288A86560DB6020BA597@esealmw107.eemea.ericsson.se> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> <46541826.30804@it.uu.se> <00E47B21F2156640838B288A86560DB6020BA597@esealmw107.eemea.ericsson.se> Message-ID: <1179922197.29556.21.camel@linux-box> On Wed, 2007-05-23 at 13:41 +0200, Petter Larsson XA (TN/EAB) wrote: > > Petter Larsson XA (TN/EAB) wrote: > > > I would actually prefer doing it in erlang code, soo I can create > > > links fo other filer etc. when possible. > > > > > > Doesn't anyone have an example code of highligting erlang code with > > > erl_syntax etc. > > > > I don't have any example code at hand, but you can do it > > fairly easily, the following way: > > > > 1. Traverse the syntax tree (use erl_syntax:subtrees/1) and add > > annotations (erl_syntax:add_ann/2) on nodes of interest. > > How do I get this syntax tree in the first place, if I use > epp_dogder:parse_file all comments in the file is lost. What is the > correct function to create a full syntax tree from a source code? {ok, Form1} = epp_dodger:parse_file(File), Comments = erl_comment_scan:file(File), Form2 = erl_recomment:recomment_forms(Form1, Comments), Form3 = erl_syntax:flatten_form_list(Form2) And in Form3 you get the whole AST with comments. There are seperate comment nodes, and comment nodes attached to other nodes (pre- and postcomments) %%This will be a seperate comment %%This will be a precomment of the function node f()-> 3. %%This will be a postcomment of the function node. %%This will be another separate comment. Tamas > > /Petter > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Wed May 23 14:17:14 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 23 May 2007 14:17:14 +0200 Subject: [erlang-questions] Syntax highlight erlang code with erlang In-Reply-To: <00E47B21F2156640838B288A86560DB6020BA597@esealmw107.eemea.ericsson.se> References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se> <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se> <46541826.30804@it.uu.se> <00E47B21F2156640838B288A86560DB6020BA597@esealmw107.eemea.ericsson.se> Message-ID: <465430CA.1050606@it.uu.se> Petter Larsson XA (TN/EAB) wrote: > How do I get this syntax tree in the first place, if I use > epp_dogder:parse_file all comments in the file is lost. What is the > correct function to create a full syntax tree from a source code? Something like this (from lib/syntax_tools/examples/demo.erl): read(Name) -> {ok, Forms} = epp:parse_file(Name, [], []), Comments = erl_comment_scan:file(Name), erl_recomment:recomment_forms(Forms, Comments). /Richard From dizzyd@REDACTED Wed May 23 14:29:03 2007 From: dizzyd@REDACTED (Dave Smith) Date: Wed, 23 May 2007 06:29:03 -0600 Subject: [erlang-questions] Environment variables in sasl.config Message-ID: Greetings, I've been working through Joe Armstrong's book -- nice work, Joe! One thing that I'm trying to sort out is how avoid hard coding paths into my sasl.config. I want my log files to be output to a directory, as defined by an environment variable in the script that starts up my erlang application. Unfortunately, it seems that only erlang terms can be used in sasl.config, not functions (such as os:getenv/1). Is there something I'm missing here? Thanks, D. From mberrow1@REDACTED Wed May 23 16:20:56 2007 From: mberrow1@REDACTED (Mike Berrow) Date: Wed, 23 May 2007 07:20:56 -0700 Subject: [erlang-questions] some language changes References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> Message-ID: <004001c79d45$9b05c7a0$6401a8c0@rubicon> ok wrote: > On 21 May 2007, at 8:10 pm, Joe Armstrong wrote: >> 1. What you type in the shell and what you type in a module/escript >> should be the same > ... > This has never been the case in Smalltalk, and nobody seems to > notice any problem. > ... I've used Smalltalk and I've been making a living programming in Ruby for the last 18 months. Now that you point that out, it is one of the large advantages that Ruby has over Smalltalk w.r.t experimentation / prototyping / learning curve > It has never been the case in Prolog. > .... Is Erlang tied to Prolog in this? If not, why does that matter? > And that's a really important point. Joe is suggesting that > the Erlang shell should be changed to make it easier for beginners > to shoot themselves in the foot, instead of learning practices that > will help to keep them out of trouble. I cannot think that a good idea. I've found the transparency between the interactive shell and source environments in Ruby to be nothing but a huge boost in productivity. I've never had this "shooting myself in the foot" effect because of it. If there is something intrinsically different about the Erlang world that makes it dangerous, I would appreciate it if you could elaborate. Thanks much, -- Mike Berrow From ulf.wiger@REDACTED Wed May 23 16:39:08 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 23 May 2007 16:39:08 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <004001c79d45$9b05c7a0$6401a8c0@rubicon> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> <004001c79d45$9b05c7a0$6401a8c0@rubicon> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> I started playing with the idea of being able to define modules pretty much the same way as records are handled in the shell. For example: 1> md(" -module(foo). ... plus(A,B) -> A+B. "). {module, foo} 2> foo:plus(1,2). 3 But a few stumbling blocks made me abort the effort (that, and my bus ride ended, and I had to hop onto my bike - I've yet to learn how to program while riding a mountain bike). One problem is that epp is not willing to take just a stream of bytes (this has been discussed before on this list), but desperately wants to read a regular file. Another problem is that the shell is decidedly line-oriented, so it doesn't look like I sketched above, but rather: 1> md(" 1> -module(foo). 1> ... And you cannot move the cursor up a line, making it cumbersome to edit the code in this mode. It may still be worth it, though. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Mike Berrow > Sent: den 23 maj 2007 16:21 > To: Erlang (E-mail) > Subject: Re: [erlang-questions] some language changes > > ok wrote: > > On 21 May 2007, at 8:10 pm, Joe Armstrong wrote: > >> 1. What you type in the shell and what you type in a > module/escript > >> should be the same > > ... > > This has never been the case in Smalltalk, and nobody seems > to notice > > any problem. > > ... > > I've used Smalltalk and I've been making a living programming > in Ruby for the last 18 months. Now that you point that out, > it is one of the large advantages that Ruby has over > Smalltalk w.r.t experimentation / prototyping / learning curve > > > It has never been the case in Prolog. > > .... > Is Erlang tied to Prolog in this? If not, why does that matter? > > > And that's a really important point. Joe is suggesting that the > > Erlang shell should be changed to make it easier for beginners to > > shoot themselves in the foot, instead of learning practices > that will > > help to keep them out of trouble. I cannot think that a good idea. > > I've found the transparency between the interactive shell and > source environments in Ruby to be nothing but a huge boost in > productivity. > I've never had this "shooting myself in the foot" effect > because of it. > If there is something intrinsically different about the > Erlang world that makes it dangerous, I would appreciate it > if you could elaborate. > > Thanks much, > -- Mike Berrow > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jim.menard@REDACTED Wed May 23 16:47:50 2007 From: jim.menard@REDACTED (Jim Menard) Date: Wed, 23 May 2007 10:47:50 -0400 Subject: [erlang-questions] Blog: a MIDI file reader/writer Message-ID: I've posted "An Erlang MIDI File Reader/Writer" (http://jimmenard.blogspot.com/2007/05/erlang-midi-file-readerwriter.html). It's one of a few posts I plan to write about my adventures into Erlang. Comments on the code would be greatly appreciated. I know I have a lot to learn. Jim -- Jim Menard, jimm@REDACTED, jim.menard@REDACTED http://www.io.com/~jimm/ From bengt.kleberg@REDACTED Wed May 23 17:47:26 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 23 May 2007 17:47:26 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> <004001c79d45$9b05c7a0$6401a8c0@rubicon> <6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> Message-ID: <4654620E.40704@ericsson.com> On 2007-05-23 16:39, Ulf Wiger (TN/EAB) wrote: ...deleted > One problem is that epp is not willing to take > just a stream of bytes (this has been discussed > before on this list), but desperately wants to > read a regular file. if epp (and others that desperately want a file) also handled an IO object (as returned from file:open/2) the problem would go away. i would expect epp to use file:open/2 on the file and then the IO object in the rest of the code so the change would not be great. unless epp does a file:read_file/1 to get all of the file into memory, of course. then epp should be able to handle a binary instead of a file with out any great change. bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From hal@REDACTED Wed May 23 17:58:04 2007 From: hal@REDACTED (Hal Snyder) Date: Wed, 23 May 2007 10:58:04 -0500 Subject: [erlang-questions] WHOLETABLE lock on schema Message-ID: I am seeing a stuck lock on the schema of a mnesia database. I'm not sure how it's happening yet. We run two nodes with disc_copies of the schema and several more with ram_copies of it, but I think all the nodes in question are listed in running_db_nodes. Here is another way to create the lock. I don't think this is what is happening to the problem system above, but it would be nice to know if there is a good way to resolve the general problem without downtime: N='some_fictional_node@REDACTED'. mnesia:add_table_copy(schema, N, ram_copies). mnesia:change_table_copy_type(schema, N, disc_copies). mnesia:change_table_copy_type(schema, N, ram_copies). -- at this point, erlang shell does not come back -- you can interrupt it or remote in, though Last line could probably be anything that wants to lock the schema. For example, mnesia:create_table(baz,[]). does the same thing. If you remote in from another node, you can do mnesia:system_info(held_locks). and you will see something like this: [{{schema,'______WHOLETABLE_____'},write,{tid,5,<4163.81.0>}}] From per@REDACTED Wed May 23 19:53:05 2007 From: per@REDACTED (Per Hedeland) Date: Wed, 23 May 2007 19:53:05 +0200 (CEST) Subject: [erlang-questions] escript questions In-Reply-To: <4653E69C.7040609@ericsson.com> Message-ID: <200705231753.l4NHr5wb040368@pluto.hedeland.org> Bengt Kleberg wrote: > >On 2007-05-23 02:13, ok wrote: >>>> How do I write to stderr from a script? >> >> Open an output stream to the Unix command 'cat 1>&2'. > >note that this mean that _everything_ written to stdout goes to stderr. Hm? I'm not 100% sure what Richard means by "Open an output stream", but I would guess it's something like open_port({spawn, "cat 1>&2"}, [out]), in which case only the data sent to that port goes to stderr, of course. >if you want to write to both stdout and stderr you have to wait for a >new OTP. No, it's seems we now have at least two ways to do it, as I posted a slightly different one (more efficient:-) two days ago. For some value of "write", that is - AFAIK there's no readily available way to create an io_device() from such a "stupid" port. --Per Hedeland From als@REDACTED Wed May 23 20:04:55 2007 From: als@REDACTED (Anthony Shipman) Date: Thu, 24 May 2007 04:04:55 +1000 Subject: [erlang-questions] some language changes In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> Message-ID: <200705240404.55145.als@iinet.net.au> On Monday 21 May 2007 18:10, Joe Armstrong wrote: > Now the book is done I've been thinking about some language changes. > How about allowing a semicolon after the last clause in a case or if expression or similar: case E of A -> ...; B -> ...; end Allowing a comma after the last member of a list too would be helpful. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From fritchie@REDACTED Wed May 23 20:26:41 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 23 May 2007 13:26:41 -0500 Subject: [erlang-questions] Environment variables in sasl.config In-Reply-To: Message of "Wed, 23 May 2007 06:29:03 MDT." Message-ID: <200705231826.l4NIQfT6001421@snookles.snookles.com> >>>>> "ds" == Dave Smith writes: ds> Unfortunately, it ds> seems that only erlang terms can be used in sasl.config, not ds> functions (such as os:getenv/1). Is there something I'm missing ds> here? I've faced the same problem and came up with a naive solution: use awk/sed/Tcl/Perl to mangle a .config.template file after a startup shell script starts but before starting the Erlang VM ... creating the .config file. It's ugly but at least it's straightforward and has a long-if-not-quite-noble history in the UNIX world. I'm not aware of any OTP'ish thing to avoid it ... but my knowledge of OTP's nooks and crannies isn't as thorough as it ought to be. -Scott %% This template is edited to become the FILE for "erl -config FILE". %% The "__FOO__" patterns are replaced via regexps. [ {kernel, [{distributed, [{my_active_standby_server, 3000, [{__NODELIST__}]}]}, {sync_nodes_mandatory, []}, {sync_nodes_optional, [__NODELIST_MINUS_ME__]}, {sync_nodes_timeout, 2000} ] } ] From ulf.wiger@REDACTED Wed May 23 22:07:32 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 23 May 2007 22:07:32 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <4654620E.40704@ericsson.com> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> <004001c79d45$9b05c7a0$6401a8c0@rubicon><6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> <4654620E.40704@ericsson.com> Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se> The problem is (1) that epp explicitly calls file:open(), and has no function that just accepts a file descriptor, and (2) that epp uses the io subsystem, which requires file_io_server, which only works on regular files. This has been discussed in an earlier thread, and various workarounds have been presented. Mine was to make a ram_file_io_server, which I thought was trivially easy (after some study of the file IO system). BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Bengt Kleberg > Sent: den 23 maj 2007 17:47 > To: Erlang (E-mail) > Subject: Re: [erlang-questions] some language changes > > On 2007-05-23 16:39, Ulf Wiger (TN/EAB) wrote: > ...deleted > > One problem is that epp is not willing to take just a > stream of bytes > > (this has been discussed before on this list), but > desperately wants > > to read a regular file. > > if epp (and others that desperately want a file) also handled > an IO object (as returned from file:open/2) the problem would > go away. i would expect epp to use file:open/2 on the file > and then the IO object in the rest of the code so the change > would not be great. > > unless epp does a file:read_file/1 to get all of the file > into memory, of course. then epp should be able to handle a > binary instead of a file with out any great change. > > > bengt > -- > Those were the days... > EPO guidelines 1978: "If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Wed May 23 22:38:28 2007 From: chsu79@REDACTED (Christian S) Date: Wed, 23 May 2007 22:38:28 +0200 Subject: [erlang-questions] some language changes In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com> <987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz> <004001c79d45$9b05c7a0$6401a8c0@rubicon> <6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se> Message-ID: On 5/23/07, Ulf Wiger (TN/EAB) wrote: > 1> md(" > -module(foo). > ... > plus(A,B) -> A+B. > "). > {module, foo} Isnt this horribly annoying when you have string litterals in the module you are defining? How about following the idea from unix shells: cat < -module(foo). >-export([plus/2]). > >plus(A, B) -> A + B. > >foo. {ok, foo} 2> (Not a "screenshot", just mockup.) It would make it easier to put some example code in
 that
the newbie can
cut'n'paste into the erl they just installed with apt-get install
erlang. And then have them start using the fresly defined module.

For symmetry the compiler would probably want to ignore an atom and
'.' so there wont be a problem that modules that work in the shell are
refused when compiling them from .erl files.
:)


From hal@REDACTED  Wed May 23 23:23:34 2007
From: hal@REDACTED (Hal Snyder)
Date: Wed, 23 May 2007 16:23:34 -0500
Subject: [erlang-questions] WHOLETABLE lock on schema
In-Reply-To: 
References: 
Message-ID: <84BB42DE-ED9A-46D1-85BF-F323394AE7CB@vailsys.com>

Follow-up to previous post:

I see the same problem in R-11B and R-9C, the two releases we are  
running here. In both cases, I wonder if the problem is not the  
following:

mnesia_locker.erl / receive_wlocks sits in a receive and can wait  
forever if one of the nodes passed in its first argument is not  
running. The following seems to make the problem go away .... but I'm  
sure I know just enough to be dangerous:

receive_wlocks([Node | Tail], Res, Store, Oid) ->
     receive
         {?MODULE, Node, granted} ->
             del_debug(Node),
             receive_wlocks(Tail, Res, Store, Oid);
...
+   after WlockTimeoutMsec ->
+           del_debug(Node),
+           Reason1 = {aborted, {node_timed_out, Node}},
+           flush_remaining(Tail, Node, Reason1)
     end;


On May 23, 2007, at 10:58 AM, Hal Snyder wrote:

> I am seeing a stuck lock on the schema of a mnesia database. I'm  
> not sure how it's happening yet. We run two nodes with disc_copies  
> of the schema and several more with ram_copies of it, but I think  
> all the nodes in question are listed in running_db_nodes.
>
> Here is another way to create the lock. I don't think this is what  
> is happening to the problem system above, but it would be nice to  
> know if there is a good way to resolve the general problem without  
> downtime:
>
> N='some_fictional_node@REDACTED'.
> mnesia:add_table_copy(schema, N, ram_copies).
> mnesia:change_table_copy_type(schema, N, disc_copies).
> mnesia:change_table_copy_type(schema, N, ram_copies).
> -- at this point, erlang shell does not come back
> -- you can interrupt it or remote in, though
>
> Last line could probably be anything that wants to lock the schema.  
> For example,
>   mnesia:create_table(baz,[]).
> does the same thing.
>
> If you remote in from another node, you can do
>   mnesia:system_info(held_locks).
> and you will see something like this:
>   [{{schema,'______WHOLETABLE_____'},write,{tid,5,<4163.81.0>}}]
>



From darius@REDACTED  Thu May 24 01:00:53 2007
From: darius@REDACTED (Darius Bacon)
Date: Wed, 23 May 2007 16:00:53 -0700 (PDT)
Subject: [erlang-questions] some language changes
In-Reply-To:  (message from Torbjorn Tornkvist on
	Wed, 23 May 2007 10:33:29 +0200)
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>	<200705212007.09584.als@iinet.net.au>	<9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com>	
	<200705230010.l4N0Ak5j044241@shell.accesscom.com>
	
Message-ID: <200705232300.l4NN0rip095499@shell.accesscom.com>

Torbjorn Tornkvist  wrote:
> Very nice!
> However, it would be even nicer with some included examples on how to
> run the code... :-)
> 
> Let's say I have the following regexp:
> 
>  "^now/(plus|minus)(\d{1,2})hours/$"
> 
> then:
> 
>  In: "now/plus42hours/"
>  Out: ["plus, "42"]        (or something like that)
> 
>  In: "now/plus100hours/"
>  Out: nomatch
> 
> Can I do it with 'ergex' ?

No, that doesn't record submatches -- it was just an evening hack to
tackle a fun problem from Luke. Expanding it into a supported library
would be a waste of effort. However, I've read regexp.erl now and
could write some patches for it, if they're wanted. (I'm hesitating
because they would change the result of the parse function into a
different representation of the same regular expression -- is keeping
this undocumented-but-exposed data structure the same more important
than fixing matching to always terminate? Of course you could keep it
unchanged but run a prepass just before matching -- yucko.)

> Can I do it with any other of the various regexp modules that are
> floating around ?

The gregexp module in jungerl looks like it's the stdlib regexp plus
submatches.

Darius


From ok@REDACTED  Thu May 24 01:27:07 2007
From: ok@REDACTED (ok)
Date: Thu, 24 May 2007 11:27:07 +1200
Subject: [erlang-questions] escript questions
In-Reply-To: <4653E69C.7040609@ericsson.com>
References: <200705180304.06885.als@iinet.net.au>	
	<51A72600-A64F-4BA8-877F-FC094935FCCD@cs.otago.ac.nz>
	<4653E69C.7040609@ericsson.com>
Message-ID: <9A42B1D1-6A3B-4817-B886-D32279993E65@cs.otago.ac.nz>

Someone asked "How do I write to stderr from a script?"
I replied "Open an output stream to the Unix command 'cat 1>&2'.

On 23 May 2007, at 7:00 pm, Bengt Kleberg wrote:
> note that this mean that _everything_ written to stdout goes to  
> stderr.

No it doesn't.  Output written to THAT STREAM ONLY will be forwarded
to stderr; output written to Erlang's own stdout will be entirely
unaffected.

What I'm talking about is this:

     P = open_port({spawn,'cat 1>&2'}, [out,use_stdio,{line,256}]),
     port_command(P, "Error Message.\n")

Come to think of it, there is also

     Q = open_port({fd,0,2}, [out,{line,256}],
     port_command(Q, "xyzzy\n")




From ok@REDACTED  Thu May 24 02:59:03 2007
From: ok@REDACTED (ok)
Date: Thu, 24 May 2007 12:59:03 +1200
Subject: [erlang-questions] some language changes
In-Reply-To: <95be1d3b0705230101i207f6adt7d39e31cf67bc074@mail.gmail.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<200705212007.09584.als@iinet.net.au>
	<9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com>
	
	<95be1d3b0705230101i207f6adt7d39e31cf67bc074@mail.gmail.com>
Message-ID: <5A4BD7B7-CFEB-4723-B589-C2A340110F06@cs.otago.ac.nz>

On 23 May 2007, at 8:01 pm, Vlad Dumitrescu wrote:

> Hi,
>
> On 5/23/07, ok  wrote:
>> This preprocessor is just 16 SLOC of AWK.  For *THIS* we are to
>> make Erlang lexical structure more complicated and to break editor
>> support for the language?
>
> Cold you please elaborate on why a preprocessor doesn't break the
> editor support for the language?

It's a fair question, and the answer of course is that it does, BUT.
This applies to any preprocessor and any language.  Once you add your
own stuff to bend the rules, the editor cannot rely on the rules
being bent.

BUT!  This only applies to source files that use the preprocessor.
You don't HAVE to use the preprocessor.  You can continue producing
source code without it.  There is *A* language which the editor and
other tools can understand.  And people can still work directly in
that language without THEIR editor support being compromised in any
way.

> The way I see it is that if the said editor is to provide advanced
> support, it needs to be able to work with the textual raw
> representation, not the preprocessed one, because that is the one the
> developer sees and uses.

This argument works for an editor and a pretty printer.  It does not
work for anything else much, including compilers, static checkers,
cross reference programs, you name it.  My home-brew tools for  
grovelling
around in C code include ones that work on the raw source (because it is
their job to report what includes what or what defines what), on the
object code (because it is their job to construct who depends on what
graphs), and on the output of the preprocessor (because it is their job
to check a particular configuration).  There is room for all of these.

The crucial point is that if a language has syntax that is mutable by
dynamically plugging in user code, then only an editor that implements
that language can be SURE of supporting ANYTHING in that language.

Prolog's syntax isn't _that_ mutable, and my own editor has a Prolog
parser with a mildly extended set of operators built in.  It's enough
for my own stuff, but tends to fall down on code written by people
who have added a whole lot of extra operators.  ("Move backward/forward
over clause" works, but "check clause" doesn't.)  At least Prolog's
lexical structure isn't pluggable (so "move over compound term in
f(...) form" is completely reliable).  Quintus got over the problem by
having Emacs ask Prolog to do things.

Now, suppose you want good support for Erlang in Vim.  Currently, you
can do quite a bit.  If the lexical structure of the language becomes
mutable, then (a) you can't EVER rely Vim to get it right and (b) you
lose support just when you need it most.  So, give up on Vim.  The big
fancy things people are using these days are Eclipse and NetBeans.  (I
was unable to install NetBeans on my SPARC/Solaris 2.9/Java 1.5 box,
and I am abjectly daunted by the size of the Eclipse book.)  Both of
those are done in Java, not Erlang.  Good luck handling mutable lexical
structure for an extended Erlang in *those*!

Take the machine where I am typing this message.  I have Vim.
I have Emacs.  I have Xcode.  I have SubEthaEdit.  I have all sorts
of stuff.  What I *don't* have at the moment is an Erlang installation.
(That's on another, and another kind of, machine.)  Is there any reason
I shouldn't be able to edit Erlang?

OK, let's be honest here.  One of my home-brew tools is a program that
reads source code in a variety of languages, tokenises it, and can
either selectively include or exclude tokens or can write it out with
styles and/or colours in LaTeX, (X)HTML, Troff, ANSI terminal, or plain
text.  For example, I use
      find . -name "*.?rl" | xargs m2h -ex | sloc | wc
to count SLOC for Erlang.  If Erlang lexical structure becomes  
pluggable,
how will my poor little C program adapt?

How does my "poor little C program" cope with Lisp read-macros?
That's easy.  IT DOESN'T.  It's for me, and it relies on me not using
them (or not using them in ways that will confuse it).  Why don't I
fix it?  Because I can't.

> For example, I might be interested in renaming a normal -define()
> macro and get all uses replaced with the new name. This means that the
> lexer and parser used by the editor need to include the concept of a
> macro.

I have written extensively saying why the C-envious preprocessor in
Erlang was and is a bad idea.  (Thanks to E. E. Smith for the phrase
"was and is".)

> At the same time, the editor needs to be able to map back the final
> AST to the actual concrete syntax, for example in order to map compile
> errors to the right place in the code even if that code contains
> macros and parse transforms. [*]

Which side are you arguing?  It seems to me that in this paragraph you
are making a very strong case for a simple fixed syntax without
read-macros or extensive parse transforms.

At the moment, there are some things that even the dumbest editor can
rely on when processing Erlang:
(1) the lexical structure is fixed and fairly simple.
(2) top level items are ended by full stops, which have no other job.
There is one thing that one normally expects to rely on, which I use
all the time, and that is parenthesis matching.  (And other bracket
matching as well.)  Thanks to a rather dubious decision in the Erlang
C-envious preprocessor, no, you cannot rely on that.  One form of
syntax bending has ALREADY resulted in an useful error-detecting/
preventing editor facility being rendered untrustworthy.  If we are
talking about language changes, I think by far the biggest payoff
would come from removing the C-envious preprocessor, and I have written
extensively on how that can be done.

I myself proposed a method of extending Erlang syntax, so that you
could do things like

     -syntax(sql, 'lib/syntaxes/sql').
     ...
         sql (......)

which, however, had two key restrictions:
(a) lexical structure was still Erlang lexical structure, and
(b) the stuff after the syntax keyword had to be bracket-balanced.

I am not against SYNTAX extension mechanisms (like Lisp macros,
especially Scheme hygienic macros).  What I am arguing against
is LEXICAL extension mechanisms.

> So IMHO if the language is extended in any way, via preprocessor or
> not, the editor still needs to be updated if it is going to be able to
> understand the changes.

If the preprocessor is *OPTIONAL* (so that Joe might use it for his
regular expressions, but I wouldn't) then he can pay the price of the
editor not understanding his lexical extensions without ME having to
pay the price for something I am not using.



From ok@REDACTED  Thu May 24 05:35:16 2007
From: ok@REDACTED (ok)
Date: Thu, 24 May 2007 15:35:16 +1200
Subject: [erlang-questions] some language changes
In-Reply-To: <200705240404.55145.als@iinet.net.au>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<200705240404.55145.als@iinet.net.au>
Message-ID: 


On 24 May 2007, at 6:04 am, Anthony Shipman wrote:
> How about allowing a semicolon after the last clause in a case or if
> expression or similar:
> 	case E of
> 	A -> ...;
> 	B -> ...;
> 	end

Starting from Prolog, where for years people have complained that
commas and semicolons are hard to visually discriminate on screen
(and on some printers), I've adopted the practice of putting
commas at the ends of lines but semicolons at the beginning.
I would really really like to write

	case E of
	; A -> ...
	; B -> ...
	end

This is rather like
	Ada			Fortran
	case E is		select case (E)
            when A =>		   case (A)
               ...                     ...
	   when B =>		   case (B)
               ...                     ...
	end case 		end select

with the semicolon playing the role of when/case.
It's a simple matter of changing
	case_expr -> 'case' expr 'of' cr_clauses 'end' : ...
to
	case_expr -> 'case' expr of cr_clauses 'end' : ...

	of -> 'of' ';'.
	of -> 'of'.

with the same change

	try_expr -> 'try' exprs 'of' cr_clauses try_catch : ...
becoming
	try_expr -> 'try' exprs of cr_clauses try_catch : ...

(As far as I can tell those are the only two uses of 'of'.)




From patrickerj@REDACTED  Thu May 24 08:19:01 2007
From: patrickerj@REDACTED (Patrick)
Date: Thu, 24 May 2007 08:19:01 +0200
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
Message-ID: 

What is the technique of user authentication with HTTPS with only
HTTPS for authentication and after authentication transferring user to
HTTP protocol? I know many sites use this(Gmail, Hotmail,... ) but how
to do it, esp. in Yaws?

I know that i cant have virtual servers on different ports on the same
IP(same computer) for HTTPS, will i need for that two physical
servers?

If anyone else had similar solution to problem can you pls. post small
tutorial? ;)

BR,
Patrick


From ok@REDACTED  Thu May 24 08:28:29 2007
From: ok@REDACTED (ok)
Date: Thu, 24 May 2007 18:28:29 +1200
Subject: [erlang-questions] some language changes
In-Reply-To: <004001c79d45$9b05c7a0$6401a8c0@rubicon>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>
	<004001c79d45$9b05c7a0$6401a8c0@rubicon>
Message-ID: <72F0F669-9348-4295-8C89-5CB024894892@cs.otago.ac.nz>

Joe Armstrong wrote:
 > What you type in the shell and what you type in a module/escript
 > should be the same.

Currently they aren't.  The shell has something the module language
does not, and that is the ability to bind a top-level variable.  It
is a great pity that the module language requires you to write

     -define(CORNERS, 4).
     ... ?CORNERS ...

instead of a plain

     Corners = 4.
     ... Corners ...

The module language has something the shell does not, namely the
ability to define named mutually recursive functions.  (Also the
ability to define records, but the sooner that wart in the language
is replaced by a decent data structure like Joe's "proper structs"/
IBM Prolog "items"/my "frames" -- which are all pretty much identical)
the better.)

I wrote:
 > This has never been the case in Smalltalk, and nobody seems to
 > notice any problem.

That judgement was based on several years of subscription to a
Smalltalk mailing list with overwhelming traffic, in which many
issues were raised, but never ever that one, and on my own use of
Smalltalk, in which it was just never something you wanted to do,
because a browser was just a keypress away.

On 24 May 2007, at 2:20 am, Mike Berrow wrote:
> I've used Smalltalk and I've been making a living programming in Ruby
> for the last 18 months. Now that you point that out, it is one of the
> large advantages that Ruby has over Smalltalk w.r.t
> experimentation / prototyping / learning curve

Of course much depends on the Smalltalk system you are using, and
whether someone explains it to you properly.  You *can't* type in
class definitions and method definitions in a Workspace (= shell),
but you *can* type in arbitrary expressions while editing a method
and evaluate them.  Indeed, it is common (and recommended) practice
to include examples as comments in methods.  For example, we might have

     Collection>>
     asSet
       "#(3 1 4 1 5) bind: [:x | |s|
         s := x asSet.
         (x allSatisfy: [:e | s includes: e]) and: [
         (s allSatisfy: [:e | x includes: e]]]"
       |r|
       r := Set new: self size.
       self do: [:each | r add: each].
       ^r

The code between double quotes is actually a comment.  Put the cursor
just to the right of the opening one or just to the left of the closing
one.  Double click.  Type Cmd-p.  The editor inserts ' true' (the value
of the expression), highlighted so Delete will remove it.  Basically,
the pane in which one edits a method IS a Workspace, amongst other
things.
                                 [
What this tells us is that you can put the shell functionality in
a module editor instead of doing it the other way around.

>> It has never been the case in Prolog.
>> ....
> Is Erlang tied to Prolog in this?  If not, why does that matter?

No.  Surely it is obvious that I was giving a series of examples in
which the module language and the shell language are different, and
it really isn't a problem.  I also gave the example of Haskell, which
Erlang is obvious not "tied to".

What *can* be a big problem (and in several years of work with Lisp
I ran into this more times than I care to remember) is typing
definitions in at a "shell" and ending up with a state you *want* to
preserve but isn't recoverable from any source files.  (Interlisp
dealt with this by decreeing that 'source' files were actually
databases, so that practically any state *could* be dumped as legible
code, except that macros meant it didn't really work all that well.)

>> And that's a really important point.  Joe is suggesting that
>> the Erlang shell should be changed to make it easier for beginners
>> to shoot themselves in the foot, instead of learning practices that
>> will help to keep them out of trouble.  I cannot think that a good  
>> idea.
>
> I've found the transparency between the interactive shell and source
> environments in Ruby to be nothing but a huge boost in productivity.
> I've never had this "shooting myself in the foot" effect because of  
> it.
> If there is something intrinsically different about the Erlang  
> world that
> makes it dangerous, I would appreciate it if you could elaborate.

I literally cannot believe that this would be a HUGE boost in
productivity.  I think we are in agreement that TRYING THINGS OUT
is a help.  What we do not agree about is that this has to be done
by merging module language features into the shell, rather than by
merging shell features into the module language.

I've done a fair bit of stuff in R, an open source clone of the well
respected and widely used statistics language S.  In S and R the
shell language and the module language are identical.  There are a
number of things that save you.  One is that when you type
    f <- function (...) { ... }
in response to the prompt, R saves the full source text, so that if
you later do
    f <- edit(f)
it will work.  (Unless you told R not to save full source text, in
which case you are left swearing at yourself for a fool.  This is the
"shooting yourself in the foot" case.)  The other is that you can
dump any R data structure to a file, including functions, and you can
also dump the entire state of the R system to a file.  Indeed, when
you quit it normally offers to do this for you.  (S keeps most of your
state in files anyway.)

The Smalltalk systems I am used to keep a log of everything you have
typed in the .changes file, so that if the worst comes to the worst
and you trash your working image beyond belief you can fire up a fresh
copy of the system and recover changes from this log.

Erlang doesn't do that.  Erlang also doesn't offer a way to save the
complete state of a node to a file (not that I know of).

There is one thing about the shell that I would like to change, and
it is a minor change, which would bring Erlang into line with Haskell
and Lisp and Prolog, and would make trying things out in the shell
easier without major ramifications.  That is the ability to set a
current module and, in effect, evaluate expressions INSIDE some module.
This is how Hugs works, for example.  The interactive shell is always
inside some module, typically the last one loaded but you can change it
to whatever you want.  Expressions you type are interpreted in the
scope of that module.

Suppose you are working on a module under some editor.
(I am sure I remember being able to run 'erl -x' to get something
like this.  Whatever happened to that?  What is the right command?)
For the sake of concreteness, suppose it is Emacs.

You have one window at the top, editing the module.
You have another window at the bottom, running the shell.
Type a query in the shell.  It doesn't work.
A single chord gets you to the other window.
Make a change.
Again, a single chord should save the change, silently rerun the
compiler, silently reload the module (if the compilation worked),
and take you back to the shell window.
Another chord should replay the query.
Conversely, find an interesting expression in the module window,
possibly inside a comment.  Select it.  A single chord ships it
invisibly to the shell and the result appears there.
Where I have said "chord", you can bind the effect to a single
function key if you like.

With an interface like that, you get all the convenience of trying
things out WITHOUT any change to the shell language or module language
at all.  It is difficult to believe that eliminating at most two
keystrokes per definition could be a HUGE productivity boost.




From bengt.kleberg@REDACTED  Thu May 24 08:59:49 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Thu, 24 May 2007 08:59:49 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>	<004001c79d45$9b05c7a0$6401a8c0@rubicon><6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>
	<4654620E.40704@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se>
Message-ID: <465537E5.7060803@ericsson.com>

On 2007-05-23 22:07, Ulf Wiger (TN/EAB) wrote:
> The problem is (1) that epp explicitly calls file:open(),
> and has no function that just accepts a file descriptor,
> and (2) that epp uses the io subsystem, which requires
> file_io_server, which only works on regular files.

what i meant was that epp should accept an IO device (as returned from 
file:open/2), too. this seemed a good idea since it probably used one 
internally.
it is easy (since i have done it :-) to write your own server that 
handles the IO device.

if i understand you correctly then epp does not use the io module 
internally but have opened in raw mode. correct?

then it is a large (but trivial?) undertaking to change epp from 
file:read() to io:fread().


> This has been discussed in an earlier thread, and 
> various workarounds have been presented. Mine was to
> make a ram_file_io_server, which I thought was 
> trivially easy (after some study of the file IO
> system).

that is ok too. i have not done it, but it could be more fun than 
changing epp to use the io module.


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From dgud@REDACTED  Thu May 24 09:58:40 2007
From: dgud@REDACTED (Dan Gudmundsson)
Date: Thu, 24 May 2007 09:58:40 +0200
Subject: [erlang-questions] WHOLETABLE lock on schema
In-Reply-To: <84BB42DE-ED9A-46D1-85BF-F323394AE7CB@vailsys.com>
References: 
	<84BB42DE-ED9A-46D1-85BF-F323394AE7CB@vailsys.com>
Message-ID: <465545B0.1050609@erix.ericsson.se>

Thanks for the bug report.

I think this is a better patch :-)
I will include it in the next release.

/Dan

--- mnesia_dumper.erl	Thu May 24 09:45:01 2007
+++ mnesia_dumper.erl@@/mnesia-4.3.4	Thu Mar 22 12:05:25 2007
@@ -491,10 +491,10 @@
      Cs = mnesia_schema:list2cs(TabDef),
      Val = mnesia_schema:insert_cstruct(Tid, Cs, true), % Update ram only
      {schema, Tab, _} = Val,
-    case lists:member(N, val({current, db_nodes})) of
-	true when InitBy /= startup  ->
+    if
+	InitBy /= startup ->
  	    mnesia_controller:add_active_replica(Tab, N, Cs);
-	_ ->
+	true ->
  	    ignore
      end,
      if
@@ -760,11 +760,6 @@
  			     case mnesia_lib:cs_to_storage_type(Node, Cs) of
  				 Storage -> NS;
  				 disc_copies when Node == node() ->
-				     Dir = mnesia_lib:dir(),
-				     ok = mnesia_schema:opt_create_dir(true, Dir),
-				     mnesia_schema:purge_dir(Dir, []),
-				     mnesia_log:purge_all_logs(),
-
  				     mnesia_lib:set(use_dir, true),	
  				     mnesia_log:init(),
  				     Ns = val({current, db_nodes}),




Hal Snyder wrote:
> Follow-up to previous post:
> 
> I see the same problem in R-11B and R-9C, the two releases we are  
> running here. In both cases, I wonder if the problem is not the  
> following:
> 
> mnesia_locker.erl / receive_wlocks sits in a receive and can wait  
> forever if one of the nodes passed in its first argument is not  
> running. The following seems to make the problem go away .... but I'm  
> sure I know just enough to be dangerous:
> 
> receive_wlocks([Node | Tail], Res, Store, Oid) ->
>      receive
>          {?MODULE, Node, granted} ->
>              del_debug(Node),
>              receive_wlocks(Tail, Res, Store, Oid);
> ...
> +   after WlockTimeoutMsec ->
> +           del_debug(Node),
> +           Reason1 = {aborted, {node_timed_out, Node}},
> +           flush_remaining(Tail, Node, Reason1)
>      end;
> 
> 
> On May 23, 2007, at 10:58 AM, Hal Snyder wrote:
> 
>> I am seeing a stuck lock on the schema of a mnesia database. I'm  
>> not sure how it's happening yet. We run two nodes with disc_copies  
>> of the schema and several more with ram_copies of it, but I think  
>> all the nodes in question are listed in running_db_nodes.
>>
>> Here is another way to create the lock. I don't think this is what  
>> is happening to the problem system above, but it would be nice to  
>> know if there is a good way to resolve the general problem without  
>> downtime:
>>
>> N='some_fictional_node@REDACTED'.
>> mnesia:add_table_copy(schema, N, ram_copies).
>> mnesia:change_table_copy_type(schema, N, disc_copies).
>> mnesia:change_table_copy_type(schema, N, ram_copies).
>> -- at this point, erlang shell does not come back
>> -- you can interrupt it or remote in, though
>>
>> Last line could probably be anything that wants to lock the schema.  
>> For example,
>>   mnesia:create_table(baz,[]).
>> does the same thing.
>>
>> If you remote in from another node, you can do
>>   mnesia:system_info(held_locks).
>> and you will see something like this:
>>   [{{schema,'______WHOLETABLE_____'},write,{tid,5,<4163.81.0>}}]
>>
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From vladdu55@REDACTED  Thu May 24 10:36:59 2007
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Thu, 24 May 2007 10:36:59 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <5A4BD7B7-CFEB-4723-B589-C2A340110F06@cs.otago.ac.nz>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<200705212007.09584.als@iinet.net.au>
	<9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com>
	
	<95be1d3b0705230101i207f6adt7d39e31cf67bc074@mail.gmail.com>
	<5A4BD7B7-CFEB-4723-B589-C2A340110F06@cs.otago.ac.nz>
Message-ID: <95be1d3b0705240136h586cc462wce4b4193839678d6@mail.gmail.com>

Hi,

On 5/24/07, ok  wrote:
> Which side are you arguing?  It seems to me that in this paragraph you
> are making a very strong case for a simple fixed syntax without
> read-macros or extensive parse transforms.

I'm not arguing at all. I agree that dynamic lexing needs a very
strong use case to balance the extra complexity.

I wanted to point out that IMHO a tool that has to work with the
source code (an editor or a debugger[*]) is affected even by a
preprocessing step, not only by dynamic lexing support, and also by
parse transforms.

The requirements for a lexer+parser are different when used as a front
to a compiler than to an editor. For example, an editor has to be able
to handle incomplete code (with missing or extraneous full stops or
parentheses).

If the source code doesn't use nifty user-defined syntax, it can be
edited with an editor that doesn't understand user-defined syntax.
This syntax is just as optional as the use of a preprocessor, right?

[*] it's always thrilling to single step debug through code that uses
multi-line macros and extensive parse transforms :-)

best regards,
Vlad


From me@REDACTED  Thu May 24 12:07:40 2007
From: me@REDACTED (KatolaZ)
Date: Thu, 24 May 2007 12:07:40 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
Message-ID: <20070524100740.GF7300@katolaz.homeunix.net>

Dear Erlang Gurus,

we have tested the priority system of the processes and we are 
experiencing a very strange behaviour.

Take a look at the simple code attached: if you run "test:test()" from
the shell, the system hangs and "proc2" never ends blocking also
"proc1" and the shell. We think that this is due to the fact that
"proc2" hasn't any synchronization point, i.e. send or receive
messages, etc. In any case, this is quite strange since also "proc1"
has priority set to "high", so sooner or later, it should be selected
to be scheduled.

Now kill the shell (with CTRL+C, you don't have any other option!),
uncomment the "timer:sleep(1)" statement in proc2, recompile and
everything seems to work fine: "proc2" and "proc3" exit, and the value
reached by the counter proves that proc2 really runs with a higher
priority than proc3.

Well, now, don't exit from the shell, comment again the
"timer:sleep(1)" line, compile the code with "c(test)", and run it
again. Well, now it works!!! But if you (once again) exit the shell,
run "erl" again and launch "test:test()" once more.... it blocks!!!

What's behind this strange behaviour? An undocumented feature? A bug
in scheduler initialization? Too many beers before sitting down for
coding :-))) ???

All the best,
--Enzo and Corrado

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]

-------------------------------------------------

-module (test).

-compile (export_all).

test () ->
  register (proc1, spawn (fun () -> proc1() end)),
  register (proc3, spawn (fun () -> proc3() end)),
  ok.

proc1 () ->
  process_flag (priority, high),
  register (proc2, spawn (test, proc2, [])),
  timer:sleep (1000),
  proc2 ! x,
  proc3 ! x,
  ok.


proc2 () ->
  process_flag (priority, high),
  %%timer:sleep (1),
  count (0).


proc3 () ->
  count (0).



count (X) ->
  receive
    _ -> io:format ("~p, ~p~n", [process_info (self(), registered_name), X])
  after 0 ->
      count (X + 1)
  end.



From lenartlad@REDACTED  Thu May 24 13:18:30 2007
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 24 May 2007 13:18:30 +0200
Subject: [erlang-questions] [Q] Copying memory between processes
In-Reply-To: 
References: <46540824.7030905@volny.cz> 
Message-ID: <46557486.2060606@volny.cz>

Bjorn Gustavsson wrote:
> Ladislav Lenart  writes:
>> But as soon as this structure is sent to one other process
>> the system is suddenly out of resources. The only reason
>> this could happen (that I could think of) is: When the
>> structure is copied to the heap of the other process, the
>> identity is not preserved, that is each item references its
>> own list of previous items (though equal). This would explain
>> expontential growth of the memory.
> 
> Yes.
> 
>> Am I right? And if it so, what is the reason (performance)?
> 
> Yes. In typical applications, shared data structures are uncommon.
Thanks,

I have two comments then:
1. This fact (and Erlang memory management) as a whole should
    be covered somewhere in docs (maybe it is and I just missed
    it?). Erlang doc states that when you modify something only
    the top most structure is created but its other "cells" point
    to the original (unmodified) data. But this is true only within
    one process. Furthermore each process has its own heap which
    complicates matters a bit too.
2. When debugging the above problem, the VM was stuck most of
    the time by not doing anything (the scheduler seemed stuck)
    although consuming 100% CPU and almost all memory (88%). When
    it was let to run longer, the memory consumption lowered to
    50% but the VM was still "stuck". I got the VM message "Can
    not reallocate ~1.7GB to the process heap" (or something like
    that) once in a while (for some sizes of the structure).
    I would expect the VM to segfault when it runs out of memory,
    but not this...

Ladislav Lenart



From diginux@REDACTED  Thu May 24 14:57:16 2007
From: diginux@REDACTED (Jordan Wilberding)
Date: Thu, 24 May 2007 07:57:16 -0500
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070524100740.GF7300@katolaz.homeunix.net>
References: <20070524100740.GF7300@katolaz.homeunix.net>
Message-ID: <46558BAC.8000208@diginux.net>

I am definitely not a guru, but I will take my best guess at it.

My guess that it has something to do with using both 
process_flag(priority, high) and having a timeout of zero in the count 
receive loop. If you comment out process_flag(priority, high) in proc2/0 
or you change after 0 to after 1 in count/1 the program will work.

If you look at top in linux or task manager in windows, the program runs 
at nearly 100%. My guess is the proc2 is running with such a high 
priority that it is hitting that after 0 every time and not giving a 
chance for the proc2 ! x and proc3 ! x to be executed.

Again, I am not a guru, but this is my best guess based on the 
obvservations I saw.

Thanks!
Jordan Wilberding

KatolaZ wrote:
> Dear Erlang Gurus,
>
> we have tested the priority system of the processes and we are 
> experiencing a very strange behaviour.
>
> Take a look at the simple code attached: if you run "test:test()" from
> the shell, the system hangs and "proc2" never ends blocking also
> "proc1" and the shell. We think that this is due to the fact that
> "proc2" hasn't any synchronization point, i.e. send or receive
> messages, etc. In any case, this is quite strange since also "proc1"
> has priority set to "high", so sooner or later, it should be selected
> to be scheduled.
>
> Now kill the shell (with CTRL+C, you don't have any other option!),
> uncomment the "timer:sleep(1)" statement in proc2, recompile and
> everything seems to work fine: "proc2" and "proc3" exit, and the value
> reached by the counter proves that proc2 really runs with a higher
> priority than proc3.
>
> Well, now, don't exit from the shell, comment again the
> "timer:sleep(1)" line, compile the code with "c(test)", and run it
> again. Well, now it works!!! But if you (once again) exit the shell,
> run "erl" again and launch "test:test()" once more.... it blocks!!!
>
> What's behind this strange behaviour? An undocumented feature? A bug
> in scheduler initialization? Too many beers before sitting down for
> coding :-))) ???
>
> All the best,
> --Enzo and Corrado
>
>   



From me@REDACTED  Thu May 24 15:16:41 2007
From: me@REDACTED (KatolaZ)
Date: Thu, 24 May 2007 15:16:41 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
Message-ID: <20070524131641.GK7300@katolaz.homeunix.net>

On Thu, May 24, 2007 at 07:57:16AM -0500, Jordan Wilberding wrote:
> I am definitely not a guru, but I will take my best guess at it.
> 
> My guess that it has something to do with using both 
> process_flag(priority, high) and having a timeout of zero in the count 
> receive loop. If you comment out process_flag(priority, high) in proc2/0 
> or you change after 0 to after 1 in count/1 the program will work.
> 
> If you look at top in linux or task manager in windows, the program runs 
> at nearly 100%. My guess is the proc2 is running with such a high 
> priority that it is hitting that after 0 every time and not giving a 
> chance for the proc2 ! x and proc3 ! x to be executed.
> 
> Again, I am not a guru, but this is my best guess based on the 
> obvservations I saw.

The first problem is that also proc1 has priority set to "high", and
it should be eventually scheduled. That code snipped perfectly works
if priority is set to "normal" for all processes, as it should be. If
you assign all processes a "high" priority, only proc2 will be
executed, hanging-up the shell and all other processes.

But the real mess is that the behaviour changes depending on WHEN you
excecute that code. In fact, as reported in our previous mail, if you
launch the original test:test() (that without timer:sleep() in proc2)
as the first function after starting erl, it hangs up and never
returns. On the other hand, if you first try to execute the
test:test() with timer:sleep() and then you remove the timer:sleep()
and recompile, it WORKS.  And if you start again erl to run it, it
DOES NOT WORK.

HND

Enzo and Corrado

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From diginux@REDACTED  Thu May 24 15:58:32 2007
From: diginux@REDACTED (Jordan Wilberding)
Date: Thu, 24 May 2007 08:58:32 -0500
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070524131641.GK7300@katolaz.homeunix.net>
References: <20070524131641.GK7300@katolaz.homeunix.net>
Message-ID: <46559A08.8030801@diginux.net>

KatolaZ wrote:
>
> But the real mess is that the behaviour changes depending on WHEN you
> excecute that code. In fact, as reported in our previous mail, if you
> launch the original test:test() (that without timer:sleep() in proc2)
> as the first function after starting erl, it hangs up and never
> returns. On the other hand, if you first try to execute the
> test:test() with timer:sleep() and then you remove the timer:sleep()
> and recompile, it WORKS.  And if you start again erl to run it, it
> DOES NOT WORK.
>
>   
I think this is because you are using register, which registers those 
processes globally. As far as I know, those remain active throughout the 
life of the shell.

Thanks!
Jordan Wilberding


From bob@REDACTED  Thu May 24 16:12:45 2007
From: bob@REDACTED (Bob Ippolito)
Date: Thu, 24 May 2007 07:12:45 -0700
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: 
References: 
Message-ID: <6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>

On 5/23/07, Patrick  wrote:
> What is the technique of user authentication with HTTPS with only
> HTTPS for authentication and after authentication transferring user to
> HTTP protocol? I know many sites use this(Gmail, Hotmail,... ) but how
> to do it, esp. in Yaws?

That's not really what they do, they just redirect you back to where
you were. If you start at a https URL before logging in then you'll
end up at one. What they're doing is basically a form of single
sign-on.

> I know that i cant have virtual servers on different ports on the same
> IP(same computer) for HTTPS, will i need for that two physical
> servers?

Different IP addresses are sufficient.

-bob


From garyjefferson123@REDACTED  Thu May 24 16:55:38 2007
From: garyjefferson123@REDACTED (Gary Jefferson)
Date: Thu, 24 May 2007 07:55:38 -0700 (PDT)
Subject: [erlang-questions] suitability of erlang for large-scale datastore
Message-ID: <330998.34057.qm@web35805.mail.mud.yahoo.com>

Would erlang be a good choice for creating, for
example, a very high-traffic ftp server?

The concurrency model is very alluring with regard to
many concurrent ftp clients, but are there issues with
disk io performance and/or moving large chunks of
memory through such a system?  Any apparent
performance bottlenecks?

What would be some of the other
advantages/disadvantages of using erlang to build such
a thing?

Gary


       
____________________________________________________________________________________Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/


From bob@REDACTED  Thu May 24 17:14:08 2007
From: bob@REDACTED (Bob Ippolito)
Date: Thu, 24 May 2007 08:14:08 -0700
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: 
References: 
	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>
	
Message-ID: <6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>

(replying to the list, please don't follow up with me off-list next time)

On 5/24/07, Patrick  wrote:
>
> > > What is the technique of user authentication with HTTPS with only
> > > HTTPS for authentication and after authentication transferring user to
> > > HTTP protocol? I know many sites use this(Gmail, Hotmail,... ) but how
> > > to do it, esp. in Yaws?
> >
>
> > That's not really what they do, they just redirect you back to where
> > you were. If you start at a https URL before logging in then you'll
> > end up at one. What they're doing is basically a form of single
> > sign-on.
> >
>
> Not following this, if the server is on 447, then it redirects on 8080
> how can you then alternate those two different ports on the same page?

If you go to https://mail.google.com/mail/ and you login, then you
will be redirected back to https://mail.google.com/mail/. If you go to
http://mail.google.com/mail/ and you login, you will be redirected to
http://mail.google.com/mail/. I don't understand why this makes you
think about ports.

> >
> > Different IP addresses are sufficient.
>
> Do i need virtualisation of my Linux machine, or can i run two Yaws
> instances on the same OS space?

You don't need virtualization to configure multiple IP addresses in
Linux, and you can certainly run more than one copy of Yaws on a given
machine.

> Also are there some papers that detail https user authentication,
> there are many docs but Yaws documentation is lacking this. I would
> like to keep authentication sessions tracking(??)  in  mnesia, any
> docs on that too? I am still fuzzy with Erlang so bare with me.. :)

Well, find one of those papers, look at how it's done, and implement
that in Erlang. There's no documentation for it in Yaws because Yaws
doesn't do what you want out of the box.

-bob


From chsu79@REDACTED  Thu May 24 17:50:49 2007
From: chsu79@REDACTED (Christian S)
Date: Thu, 24 May 2007 17:50:49 +0200
Subject: [erlang-questions] suitability of erlang for large-scale
	datastore
In-Reply-To: <330998.34057.qm@web35805.mail.mud.yahoo.com>
References: <330998.34057.qm@web35805.mail.mud.yahoo.com>
Message-ID: 

On 5/24/07, Gary Jefferson  wrote:
> Would erlang be a good choice for creating, for
> example, a very high-traffic ftp server?

I would store the file namespace in mnesia and the data in the underlying
file system. So with mnesia you would list directories and find the
filesystem name for a ftp filename. The filesystem filenames could be
sha1 hashes of the file content.

The ftp application would make sure that every node participating as a
ftp server has a copy of the data file before changes are made to
mnesia.

Mnesia is neither good at nor designed to being a blob-store. That is
why I wouldn't put the actual data in mnesia tables.

> What would be some of the other
> advantages/disadvantages of using erlang to build such
> a thing?

Pro:
If the application is written in good OTP manner you will get all the
good properties in robustness etc. The risk of introducing buffer
overflow bugs and other security mistakes are minimal.

Con:
Not having sendfile-syscall in erlang might cost you 10-20% in
performance relative some singlenode C hacks. Maybe, I'm just
guessing. Though, I spotted a patch to add sendfile syscall to erlang
posted to this mailinglist a few years ago.


I have pondered an ftp server with an entirely different target: You
see, I work close to banks and they love to "drop files" into ftp
areas as for their information exchange. This is currently handled by
having a cronjob that poll their upload directory for new files.
Wouldnt it be lovelier if one could just have the ftp server notify
you of the change as it happens? Perhaps even refuse the upload if the
file doesnt pass sanity checks for the format.


From david.hopwood@REDACTED  Thu May 24 17:37:37 2007
From: david.hopwood@REDACTED (David Hopwood)
Date: Thu, 24 May 2007 16:37:37 +0100
Subject: [erlang-questions] [Q] Copying memory between processes
In-Reply-To: 
References: <46540824.7030905@volny.cz> 
Message-ID: <4655B141.7010604@industrial-designers.co.uk>

Bjorn Gustavsson wrote:
> Ladislav Lenart  writes:
> 
>>But as soon as this structure is sent to one other process
>>the system is suddenly out of resources. The only reason
>>this could happen (that I could think of) is: When the
>>structure is copied to the heap of the other process, the
>>identity is not preserved, that is each item references its
>>own list of previous items (though equal). This would explain
>>expontential growth of the memory.

Quadratic in the number of items, actually. But that's bad enough.

> Yes.

I'd say this was a bug. Even if this degree of sharing in a data structure
is unusual, it is not pathological enough that this increase in memory
usage should be considered acceptable.

>>Am I right? And if it so, what is the reason (performance)?
> 
> Yes. In typical applications, shared data structures are uncommon.

A deep copy that preserves sharing can be implemented efficiently.
The easiest approach is to use forwarding pointers: as you copy an
object, set a pointer in its header to point to the copy.

-- 
David Hopwood 



From patrickerj@REDACTED  Thu May 24 17:55:58 2007
From: patrickerj@REDACTED (Patrick)
Date: Thu, 24 May 2007 17:55:58 +0200
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: <6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>
References: 
	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>
	
	<6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>
Message-ID: 

@Bob
> If you go to https://mail.google.com/mail/ and you login, then you
> will be redirected back to https://mail.google.com/mail/. If you go to
> http://mail.google.com/mail/ and you login, you will be redirected to
> http://mail.google.com/mail/. I don't understand why this makes you
> think about ports.

Well actually when i sign into gmail i actually land on https page and
after i login it redirects me on http page...
Anyway i will use https for starters until i understand how to
transfer credentials without loosing security to http pages on my site
(i presume the user is checked for credentials with https every now
and then - don't know how this works) .

Thanks,
Patrick


From paul-trapexit@REDACTED  Thu May 24 18:00:49 2007
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Thu, 24 May 2007 09:00:49 -0700 (PDT)
Subject: [erlang-questions] high availablity the erlang way
Message-ID: 

Hey, I'm just learning Erlang, and have a basic question about high
availability.

I'm wondering what the "Erlang way" for providing a highly available
service is.  By this I mean Erlang node providing service A wants to talk
to a set of (N > 2, identical) Erlang nodes providing service B.  Any node
providing service B might be taken down for maintenance or removed
entirely and new nodes providing service B might be introduced for
scaling purposes.

I've seen parts of the OTP that ensure that 1 copy of an application is
running somewhere on a set of nodes, but I found anything that directly
address the above.

I could have A talk to B via UDP and use a load balancer, but that does
not feel very Erlang-y.

I do see how combining primitives such as nodeup/nodedown messages,
locally registered process names, whereis, etc. I could assemble and
maintain a list of providers of service B on each A node, and then
load balance between the providers.  Since I don't see anything that
does this already I think 1) i'm missing it, or 2) something about
Erlang makes this entire line of reasoning moot.

Thanks in advance, Erlang high school football rulz, etc.

-- p


From bob@REDACTED  Thu May 24 18:27:02 2007
From: bob@REDACTED (Bob Ippolito)
Date: Thu, 24 May 2007 09:27:02 -0700
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: 
References: 
	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>
	
	<6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>
	
Message-ID: <6a36e7290705240927vba7781ch54be8da70ae8e157@mail.gmail.com>

On 5/24/07, Patrick  wrote:
> @Bob
> > If you go to https://mail.google.com/mail/ and you login, then you
> > will be redirected back to https://mail.google.com/mail/. If you go to
> > http://mail.google.com/mail/ and you login, you will be redirected to
> > http://mail.google.com/mail/. I don't understand why this makes you
> > think about ports.
>
> Well actually when i sign into gmail i actually land on https page and
> after i login it redirects me on http page...
> Anyway i will use https for starters until i understand how to
> transfer credentials without loosing security to http pages on my site
> (i presume the user is checked for credentials with https every now
> and then - don't know how this works) .

The page with the login form is always https, of course. I was
ignoring the URL of that in my examples because it's irrelevant. It
doesn't have to be even on the same domain using the kind of
authentication scheme that Google does. The page you *started at*, the
one that redirected you to the login page, is the one that determines
where you go after logging in.

HTTPS is just transport level security (unless you're using client
certificates, which you're not). Authentication of this kind is at the
application level and the transport you're using (http vs. https)
doesn't change anything. It's usually some expiring token, stored in a
cookie, that you can verify on every request.

-bob


From me@REDACTED  Thu May 24 19:10:58 2007
From: me@REDACTED (KatolaZ)
Date: Thu, 24 May 2007 19:10:58 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <46559A08.8030801@diginux.net>
References: <20070524131641.GK7300@katolaz.homeunix.net>
	<46559A08.8030801@diginux.net>
Message-ID: <20070524171058.GN7300@katolaz.homeunix.net>

On Thu, May 24, 2007 at 08:58:32AM -0500, Jordan Wilberding wrote:
> KatolaZ wrote:
> >
> > But the real mess is that the behaviour changes depending on WHEN you
> > excecute that code. In fact, as reported in our previous mail, if you
> > launch the original test:test() (that without timer:sleep() in proc2)
> > as the first function after starting erl, it hangs up and never
> > returns. On the other hand, if you first try to execute the
> > test:test() with timer:sleep() and then you remove the timer:sleep()
> > and recompile, it WORKS.  And if you start again erl to run it, it
> > DOES NOT WORK.
> >
> >   
> I think this is because you are using register, which registers those 
> processes globally. As far as I know, those remain active throughout the 
> life of the shell.
> 

We still don't understand why the same code has different behaviours
when executed as the first function and when executed the second or
the third time. It is also quite astonishing that a silly process as
proc2 can *definetively* lock the scheduler, pushing out all other
processes, including the shell.....

I suppose we hit a serious bug...

HND

Enzo and Corrado

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From patrickerj@REDACTED  Thu May 24 19:11:52 2007
From: patrickerj@REDACTED (Patrick)
Date: Thu, 24 May 2007 19:11:52 +0200
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: <6a36e7290705240927vba7781ch54be8da70ae8e157@mail.gmail.com>
References: 
	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>
	
	<6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>
	
	<6a36e7290705240927vba7781ch54be8da70ae8e157@mail.gmail.com>
Message-ID: 

Generally https data transfer is encrypted with ssl, but if i use
session identifiers then what is the difference between http and
https? Generally as i understand https is much more heavy on cpu than
his counterpart. But without certificate authentication what is the
advantage of https anyway?

Patrick

> > @Bob
> > Well actually when i sign into gmail i actually land on https page and
> > after i login it redirects me on http page...
> > Anyway i will use https for starters until i understand how to
> > transfer credentials without loosing security to http pages on my site
> > (i presume the user is checked for credentials with https every now
> > and then - don't know how this works) .
>
> The page with the login form is always https, of course. I was
> ignoring the URL of that in my examples because it's irrelevant. It
> doesn't have to be even on the same domain using the kind of
> authentication scheme that Google does. The page you *started at*, the
> one that redirected you to the login page, is the one that determines
> where you go after logging in.
>
> HTTPS is just transport level security (unless you're using client
> certificates, which you're not). Authentication of this kind is at the
> application level and the transport you're using (http vs. https)
> doesn't change anything. It's usually some expiring token, stored in a
> cookie, that you can verify on every request.
>
> -bob
>


From csanto@REDACTED  Thu May 24 20:21:33 2007
From: csanto@REDACTED (Corrado Santoro)
Date: Thu, 24 May 2007 20:21:33 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070524171058.GN7300@katolaz.homeunix.net>
References: <20070524131641.GK7300@katolaz.homeunix.net>	<46559A08.8030801@diginux.net>
	<20070524171058.GN7300@katolaz.homeunix.net>
Message-ID: <4655D7AD.6080901@diit.unict.it>

Hi all,

On Thu, May 24, 2007 at 08:58:32AM -0500, Jordan Wilberding wrote:
> I think this is because you are using register, which registers those 
> processes globally. As far as I know, those remain active throughout the 
> life of the shell.
No, no. If a registered process ends, the registry is updated. See this 
snap of the shell:

3> register(proc1,
    spawn (fun () -> io:format ("I am ~p~n", [whereis(proc1)]) end )).
I am <0.37.0>
true
4> whereis(proc1).
undefined
5>

> We still don't understand why the same code has different behaviours
> when executed as the first function and when executed the second or
> the third time. It is also quite astonishing that a silly process as
> proc2 can *definetively* lock the scheduler, pushing out all other
> processes, including the shell.....
> 
> I suppose we hit a serious bug...
I agree! It seems that, at the first startup of the emulator, a process 
running with a priority "high" (and without synchronization points) does 
not release the CPU, even if there are other processes with the same 
"high" priority. Indeed not a "so correct" behaviour for a round-robin 
scheduler.

We tried to take a look at the source code of the function "Process" in 
"erl_process.c", which performs scheduling, but, at first sight, 
everything seems ok. :-O

All the best,
--Enzo and Corrado

-- 
==================================================================
Eng. Corrado Santoro, Ph.D.
University of Catania - ITALY - Engineering Faculty

Tel: +39 095 7382380        VoIP: sip:7035@REDACTED

Personal Home Page: http://www.diit.unict.it/users/csanto
     NUXI Home Page: http://nuxi.diit.unict.it
==================================================================



From paul-trapexit@REDACTED  Thu May 24 20:21:43 2007
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Thu, 24 May 2007 11:21:43 -0700 (PDT)
Subject: [erlang-questions] high availablity the erlang way
In-Reply-To: 
References: 
	
Message-ID: 

Comments inline.

-- p

On Thu, 24 May 2007, RCB wrote:

> Paul,
>
> The way that I've done this is fairly simple.   Let's say service B runs its
> own application.    The service that you're providing on service B might be
> made available using a single gen_server, and that gen_server will sit in a
> supervision tree within that application.    What is done from this point is
> to have that particular gen_server's init() function use pg2 to announce
> that it is online and ready to serve requests (of course, do this after any
> initialization that is required...)  It'll make a call like
> pg2:create(service_name), pg2:join(service_name, self()).
>
> The clients will communicate with this service by first getting the eligible
> PIDs from pg2, and then using gen_server:call() to send a request to it:

Awesome.

>
> client:
>
> Spid = pg2:get_closest_pid(service_name),
> Response = gen_server:call(Spid, {this_is_a_request, Param1, Param2, etc}).
>
> This solves the problem with a node taken down.   pg2 module will handle the
> case if the machine is brought down gracefully or not.  It will also handle
> somewhat random distribution to the node(s) which are running that
> gen_server!  You'll need to handle race condition errors with the
> gen_server:call in the clients, but that's relatively simple.

Ok; I assume you mean the race condition wherein the Spid goes down
between the call to pg2:get_closest_pid and gen_server:call; some kind
of retry-if-time-remaining strategy could work here.

> Naturally, if you need to synchronize state across the various service
> nodes, mnesia is an excellent choice.
>
> Let me know if you have additional questions.   Have fun!

I think this will work.  Another problem we have is that we need to do
non-uniform load balacing because the different hardware orders at
different points in time generate boxes with different capacity
(sometimes radically different capacity, such as going from dual
 to quad core); however since pg2 is process id based we might be
able to handle this by spawning more or less processes per node
depending upon the hardware config.

Thanks,

-- p



>
> Rich Beerman
> Cupertino CA
> +1 408-221-2444
>
>
> On 5/24/07, Paul Mineiro  wrote:
> >
> > Hey, I'm just learning Erlang, and have a basic question about high
> > availability.
> >
> > I'm wondering what the "Erlang way" for providing a highly available
> > service is.  By this I mean Erlang node providing service A wants to talk
> > to a set of (N > 2, identical) Erlang nodes providing service B.  Any node
> > providing service B might be taken down for maintenance or removed
> > entirely and new nodes providing service B might be introduced for
> > scaling purposes.
> >
> > I've seen parts of the OTP that ensure that 1 copy of an application is
> > running somewhere on a set of nodes, but I found anything that directly
> > address the above.
> >
> > I could have A talk to B via UDP and use a load balancer, but that does
> > not feel very Erlang-y.
> >
> > I do see how combining primitives such as nodeup/nodedown messages,
> > locally registered process names, whereis, etc. I could assemble and
> > maintain a list of providers of service B on each A node, and then
> > load balance between the providers.  Since I don't see anything that
> > does this already I think 1) i'm missing it, or 2) something about
> > Erlang makes this entire line of reasoning moot.
> >
> > Thanks in advance, Erlang high school football rulz, etc.
> >
> > -- p
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>

Many parts of Iraq are stable now.  But of course what we see on television
is the one bombing a day that discourages everybody.

        -- First Lady Laura Bush


From bob@REDACTED  Thu May 24 22:52:55 2007
From: bob@REDACTED (Bob Ippolito)
Date: Thu, 24 May 2007 13:52:55 -0700
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: 
References: 
	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>
	
	<6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>
	
	<6a36e7290705240927vba7781ch54be8da70ae8e157@mail.gmail.com>
	
Message-ID: <6a36e7290705241352w79608843vacc22064bd8f54e4@mail.gmail.com>

HTTPS *is* HTTP over SSL. That's what the S means (unless it means
TLS). It's transport level encryption that prevents eavesdropping and
man in the middle attacks. This is what uses the CPU.  It's still
*just* HTTP other than the transport, in the same way that HTTP is the
same over wireless or wired LAN.

Typical HTTPS implementations do of course have a server certificates
so that the client can verify they're talking to the same server over
several different requests. Client certificates are different in that
each client needs their own certificate that the server can use to
verify who the client is. If you're using client certs you don't need
logins or passwords.

-bob

On 5/24/07, Patrick  wrote:
> Generally https data transfer is encrypted with ssl, but if i use
> session identifiers then what is the difference between http and
> https? Generally as i understand https is much more heavy on cpu than
> his counterpart. But without certificate authentication what is the
> advantage of https anyway?
>
> Patrick
>
> > > @Bob
> > > Well actually when i sign into gmail i actually land on https page and
> > > after i login it redirects me on http page...
> > > Anyway i will use https for starters until i understand how to
> > > transfer credentials without loosing security to http pages on my site
> > > (i presume the user is checked for credentials with https every now
> > > and then - don't know how this works) .
> >
> > The page with the login form is always https, of course. I was
> > ignoring the URL of that in my examples because it's irrelevant. It
> > doesn't have to be even on the same domain using the kind of
> > authentication scheme that Google does. The page you *started at*, the
> > one that redirected you to the login page, is the one that determines
> > where you go after logging in.
> >
> > HTTPS is just transport level security (unless you're using client
> > certificates, which you're not). Authentication of this kind is at the
> > application level and the transport you're using (http vs. https)
> > doesn't change anything. It's usually some expiring token, stored in a
> > cookie, that you can verify on every request.
> >
> > -bob
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf.wiger@REDACTED  Fri May 25 10:42:07 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 25 May 2007 10:42:07 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: 
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>
	<004001c79d45$9b05c7a0$6401a8c0@rubicon>
	<6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>
	
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F4FE32@esealmw115.eemea.ericsson.se>

 
Christian S wrote:
> 
> On 5/23/07, Ulf Wiger (TN/EAB)  wrote:
> > 1> md("
> > -module(foo).
> > ...
> > plus(A,B) -> A+B.
> > ").
> > {module, foo}
> 
> Isnt this horribly annoying when you have string litterals in 
> the module you are defining?

Yeah, sure, but this was supposed to be the first step.
There are two parts of the problem:

1) Making the shell keep information about interpreted
   modules, much as it does with records today
2) Finding nifty ways of entering the module definition.

By far the easiest way to be done with (1) is to accept
the current behaviour of the shell's line editor. And,
yes, it would be inconvenient with escape codes etc, but
it would work.

> How about following the idea from unix shells:
> 
> cat < dobido
> blah...
> sim salabim
> EOF

Regardless of whether the shell supports module definitions,
I (and especially Mats Cronqvist, I believe) would like to
see better support for editing insanely complex one-liners
in the shell (multi-line editing would be a great help).

Today, if you insert line breaks into a command, the 
repeated occurences of the prompt destroys your chances
of copying and pasting the expression without post-
processing. This leaves you with writing expressions that 
wrap several times, and they are a bear to edit (esp. with
broken terminal windows).

BR,
Ulf W



From casper2000a@REDACTED  Fri May 25 14:29:45 2007
From: casper2000a@REDACTED (Eranga Udesh)
Date: Fri, 25 May 2007 17:59:45 +0530
Subject: [erlang-questions] ASN.1 asn1ct error
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F4FE32@esealmw115.eemea.ericsson.se>
Message-ID: <20070525123030.D657819DC37C@mail.wavenet.lk>

Hi,

Why could be the reason for asn1ct to return below error? I checked
asn1ct:check_object_list/4, but I cannot find a case match for type pv. If
you want me to send the asn.1 source to check the error, please let me know.

asn1error:72:'Test':'ActivityTest2' {internal_error,
                                     {error,
                                      {'unknown object',
                                       {pv,
                                        {simpledefinedvalue,
                                         32,
                                         boundedExtension},
                                        [{'Externalvaluereference',
                                          32,
                                          'IN-CS2-classes-test',
                                          bound}]}},


Thanks,
- Eranga



From zhaoomingg@REDACTED  Fri May 25 14:45:30 2007
From: zhaoomingg@REDACTED (Ming Zhao(Jimmy))
Date: Fri, 25 May 2007 14:45:30 +0200
Subject: [erlang-questions] questions about gen_server behaviour
Message-ID: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>

Could anyone explain these two functions below in details (better with
example)?
1.synchronous request ----call
Makes a synchronous call to the gen_server by sending a request and waiting
until a reply arrives or a timout occurs.
who sends the reply? what exactly is the reply?
2.asynchronous request ----cast
Sends an asynchronous request to the gen_server and returns ok immediately
who sends the ok?

these 2 functions seems to me the same ,
so confused by them ..

BR
Thanks
Jimmy

-- 
Ming   Zhao
Dobelnsgatan 2C  231
752 37 Uppsala, SWE

Email: zhaoomingg@REDACTED
Tel: +46 (0)736964077
MSN:
zhaoomingg@REDACTED
Skype: zhaoomingg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang@REDACTED  Fri May 25 14:53:06 2007
From: erlang@REDACTED (Joe Armstrong)
Date: Fri, 25 May 2007 14:53:06 +0200
Subject: [erlang-questions] Syntax highlight erlang code with erlang
In-Reply-To: <00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se>
References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se>
	
	<00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se>
Message-ID: <9b08084c0705250553x4a6e6290x5c0324c35c967769@mail.gmail.com>

I have just written something that might be useful. It was rather
hacky so I'm not very proud
of it. To get the tagging correct is a bit of a pain. This is done in
several passes

1)
Modified the tokeniser (erl_scan.erl) to return the actual text in the tokens
- so, for example, when the original tokeniser returned {int, 6,  18}
(meaning the integer
18 on line 6) I now return {int,6,18,"16#12"} (suppose the integer was
written 16#12)
I also added all inter-token white space as {ws,Line,"..."} tokens and
retained the comments

In this stream of tokens the original source can be exactly
reconstructed by concatinating
all the strings in the tokens  - since I preserve everything.

2) Number each token 1,2,3,4

(This replaces the line number)

3) Keep a copy of this token list, and make a new token list that is
compatible with the parser

4) Modify the erlang parser. I took erl_parse.yrl and changed the RHS
to contain tagged
forms -

5) Merged the parse tree with the numbered-token list.

By this time I have a correct semantic tag for *everything* in the
source text (so keywords occurring
in strings won't causes accidental tagging errors (which would have
happened with a simple
-minded "regexp" approach).

The result is an abstract form which is easily turned in HTML or TeX
for printing.

I think the changes to the tokeniser should be folded into the main
OTP release - my version
involved "minimum changes" to the existing version, the result is a
mess which needs to be
rewritten.

This is part of a large project to produce *beautiful* documentation :-)

Cheers

/Joe






On 5/23/07, Petter Larsson XA (TN/EAB)  wrote:
> I would actually prefer doing it in erlang code, soo I can create links
> fo other filer etc. when possible.
>
> Doesn't anyone have an example code of highligting erlang code with
> erl_syntax etc.
>
> /Petter
>
> > -----Original Message-----
> > From: erlang-questions-bounces@REDACTED
> > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of
> > Torbjorn Tornkvist
> > Sent: den 23 maj 2007 10:53
> > To: erlang-questions@REDACTED
> > Subject: Re: [erlang-questions] Syntax highlight erlang code
> > with erlang
> >
> > Petter Larsson XA (TN/EAB) wrote:
> > > I have a file browser in yaws that I look at erlang code with.
> > > I would like to syntax highlight this code.
> > >
> > > What is the best way to view a erlang source code with syntax
> > > highlighting?
> > > I can parse the code with functions in Syntax_Tools I
> > guess, but does
> > > anyone have any example code for this?
> > >
> > > BR
> > > Petter Larsson
> > >
> >
> > Perhaps you could do it with Chili ?
> > Chili is the jQuery code highlighter plugin.
> >
> >  http://noteslog.com/chili/
> >
> > Would be nice if you could post the setup of Chili when
> > you're done... :-)
> >
> > --Tobbe
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf.wiger@REDACTED  Fri May 25 15:00:16 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 25 May 2007 15:00:16 +0200
Subject: [erlang-questions] questions about gen_server behaviour
In-Reply-To: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>
References: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F503A1@esealmw115.eemea.ericsson.se>

 
A synchronous request is similar to
 
call(Server, Request) ->
   MonRef = erlang:monitor(process, Server),
   Msg = {'$gen_call', {self(), MonRef}, Request},
   Server ! Msg,
   receive
      {MonRef, Reply} -> Reply;
      {'DOWN', MonRef, _, _, _} -> erlang:error(...);
   after 5000 -> 
      erlang:error(timeout
   end.
 
(The actual code is a little bit more contrived.)
 
A cast is simply:
 
cast(Server, Msg) ->
   Server ! {'$gen_cast', Msg},
   ok.
 
So to answer your question, the gen_server sends the reply in the case
of a synchronous call.
 
The 'ok' in cast is not _sent_, it is simply the return value from the
cast/2 function.
 
With a call, you get actual acknowledgment from the server that the
request was received and processed. With cast, you have no such
information. The message may have been received and understood, but you
cannot know that.
 
Cast is also asynchronous, while call isn't. Call gives a form of flow
control.
 
BR,
Ulf W


________________________________

	From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ming
Zhao(Jimmy)
	Sent: den 25 maj 2007 14:46
	To: erlang-questions@REDACTED
	Subject: [erlang-questions] questions about gen_server behaviour
	
	
	Could anyone explain these two functions below in details
(better with example)?
	1.synchronous request ----call
	Makes a synchronous call to the gen_server by sending a request
and waiting until a reply arrives or a timout occurs.
	who sends the reply? what exactly is the reply? 
	2.asynchronous request ----cast
	Sends an asynchronous request to the gen_server and returns ok
immediately
	who sends the ok? 
	
	these 2 functions seems to me the same ,
	so confused by them ..
	
	BR
	Thanks
	Jimmy
	
	-- 
	Ming   Zhao
	Dobelnsgatan 2C  231
	752 37 Uppsala, SWE
	
	Email: zhaoomingg@REDACTED
	Tel: +46 (0)736964077
	MSN:
	zhaoomingg@REDACTED
	Skype: zhaoomingg 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From zhaoomingg@REDACTED  Fri May 25 15:08:48 2007
From: zhaoomingg@REDACTED (Ming Zhao(Jimmy))
Date: Fri, 25 May 2007 15:08:48 +0200
Subject: [erlang-questions] questions about gen_server behaviour
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F503A1@esealmw115.eemea.ericsson.se>
References: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>
	<6616D98C65DD514BA2E1DDC5F922315501F503A1@esealmw115.eemea.ericsson.se>
Message-ID: <4fe9e1b00705250608r6910bd04hd4636558308dea0b@mail.gmail.com>

Thanks very much , its now pretty clear ~~
just didnt know the mechanism behind~~~

On 5/25/07, Ulf Wiger (TN/EAB)  wrote:
>
>
> A synchronous request is similar to
>
> call(Server, Request) ->
>    MonRef = erlang:monitor(process, Server),
>    Msg = {'$gen_call', {self(), MonRef}, Request},
>    Server ! Msg,
>    receive
>       {MonRef, Reply} -> Reply;
>       {'DOWN', MonRef, _, _, _} -> erlang:error(...);
>    after 5000 ->
>       erlang:error(timeout
>    end.
>
> (The actual code is a little bit more contrived.)
>
> A cast is simply:
>
> cast(Server, Msg) ->
>    Server ! {'$gen_cast', Msg},
>    ok.
>
> So to answer your question, the gen_server sends the reply in the case
> of a synchronous call.
>
> The 'ok' in cast is not _sent_, it is simply the return value from the
> cast/2 function.
>
> With a call, you get actual acknowledgment from the server that the
> request was received and processed. With cast, you have no such information.
> The message may have been received and understood, but you cannot know that.
>
> Cast is also asynchronous, while call isn't. Call gives a form of flow
> control.
>
> BR,
> Ulf W
>
>  ------------------------------
> *From:* erlang-questions-bounces@REDACTED [mailto:
> erlang-questions-bounces@REDACTED] *On Behalf Of *Ming Zhao(Jimmy)
> *Sent:* den 25 maj 2007 14:46
> *To:* erlang-questions@REDACTED
> *Subject:* [erlang-questions] questions about gen_server behaviour
>
> Could anyone explain these two functions below in details (better with
> example)?
> 1.synchronous request ----call
> Makes a synchronous call to the gen_server by sending a request and
> waiting until a reply arrives or a timout occurs.
> who sends the reply? what exactly is the reply?
> 2.asynchronous request ----cast
> Sends an asynchronous request to the gen_server and returns ok immediately
> who sends the ok?
>
> these 2 functions seems to me the same ,
> so confused by them ..
>
> BR
> Thanks
> Jimmy
>
> --
> Ming   Zhao
> Dobelnsgatan 2C  231
> 752 37 Uppsala, SWE
>
> Email: zhaoomingg@REDACTED
> Tel: +46 (0)736964077
> MSN:
> zhaoomingg@REDACTED
> Skype: zhaoomingg
>
>


-- 
Ming   Zhao
Dobelnsgatan 2C  231
752 37 Uppsala, SWE

Email: zhaoomingg@REDACTED
Tel: +46 (0)736964077
MSN:
zhaoomingg@REDACTED
Skype: zhaoomingg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From lenartlad@REDACTED  Fri May 25 15:24:02 2007
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Fri, 25 May 2007 15:24:02 +0200
Subject: [erlang-questions] questions about gen_server behaviour
In-Reply-To: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>
References: <4fe9e1b00705250545u2d70d831p45a24f48e62aab3e@mail.gmail.com>
Message-ID: <4656E372.3050305@volny.cz>

Ming Zhao(Jimmy) wrote:
> Could anyone explain these two functions below in details (better with 
> example)?
> 1.synchronous request ----call
> Makes a synchronous call to the gen_server ||by sending a request and 
> waiting until a reply arrives or a timout occurs.
> who sends the reply? what exactly is the reply?
Suppose you have two processes A and B. Both are gen_servers.
If A wants something from B, it does:
   ...
   {ok, Result} = gen_server:call(B, something),
   ...
This blocks A until a reply from B arrives or a timeout occurs
(which is 5 seconds by default I think).

If B implements the following in its gen_server callback module:
   ...
   handle_call(something, _From, _State) ->
     {reply, {ok, anything}, State};
   ...
A will receive atom {ok, anything}. Otherwise A will (eventually)
crash with timeout.

> 2.asynchronous request ----cast
> Sends an asynchronous request to the gen_server ||and returns |ok| 
> immediately
> who sends the ok?
No one. Atom ok is returned by the cast function itself (it is
its last expression).

> these 2 functions seems to me the same ,
> so confused by them ..
But they are not.

gen_server:cast(Pid, message) is a "gen_server way" for Pid ! message.
But gen_server:call is used to retrieve some information from another
process. It is implemented as two casts: one from the requestor process
to the provider process and one back. The gen_server:call machinery
ensures that process A (from the example above) will wake up *only*
when it receives reply to its request.

Hope this helps,

Ladislav Lenart



From me@REDACTED  Fri May 25 16:37:57 2007
From: me@REDACTED (KatolaZ)
Date: Fri, 25 May 2007 16:37:57 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070524131641.GK7300@katolaz.homeunix.net>
	
Message-ID: <20070525143757.GP7300@katolaz.homeunix.net>

On Fri, May 25, 2007 at 09:53:49PM +1000, Philip Robinson wrote:
> This might be a silly question, but after you compiled the code with
> c() did you load the module again with l()?  If not, you will still be
> running the older code in the shell.
> 

yes, philip, we did. And the result does not change, unfortunately.

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From ulf.wiger@REDACTED  Fri May 25 16:45:07 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 25 May 2007 16:45:07 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070525143757.GP7300@katolaz.homeunix.net>
References: <20070524131641.GK7300@katolaz.homeunix.net>
	<20070525143757.GP7300@katolaz.homeunix.net>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>


Actually, c() does load the new module.

>From c.erl in stdlib:

c(File, Opts0) when list(Opts0) ->
    Opts = [report_errors,report_warnings|Opts0],
    case compile:file(File, Opts) of
        {ok,Mod} ->                             %Listing file.
            machine_load(Mod, File, Opts);
        {ok,Mod,_Ws} ->                         %Warnings maybe turned
on.
            machine_load(Mod, File, Opts);
        Other ->                                %Errors go here
            Other
    end; 

BR,
Ulf W

> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of KatolaZ
> Sent: den 25 maj 2007 16:38
> To: Philip Robinson
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] Subtle behaviour of Erlang scheduler
> 
> On Fri, May 25, 2007 at 09:53:49PM +1000, Philip Robinson wrote:
> > This might be a silly question, but after you compiled the code with
> > c() did you load the module again with l()?  If not, you 
> will still be 
> > running the older code in the shell.
> > 
> 
> yes, philip, we did. And the result does not change, unfortunately.
> 
> HND
> 
> Enzo
> 
> --
> [ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet 
> Medialab ] [ me [at] katolaz.homeunix.net -- 
> http://katolaz.homeunix.net -- ] [ GNU/Linux User:#325780/ICQ 
> UIN: #258332181/GPG key ID 0B5F062F ] [ Fingerprint: 8E59 
> D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ] 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From me@REDACTED  Fri May 25 17:23:25 2007
From: me@REDACTED (KatolaZ)
Date: Fri, 25 May 2007 17:23:25 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
Message-ID: <20070525152325.GQ7300@katolaz.homeunix.net>

On Fri, May 25, 2007 at 04:45:07PM +0200, Ulf Wiger (TN/EAB) wrote:
> 
> Actually, c() does load the new module.
> 
> From c.erl in stdlib:
> 
> c(File, Opts0) when list(Opts0) ->
>     Opts = [report_errors,report_warnings|Opts0],
>     case compile:file(File, Opts) of
>         {ok,Mod} ->                             %Listing file.
>             machine_load(Mod, File, Opts);
>         {ok,Mod,_Ws} ->                         %Warnings maybe turned
> on.
>             machine_load(Mod, File, Opts);
>         Other ->                                %Errors go here
>             Other
>     end; 
> 
> BR,
> Ulf W
> 

So, Ulf, do you or anybody else have any idea about this strange
behaviour of erl scheduler ??? I hope someone can say if we hit a
big-bug in the priority management system, and what it the cause.

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From ulf.wiger@REDACTED  Fri May 25 17:38:33 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 25 May 2007 17:38:33 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070525152325.GQ7300@katolaz.homeunix.net>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
	<20070525152325.GQ7300@katolaz.homeunix.net>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>


KatolaZ wrote:
>
> So, Ulf, do you or anybody else have any idea about this 
> strange behaviour of erl scheduler ??? I hope someone can say 
> if we hit a big-bug in the priority management system, and 
> what it the cause.


No, I don't have an explanation, although I didn't 
look that hard at the problem. It did look weird.

In general, one should be very careful with the 
priority levels 'high' and 'max', since they make
it possible to starve all other processes. A high
priority process shouldn't be able to starve 
another high priority process, obviously.

BR,
Ulf W 



From me@REDACTED  Fri May 25 18:07:04 2007
From: me@REDACTED (KatolaZ)
Date: Fri, 25 May 2007 18:07:04 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
	<20070525152325.GQ7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
Message-ID: <20070525160704.GR7300@katolaz.homeunix.net>

On Fri, May 25, 2007 at 05:38:33PM +0200, Ulf Wiger (TN/EAB) wrote:
> 
> KatolaZ wrote:
> >
> > So, Ulf, do you or anybody else have any idea about this 
> > strange behaviour of erl scheduler ??? I hope someone can say 
> > if we hit a big-bug in the priority management system, and 
> > what it the cause.
> 
> 
> No, I don't have an explanation, although I didn't 
> look that hard at the problem. It did look weird.
> 
> In general, one should be very careful with the 
> priority levels 'high' and 'max', since they make
> it possible to starve all other processes. A high
> priority process shouldn't be able to starve 
> another high priority process, obviously.

I agree. The messy thing is that the behaviour changes depending on 
WHEN you lauch that process, as explained in the first mail ....
8-O

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From bob@REDACTED  Fri May 25 18:26:49 2007
From: bob@REDACTED (Bob Ippolito)
Date: Fri, 25 May 2007 09:26:49 -0700
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
	<20070525152325.GQ7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
Message-ID: <6a36e7290705250926webdac91n9d9f8aa316861ce2@mail.gmail.com>

On 5/25/07, Ulf Wiger (TN/EAB)  wrote:
>
> KatolaZ wrote:
> >
> > So, Ulf, do you or anybody else have any idea about this
> > strange behaviour of erl scheduler ??? I hope someone can say
> > if we hit a big-bug in the priority management system, and
> > what it the cause.
>
>
> No, I don't have an explanation, although I didn't
> look that hard at the problem. It did look weird.
>
> In general, one should be very careful with the
> priority levels 'high' and 'max', since they make
> it possible to starve all other processes. A high
> priority process shouldn't be able to starve
> another high priority process, obviously.
>

Unless "high" means "only schedule out at synchronization points".
It's not documented as such, but it sure could be given the behavior.

I guess the real question is why they think they need to use it in the
first place.

-bob


From me@REDACTED  Fri May 25 18:37:10 2007
From: me@REDACTED (KatolaZ)
Date: Fri, 25 May 2007 18:37:10 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6a36e7290705250926webdac91n9d9f8aa316861ce2@mail.gmail.com>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
	<20070525152325.GQ7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
	<6a36e7290705250926webdac91n9d9f8aa316861ce2@mail.gmail.com>
Message-ID: <20070525163710.GT7300@katolaz.homeunix.net>

On Fri, May 25, 2007 at 09:26:49AM -0700, Bob Ippolito wrote:
> 
> Unless "high" means "only schedule out at synchronization points".
> It's not documented as such, but it sure could be given the behavior.
> 
> I guess the real question is why they think they need to use it in the
> first place.
> 

No, bob, unfortunately thing are not so. Even if high would mean 
"only schedule at synchronisation points", that does not explain 
why that piece of code DOES NOT work if executed as the first piece of
code in the erl shell, while it DOES work when executed after the 
other version (the one with explicit timer:sleep) has been executed. 

According to us, it seems to be a serious flaw in priority
management. In a couple of words: "a bug, not a feature", even if we
were not able to discover where the flaw actually is, neither looking
at the scheduler source code (erl_process.c).... :-)

The problem is not if anybody would eventually need to use a high
priority process as we do in that piece of code. The question is why
using it in that way does not produce predictable effects in case
anybody would do, as expected from a reliable and predictable
scheduler.... :-)

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From als@REDACTED  Fri May 25 19:19:52 2007
From: als@REDACTED (Anthony Shipman)
Date: Sat, 26 May 2007 03:19:52 +1000
Subject: [erlang-questions] yaws and deflate
Message-ID: <200705260319.52124.als@iinet.net.au>

I've discovered that a yaws configuration file has undocumented server options 
such as 'deflate'.  Why is it not documented? Does it not work properly?
-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.


From joseerlang@REDACTED  Fri May 25 09:31:31 2007
From: joseerlang@REDACTED (Jose Antonio)
Date: Fri, 25 May 2007 19:31:31 +1200
Subject: [erlang-questions] yaws and deflate
In-Reply-To: <200705260319.52124.als@iinet.net.au>
References: <200705260319.52124.als@iinet.net.au>
Message-ID: <465690D3.5070008@gmail.com>

Anthony Shipman wrote:
> I've discovered that a yaws configuration file has undocumented server options 
> such as 'deflate'.  Why is it not documented? Does it not work properly?
>   
http://yaws.hyber.org/yman.yaws?page=yaws.conf

deflate = true | false
              Turns on or off deflate compression for a server

What is it?

http://carsten.codimi.de/gzip.yaws/


Regards


From cyberlync@REDACTED  Fri May 25 19:45:11 2007
From: cyberlync@REDACTED (Eric Merritt)
Date: Fri, 25 May 2007 10:45:11 -0700
Subject: [erlang-questions] some language changes
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F4FE32@esealmw115.eemea.ericsson.se>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>
	<004001c79d45$9b05c7a0$6401a8c0@rubicon>
	<6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>
	
	<6616D98C65DD514BA2E1DDC5F922315501F4FE32@esealmw115.eemea.ericsson.se>
Message-ID: 

On 5/25/07, Ulf Wiger (TN/EAB)  wrote:

>
> Regardless of whether the shell supports module definitions,
> I (and especially Mats Cronqvist, I believe) would like to
> see better support for editing insanely complex one-liners
> in the shell (multi-line editing would be a great help).
>
> Today, if you insert line breaks into a command, the
> repeated occurences of the prompt destroys your chances
> of copying and pasting the expression without post-
> processing. This leaves you with writing expressions that
> wrap several times, and they are a bear to edit (esp. with
> broken terminal windows).

The shell has the source. I would probably not be a great problem for
it to store that source and print it on demand, or even write it to a
file. That may solve a few problems that have been talked about.


From erlang@REDACTED  Fri May 25 20:23:54 2007
From: erlang@REDACTED (Hubert Matthews)
Date: Fri, 25 May 2007 19:23:54 +0100
Subject: [erlang-questions] Yaws with HTPPS authentication + HTTP
In-Reply-To: 
References: 	<6a36e7290705240712g5ae8a605kc8c9f96d9f241443@mail.gmail.com>		<6a36e7290705240814k5a946e4l21cec75a561d1aab@mail.gmail.com>		<6a36e7290705240927vba7781ch54be8da70ae8e157@mail.gmail.com>
	
Message-ID: <465729BA.7050107@oxyware.com>

Patrick wrote:
> Generally https data transfer is encrypted with ssl, but if i use 
> session identifiers then what is the difference between http and 
> https? Generally as i understand https is much more heavy on cpu
> than his counterpart. But without certificate authentication what
> is the advantage of https anyway?

On modern machines the overhead of SSL is insignificant except for
very large sites.  Even then the CPU usage is primarily when
establishing a session.  If security is a concern then just use SSL
for everything.  I doubt you'll notice the difference.  Even if you do
then the time and cost of fiddling with a software solution will
probably pay for an extra box.

-- 
Hubert Matthews         http://www.oxyware.com/
Software Consultant     hubert@REDACTED


From als@REDACTED  Fri May 25 21:29:27 2007
From: als@REDACTED (Anthony Shipman)
Date: Sat, 26 May 2007 05:29:27 +1000
Subject: [erlang-questions] yaws and deflate
In-Reply-To: <465690D3.5070008@gmail.com>
References: <200705260319.52124.als@iinet.net.au> <465690D3.5070008@gmail.com>
Message-ID: <200705260529.27235.als@iinet.net.au>

On Friday 25 May 2007 17:31, Jose Antonio wrote:
> Anthony Shipman wrote:
> > I've discovered that a yaws configuration file has undocumented server
> > options such as 'deflate'.  Why is it not documented? Does it not work
> > properly?
>
> http://yaws.hyber.org/yman.yaws?page=yaws.conf
>
> deflate = true | false
>               Turns on or off deflate compression for a server
>
> What is it?
>
> http://carsten.codimi.de/gzip.yaws/
>
>
> Regards

I was looking in the doc/yaws.pdf file which came with the source. It must be 
out of date.

Here's a useful patch:
*** src/yaws_server.erl.orig    Sat May 26 03:37:16 2007
--- src/yaws_server.erl Sat May 26 03:37:37 2007
***************
*** 3409,3414 ****
--- 3409,3416 ----
      true;
  compressible_mime_type("application/x-dvi") ->
      true;
+ compressible_mime_type("application/x-javascript") ->
+     true;
  compressible_mime_type(_) ->
      false.

-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.


From rickard.s.green@REDACTED  Fri May 25 23:48:43 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Fri, 25 May 2007 23:48:43 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070524100740.GF7300@katolaz.homeunix.net>
References: <20070524100740.GF7300@katolaz.homeunix.net>
Message-ID: <465759BB.7040105@ericsson.com>

This behavior is due to the fact that the code server runs on priority 
normal.

If the code for the timer module hasn't been loaded before you start 
your program, proc1 will block forever in the call to timer:sleep 
waiting for the code server to load the code for the timer module. Since 
the code server runs on normal prio, it wont be scheduled until the high 
prio run-queue is empty.

Try l(timer) before running you program, and everything will work as 
expected.

This behavior is in my opinion unfortunate, and we will probably 
increase the priority level of the code server some time in the future.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.


KatolaZ wrote:
> Dear Erlang Gurus,
> 
> we have tested the priority system of the processes and we are 
> experiencing a very strange behaviour.
> 
> Take a look at the simple code attached: if you run "test:test()" from
> the shell, the system hangs and "proc2" never ends blocking also
> "proc1" and the shell. We think that this is due to the fact that
> "proc2" hasn't any synchronization point, i.e. send or receive
> messages, etc. In any case, this is quite strange since also "proc1"
> has priority set to "high", so sooner or later, it should be selected
> to be scheduled.
> 
> Now kill the shell (with CTRL+C, you don't have any other option!),
> uncomment the "timer:sleep(1)" statement in proc2, recompile and
> everything seems to work fine: "proc2" and "proc3" exit, and the value
> reached by the counter proves that proc2 really runs with a higher
> priority than proc3.
> 
> Well, now, don't exit from the shell, comment again the
> "timer:sleep(1)" line, compile the code with "c(test)", and run it
> again. Well, now it works!!! But if you (once again) exit the shell,
> run "erl" again and launch "test:test()" once more.... it blocks!!!
> 
> What's behind this strange behaviour? An undocumented feature? A bug
> in scheduler initialization? Too many beers before sitting down for
> coding :-))) ???
> 
> All the best,
> --Enzo and Corrado
> 


From ulf.wiger@REDACTED  Sat May 26 00:22:07 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Sat, 26 May 2007 00:22:07 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <465759BB.7040105@ericsson.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>


Ooh, didn't think of that. (:

BTW, where is it documented that 'high' and 'max'
are strict priorities, and does this still hold
true in an SMP environment (i.e. can one high
priority process starve all normal priority 
processes)? 

The code server is a pretty heavy process to 
run on a blocking priority. One way to address
the problem would be to make all priorities 
non-strict, right?

BR,
Ulf W


> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of 
> Rickard Green
> Sent: den 25 maj 2007 23:49
> To: KatolaZ
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] Subtle behaviour of Erlang scheduler
> 
> This behavior is due to the fact that the code server runs on 
> priority normal.
> 
> If the code for the timer module hasn't been loaded before 
> you start your program, proc1 will block forever in the call 
> to timer:sleep waiting for the code server to load the code 
> for the timer module. Since the code server runs on normal 
> prio, it wont be scheduled until the high prio run-queue is empty.
> 
> Try l(timer) before running you program, and everything will 
> work as expected.
> 
> This behavior is in my opinion unfortunate, and we will 
> probably increase the priority level of the code server some 
> time in the future.
> 
> BR,
> Rickard Green, Erlang/OTP, Ericsson AB.
> 
> 
> KatolaZ wrote:
> > Dear Erlang Gurus,
> > 
> > we have tested the priority system of the processes and we are 
> > experiencing a very strange behaviour.
> > 
> > Take a look at the simple code attached: if you run 
> "test:test()" from 
> > the shell, the system hangs and "proc2" never ends blocking also 
> > "proc1" and the shell. We think that this is due to the fact that 
> > "proc2" hasn't any synchronization point, i.e. send or receive 
> > messages, etc. In any case, this is quite strange since also "proc1"
> > has priority set to "high", so sooner or later, it should 
> be selected 
> > to be scheduled.
> > 
> > Now kill the shell (with CTRL+C, you don't have any other option!), 
> > uncomment the "timer:sleep(1)" statement in proc2, recompile and 
> > everything seems to work fine: "proc2" and "proc3" exit, 
> and the value 
> > reached by the counter proves that proc2 really runs with a higher 
> > priority than proc3.
> > 
> > Well, now, don't exit from the shell, comment again the 
> > "timer:sleep(1)" line, compile the code with "c(test)", and run it 
> > again. Well, now it works!!! But if you (once again) exit 
> the shell, 
> > run "erl" again and launch "test:test()" once more.... it blocks!!!
> > 
> > What's behind this strange behaviour? An undocumented 
> feature? A bug 
> > in scheduler initialization? Too many beers before sitting down for 
> > coding :-))) ???
> > 
> > All the best,
> > --Enzo and Corrado
> > 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From saleyn@REDACTED  Sat May 26 01:39:44 2007
From: saleyn@REDACTED (Serge Aleynikov)
Date: Fri, 25 May 2007 18:39:44 -0500
Subject: [erlang-questions] unix domain socket driver
Message-ID: <465773C0.7020209@gmail.com>

Hi,

I've seen several implementations of a unix domain socket driver 
floating around.  Can anyone point me to an implementation that is used 
in production projects?

Serge


From robert.virding@REDACTED  Sat May 26 00:56:48 2007
From: robert.virding@REDACTED (Robert Virding)
Date: Sat, 26 May 2007 00:56:48 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <465537E5.7060803@ericsson.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>	<004001c79d45$9b05c7a0$6401a8c0@rubicon><6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>	<4654620E.40704@ericsson.com>	<6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se>
	<465537E5.7060803@ericsson.com>
Message-ID: <465769B0.6090405@telia.com>

Bengt Kleberg wrote:
> if i understand you correctly then epp does not use the io module 
> internally but have opened in raw mode. correct?

Epp does use (or at least used to use when it was written) the io module 
without any strangities. It uses the normal tokeniser straight out of 
the bag. That's why things are still . terminated things even with epp, 
and why you can't define a macro inside a function. (Like you can in "C").

> then it is a large (but trivial?) undertaking to change epp from 
> file:read() to io:fread().
> 
> 
>> This has been discussed in an earlier thread, and 
>> various workarounds have been presented. Mine was to
>> make a ram_file_io_server, which I thought was 
>> trivially easy (after some study of the file IO
>> system).
> 
> that is ok too. i have not done it, but it could be more fun than 
> changing epp to use the io module.
This is definitely the cleanest solution, add a function which takes an 
already open file. There is one problem though and that is when you use 
-include. Breaks the style.

Robert


From tony@REDACTED  Sat May 26 01:52:20 2007
From: tony@REDACTED (Tony Rogvall)
Date: Sat, 26 May 2007 01:52:20 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <20070525163710.GT7300@katolaz.homeunix.net>
References: <20070525143757.GP7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F505F6@esealmw115.eemea.ericsson.se>
	<20070525152325.GQ7300@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501F50683@esealmw115.eemea.ericsson.se>
	<6a36e7290705250926webdac91n9d9f8aa316861ce2@mail.gmail.com>
	<20070525163710.GT7300@katolaz.homeunix.net>
Message-ID: 

Hi!

Yes you found an interesting bug.

replace the
	timer:sleep(1000)
with
	receive
	after 1000 -> ok
	end

and it works! (at least for me, but with in GDB the code may work  
unmodified !!!)

The definition of timer:sleep is however:

sleep(T) ->
     receive
     after T -> ok
     end.

which looks very much like the code above ;-)

I think OTP team will have some debugging sessions, I tried a bit but  
could not find it..... yet :-)

/Tony






On 25 maj 2007, at 18.37, KatolaZ wrote:

> On Fri, May 25, 2007 at 09:26:49AM -0700, Bob Ippolito wrote:
>>
>> Unless "high" means "only schedule out at synchronization points".
>> It's not documented as such, but it sure could be given the behavior.
>>
>> I guess the real question is why they think they need to use it in  
>> the
>> first place.
>>
>
> No, bob, unfortunately thing are not so. Even if high would mean
> "only schedule at synchronisation points", that does not explain
> why that piece of code DOES NOT work if executed as the first piece of
> code in the erl shell, while it DOES work when executed after the
> other version (the one with explicit timer:sleep) has been executed.
>
> According to us, it seems to be a serious flaw in priority
> management. In a couple of words: "a bug, not a feature", even if we
> were not able to discover where the flaw actually is, neither looking
> at the scheduler source code (erl_process.c).... :-)
>
> The problem is not if anybody would eventually need to use a high
> priority process as we do in that piece of code. The question is why
> using it in that way does not produce predictable effects in case
> anybody would do, as expected from a reliable and predictable
> scheduler.... :-)
>
> HND
>
> Enzo
>
> -- 
> [ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
> [ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
> [ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
> [ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From tony@REDACTED  Sat May 26 01:57:22 2007
From: tony@REDACTED (Tony Rogvall)
Date: Sat, 26 May 2007 01:57:22 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <465759BB.7040105@ericsson.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
Message-ID: 

Wow!

Before my post was even on the list, you cracked it. Good catch! You  
are mister runtime system ;-)
And order is restored !

/Tony



On 25 maj 2007, at 23.48, Rickard Green wrote:

> This behavior is due to the fact that the code server runs on priority
> normal.
>
> If the code for the timer module hasn't been loaded before you start
> your program, proc1 will block forever in the call to timer:sleep
> waiting for the code server to load the code for the timer module.  
> Since
> the code server runs on normal prio, it wont be scheduled until the  
> high
> prio run-queue is empty.
>
> Try l(timer) before running you program, and everything will work as
> expected.
>
> This behavior is in my opinion unfortunate, and we will probably
> increase the priority level of the code server some time in the  
> future.
>
> BR,
> Rickard Green, Erlang/OTP, Ericsson AB.
>
>
> KatolaZ wrote:
>> Dear Erlang Gurus,
>>
>> we have tested the priority system of the processes and we are
>> experiencing a very strange behaviour.
>>
>> Take a look at the simple code attached: if you run "test:test()"  
>> from
>> the shell, the system hangs and "proc2" never ends blocking also
>> "proc1" and the shell. We think that this is due to the fact that
>> "proc2" hasn't any synchronization point, i.e. send or receive
>> messages, etc. In any case, this is quite strange since also "proc1"
>> has priority set to "high", so sooner or later, it should be selected
>> to be scheduled.
>>
>> Now kill the shell (with CTRL+C, you don't have any other option!),
>> uncomment the "timer:sleep(1)" statement in proc2, recompile and
>> everything seems to work fine: "proc2" and "proc3" exit, and the  
>> value
>> reached by the counter proves that proc2 really runs with a higher
>> priority than proc3.
>>
>> Well, now, don't exit from the shell, comment again the
>> "timer:sleep(1)" line, compile the code with "c(test)", and run it
>> again. Well, now it works!!! But if you (once again) exit the shell,
>> run "erl" again and launch "test:test()" once more.... it blocks!!!
>>
>> What's behind this strange behaviour? An undocumented feature? A bug
>> in scheduler initialization? Too many beers before sitting down for
>> coding :-))) ???
>>
>> All the best,
>> --Enzo and Corrado
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From datacompboy@REDACTED  Sat May 26 07:51:32 2007
From: datacompboy@REDACTED (datacompboy)
Date: Sat, 26 May 2007 06:51:32 +0100
Subject: [erlang-questions] Mnesia index foldl
References: 
Message-ID: <20070526055132.CFB745A510@mail.erlangsystems.com>


Is there any way to foldl() on index value?
I have in database some log, indexed on date (records have date and time fields, index on date only).
I need to select all on date, filter result on some other field, and calculate sum of 3rd field. f.e., standard statistic are:
stat(Date, Types) ->
  TypeFilter = fun(#stats{type=X})->ordsets:is_element(X, Types) end,
  CalcStat = fun(#stats{count=X}, S)->S+X  end,
  Log = mnesia:index_read(statlog, Date, #stats.date),
  TypeLog = lists:filter(TypeFilter, Log),
  Stat = lists:foldl(CalcStat, 0, TypeLog).
So it load into memory all log (up to 10k records) while they needs only for filtering and sum.

So, is there way to foldl() on index, without reading whole key records?
--
--- suicide proc near\n call death\n suicide endp
_________________________________________________________
Post sent from http://www.trapexit.org


From jsnx@REDACTED  Sat May 26 08:28:51 2007
From: jsnx@REDACTED (Jason Dusek)
Date: Fri, 25 May 2007 23:28:51 -0700
Subject: [erlang-questions] implementing a heartbeat
Message-ID: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>

I'm working on a system that updates a value at set intervals, so I
set up a server (can be queried for data), an 'evolve' function
(advances the state of the system) and a heartbeat. The heartbeat
kicks off the evolve function, waits for a reply and then forwards the
reply to the server at the right time. However, my heartbeat never
lets go of control! Here is the source:

    http://rafb.net/p/OZpMZ113.html

Ideally, I should be able to go into erl and type

  1> c(foo).
  2> S = foo:start(7, 100).
  3> foo:client(S).

which should spit out a few tuples. I appreciate any help the list can
offer on this matter -- I'm just trying Erlang out, doing something
deliberately useless and obtuse to wrap my head around the different
architectural possibilities.

-- 
_jsn


From jsnx@REDACTED  Sat May 26 08:36:46 2007
From: jsnx@REDACTED (Jason Dusek)
Date: Fri, 25 May 2007 23:36:46 -0700
Subject: [erlang-questions] implementing a heartbeat
In-Reply-To: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>
References: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>
Message-ID: <42784f260705252336o3dbdeb1bh82af8a492e7cefd7@mail.gmail.com>

On 5/25/07, Jason Dusek  wrote:
> I'm working on a system that updates a value at set
> intervals...Here is the source:
>
>     http://rafb.net/p/OZpMZ113.html

By the way, there are a few comments in there about a grid. These
comments are a little ambitious :) Right now, I'm working with an
integer.

--
_jsn


From tim@REDACTED  Sat May 26 08:51:44 2007
From: tim@REDACTED (Tim Bates)
Date: Sat, 26 May 2007 16:21:44 +0930
Subject: [erlang-questions] implementing a heartbeat
In-Reply-To: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>
References: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>
Message-ID: <4657D900.9070704@bates.id.au>

Jason Dusek wrote:
> However, my heartbeat never lets go of control!

Change this line:

   spawn(?MODULE, heartbeat(Server, Evolver, Delay)),

to:

   spawn(?MODULE, heartbeat, [Server, Evolver, Delay]),


HTH,
Tim.

-- 
Tim Bates
tim@REDACTED


From datacompboy@REDACTED  Sat May 26 09:02:08 2007
From: datacompboy@REDACTED (datacompboy)
Date: Sat, 26 May 2007 08:02:08 +0100
Subject: [erlang-questions] Parallel Sudoku Solver
References: 
Message-ID: <20070526070208.401AC5A510@mail.erlangsystems.com>



Andrew wrote:
PS Ooops forgot: http://www.acooke.org/cute/ParallelSu0.html
(end of quote)

% > io:fwrite("~s", [Piccy]).
% 4 5 1 | 1 4 6 | 8 3 5
% 8 3 7 | 9 2 5 | 7 1 9
% 2 6 9 | 7 8 3 | 6 4 2
% ---------------------
% 9 2 4 | 2 9 7 | 3 6 8
% 6 7 3 | 3 8 4 | 4 5 1
% 8 5 1 | 5 1 6 | 9 2 7
% ---------------------
% 7 8 9 | 6 1 3 | 5 7 2
% 5 6 2 | 2 9 8 | 1 4 6
% 1 3 4 | 4 7 5 | 3 9 8

sorry, that wrong answer for sudoku :) for sudoku not only in 3*3 cell must all numbers be uniq, but also in every line and column.
so, 
% 4 5 1 | 1 4 6 | 8 3 5
is incorrect line -- you have 1, 4, 5 twice, and no 2 at all...
--
--- suicide proc near\n call death\n suicide endp
_________________________________________________________
Post sent from http://www.trapexit.org


From csanto@REDACTED  Sat May 26 09:05:30 2007
From: csanto@REDACTED (Corrado Santoro)
Date: Sat, 26 May 2007 09:05:30 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
Message-ID: <4657DC3A.1070800@diit.unict.it>



Ulf Wiger (TN/EAB) wrote:
> BTW, where is it documented that 'high' and 'max'
> are strict priorities, and does this still hold
> true in an SMP environment (i.e. can one high
> priority process starve all normal priority 
> processes)? 
Indeed, this could be reasonable, IMHO, according to a "standard" 
priority system.


> The code server is a pretty heavy process to 
> run on a blocking priority. One way to address
> the problem would be to make all priorities 
> non-strict, right?
Or to think about a priority inheritance/ceiling system. If we think 
that a gen_server is something like an object and that a gen_server:call 
is something like a method call, it is reasonable to assume that a 
process receiving a message handles it running with the same priority of 
the sending process. That is, not only the receiving process uses the 
reductions left by the sending proces, but also its priority. This 
should definitively solve the problem by means of a state-of-art approach.

All the best,
--Corrado

-- 
==================================================================
Eng. Corrado Santoro, Ph.D.
University of Catania - ITALY - Engineering Faculty

Tel: +39 095 7382380        VoIP: sip:7035@REDACTED

Personal Home Page: http://www.diit.unict.it/users/csanto
     NUXI Home Page: http://nuxi.diit.unict.it
==================================================================



From datacompboy@REDACTED  Sat May 26 09:36:33 2007
From: datacompboy@REDACTED (datacompboy)
Date: Sat, 26 May 2007 08:36:33 +0100
Subject: [erlang-questions] Parallel Sudoku Solver
References: 
Message-ID: <20070526073634.078BE5A510@mail.erlangsystems.com>


Last your result ("The result just converged in just 148 exchanges:" also incorrect :)
457 321 865 -- two's "5"
836 548 497 -- two's "4"
etc.

I think, for sudoku you can't miss line/column.
--
--- suicide proc near\n call death\n suicide endp
_________________________________________________________
Post sent from http://www.trapexit.org


From andrew@REDACTED  Sat May 26 13:47:28 2007
From: andrew@REDACTED (andrew cooke)
Date: Sat, 26 May 2007 07:47:28 -0400 (CLT)
Subject: [erlang-questions] Parallel Sudoku Solver
In-Reply-To: <20070526070208.401AC5A510@mail.erlangsystems.com>
References:  <20070526070208.401AC5A510@mail.erlangsystems.com>
Message-ID: <5393.127.0.0.1.1180180048.squirrel@localhost>


Yeah, someone else pointed that out on reddit.  Turns out that I didn't
understand the rules of Sudoku.  There's good news, bad news, and good
news...

- Good news: The approach I used was general enough for the rule change to
be trivial to implement.

- Bad news: It then didn't converge after running for 8 hours.

- Good news: It was pretty easy to change the algorithm so that each
"block" of 9 digits works together as a "community" to maintain as an
invariant the use of the digits 1-9.  With that change it converges very
quickly.

The final code is at http://www.acooke.org/cute/CommunityS0.html

Andrew


>
> Andrew wrote:
> PS Ooops forgot: http://www.acooke.org/cute/ParallelSu0.html
> (end of quote)
>
> % > io:fwrite("~s", [Piccy]).
> % 4 5 1 | 1 4 6 | 8 3 5
> % 8 3 7 | 9 2 5 | 7 1 9
> % 2 6 9 | 7 8 3 | 6 4 2
> % ---------------------
> % 9 2 4 | 2 9 7 | 3 6 8
> % 6 7 3 | 3 8 4 | 4 5 1
> % 8 5 1 | 5 1 6 | 9 2 7
> % ---------------------
> % 7 8 9 | 6 1 3 | 5 7 2
> % 5 6 2 | 2 9 8 | 1 4 6
> % 1 3 4 | 4 7 5 | 3 9 8
>
> sorry, that wrong answer for sudoku :) for sudoku not only in 3*3 cell
> must all numbers be uniq, but also in every line and column.
> so,
> % 4 5 1 | 1 4 6 | 8 3 5
> is incorrect line -- you have 1, 4, 5 twice, and no 2 at all...
> --
> --- suicide proc near\n call death\n suicide endp
> _________________________________________________________
> Post sent from http://www.trapexit.org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>




From andrew@REDACTED  Sat May 26 13:52:27 2007
From: andrew@REDACTED (andrew cooke)
Date: Sat, 26 May 2007 07:52:27 -0400 (CLT)
Subject: [erlang-questions] Parallel Sudoku Solver
In-Reply-To: <20070526073634.078BE5A510@mail.erlangsystems.com>
References:  <20070526073634.078BE5A510@mail.erlangsystems.com>
Message-ID: <11670.127.0.0.1.1180180347.squirrel@localhost>


Ugh.  You're right.  I'll check it...

Thanks,
Andrew

> Last your result ("The result just converged in just 148 exchanges:" also
> incorrect :)
> 457 321 865 -- two's "5"
> 836 548 497 -- two's "4"
> etc.
>
> I think, for sudoku you can't miss line/column.
> --
> --- suicide proc near\n call death\n suicide endp
> _________________________________________________________
> Post sent from http://www.trapexit.org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>




From datacompboy@REDACTED  Sat May 26 15:23:50 2007
From: datacompboy@REDACTED (datacompboy)
Date: Sat, 26 May 2007 14:23:50 +0100
Subject: [erlang-questions] Parallel Sudoku Solver
References: 
Message-ID: <20070526132350.79EA75A510@mail.erlangsystems.com>


you use correct task, with only one solution possible, and here is it :
417 369 825
632 158 947
958 723 316
           
825 437 169
791 586 432
346 912 758
           
289 643 571
573 291 684
164 875 293
--
--- suicide proc near\n call death\n suicide endp
_________________________________________________________
Post sent from http://www.trapexit.org


From jsnx@REDACTED  Sat May 26 18:31:58 2007
From: jsnx@REDACTED (Jason Dusek)
Date: Sat, 26 May 2007 09:31:58 -0700
Subject: [erlang-questions] implementing a heartbeat
In-Reply-To: <4657D900.9070704@bates.id.au>
References: <42784f260705252328m26e3486bn2b643b8b974c0c9e@mail.gmail.com>
	<4657D900.9070704@bates.id.au>
Message-ID: <42784f260705260931s13629c54y823f9a187c6c639d@mail.gmail.com>

On 5/25/07, Tim Bates  wrote:
> Change this line:
>
>    spawn(?MODULE, heartbeat(Server, Evolver, Delay)),
>
> to:
>
>    spawn(?MODULE, heartbeat, [Server, Evolver, Delay]),

Ah, well -- there is unfortunately no vim plugin to detect absent mindedness.

Thank you.

-- 
_jsn


From m5@REDACTED  Sat May 26 21:18:09 2007
From: m5@REDACTED (Mike McNally)
Date: Sat, 26 May 2007 14:18:09 -0500
Subject: [erlang-questions] file:pread/3
Message-ID: <20070526191809.GD9536@works.com>

Am I missing something in the documentation of the "Location" argument
to file:pread?  The only notation I can get to work is a plain integer
offset. The documented forms like "{eof, Offset}" invariably give me an
einval error.

--
[ I love pre-moistened towelettes ] Mike McNally -- m5@REDACTED


From m5@REDACTED  Sat May 26 21:42:25 2007
From: m5@REDACTED (Mike McNally)
Date: Sat, 26 May 2007 14:42:25 -0500
Subject: [erlang-questions] file:pread/3
In-Reply-To: <20070526191809.GD9536@works.com>
References: <20070526191809.GD9536@works.com>
Message-ID: <20070526194225.GE9536@works.com>

On Sat, 26 May 2007, Mike McNally furiously typed:

> Am I missing something in the documentation of the "Location" argument
> to file:pread?  The only notation I can get to work is a plain integer
> offset. The documented forms like "{eof, Offset}" invariably give me an
> einval error.

Found my problem - apparently Locations like "{eof, -128}" don't work
for raw files (and I don't think that's noted, though it's probably
obvious to those who know how it really works).  It's very handy having
the source around :)



--
[ I love pre-moistened towelettes ] Mike McNally -- m5@REDACTED


From robert.virding@REDACTED  Sun May 27 00:54:44 2007
From: robert.virding@REDACTED (Robert Virding)
Date: Sun, 27 May 2007 00:54:44 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <4657DC3A.1070800@diit.unict.it>
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>	<6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
	<4657DC3A.1070800@diit.unict.it>
Message-ID: <4658BAB4.8020507@telia.com>

Corrado Santoro wrote:
> 
> Ulf Wiger (TN/EAB) wrote:
>> BTW, where is it documented that 'high' and 'max'
>> are strict priorities, and does this still hold
>> true in an SMP environment (i.e. can one high
>> priority process starve all normal priority 
>> processes)? 
> Indeed, this could be reasonable, IMHO, according to a "standard" 
> priority system.
> 
> 
>> The code server is a pretty heavy process to 
>> run on a blocking priority. One way to address
>> the problem would be to make all priorities 
>> non-strict, right?
> Or to think about a priority inheritance/ceiling system. If we think 
> that a gen_server is something like an object and that a gen_server:call 
> is something like a method call, it is reasonable to assume that a 
> process receiving a message handles it running with the same priority of 
> the sending process. That is, not only the receiving process uses the 
> reductions left by the sending proces, but also its priority. This 
> should definitively solve the problem by means of a state-of-art approach.

That could be devasting to a system if a critical server inherits the 
priority of the process which sent it a message. A low priority process 
could then block the system by sending messages to critical servers, 
which would then be blocked by normal level processes and potentially 
hang the system.

Another problem would be to determine *when* the receiving process 
actually inherits the priority. When the message arrives or when it is 
received?

On an SMP environment I would assume that the high priority processes 
take as many run-queues as are needed and leave the rest, if any, to 
lower priority processes. To completley block the system if they don't 
use all the resources seems odd.

Wouldn't it be possible to have one blocking high priority, 'max', and 
one which is non-blocking but is allowed in more often, 'high'. I don't 
know if this is the case already.

Robert


From matthias@REDACTED  Sun May 27 08:45:35 2007
From: matthias@REDACTED (Matthias Lang)
Date: Sun, 27 May 2007 08:45:35 +0200
Subject: [erlang-questions] file:pread/3
In-Reply-To: <20070526194225.GE9536@works.com>
References: <20070526191809.GD9536@works.com> <20070526194225.GE9536@works.com>
Message-ID: <18009.10511.823339.895311@antilipe.corelatus.se>

Mike McNally writes:

 > Found my problem - apparently Locations like "{eof, -128}" don't work
 > for raw files (and I don't think that's noted, 

It _is_ noted. Here's the manual page for file:pread/3 straight from
erlang.org:

   pread(IoDevice, Location, Number) -> {ok, Data} | {error, Reason}
   
     Types:
   
       IoDevice = io_device()
       Location -- see position/2
       Number = int()
       Data = [char()] | binary() | eof
       Reason = posix()
   
   Combines position/2 and read/2 in one operation, which is more
   efficient than calling them one at a time. If IoDevice has been
   opened in raw mode, some restrictions apply: Location is only
   allowed to be an integer; and the current position of the file is
   undefined after the operation.

Matthias
   


From kosik@REDACTED  Sun May 27 15:58:14 2007
From: kosik@REDACTED (Matej Kosik)
Date: Sun, 27 May 2007 15:58:14 +0200
Subject: [erlang-questions] is there something like #line
Message-ID: <46598E76.6080008@fiit.stuba.sk>

Hello,

Some languages provide mechanisms for "redefining" the current filename and line number. This is done via #line directive. It is not very useful if one writes the code in Erlang, but it is useful when the Erlang code is generated from some other file. For example from a noweb file. I can tangle the actual code so that before each code chunk will be placed correct

	# line  

command. This way it is possible to influence the compiler error messages and warnings so that they refer to the original file (and line number) rather than to the line number in the generated file.

Is there a similar directive in Erlang? I have tried to google it out, but with little luck. In `Erlang Reference Manual', section 7.2 there I see two interesting macros:

	?FILE.
	    The file name of the current module. 
	?LINE.
	    The current line number.

Unfortunatelly, when I tried to redefine it, the compiler rejected such redefinitions. Any hint is appreciated.

PS: I am still not 100% sure that using noweb with Erlang is a good idea. But I have used noweb elsewhere (with C and with Pict) so in my current interesting Erlang-task I decided to try it too.

Regards
-- 
Matej Kosik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: 

From me@REDACTED  Sun May 27 18:59:31 2007
From: me@REDACTED (KatolaZ)
Date: Sun, 27 May 2007 18:59:31 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <4658BAB4.8020507@telia.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
	<4657DC3A.1070800@diit.unict.it> <4658BAB4.8020507@telia.com>
Message-ID: <20070527165931.GW7300@katolaz.homeunix.net>

On Sun, May 27, 2007 at 12:54:44AM +0200, Robert Virding wrote:

> > Or to think about a priority inheritance/ceiling system. If we think 
> > that a gen_server is something like an object and that a gen_server:call 
> > is something like a method call, it is reasonable to assume that a 
> > process receiving a message handles it running with the same priority of 
> > the sending process. That is, not only the receiving process uses the 
> > reductions left by the sending proces, but also its priority. This 
> > should definitively solve the problem by means of a state-of-art approach.
> 
> That could be devasting to a system if a critical server inherits the 
> priority of the process which sent it a message. A low priority process 
> could then block the system by sending messages to critical servers, 
> which would then be blocked by normal level processes and potentially 
> hang the system.
> 

Yes, but what about letting a process to inherit caller's priority 
*only in case the caller has a higher priority* ?

In this way, if a high priority process sends messages to a low
priority one, the latter inherits high priority, speeding-up the
execution of code triggered by the incoming message. On the other
hand, if a low-priority process sends a message to a high-priority
one, nothing happens: The high priority process serves the message,
without changing its priority level.

It is true that priority levels are not widely used in the majority of
actual Erlang applications, but priority inversion, as explained
above, can sensibly speed-up execution in massively concurrent
applications......

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From andrew@REDACTED  Sun May 27 19:09:38 2007
From: andrew@REDACTED (andrew cooke)
Date: Sun, 27 May 2007 13:09:38 -0400 (CLT)
Subject: [erlang-questions] Parallel Sudoku Solver
In-Reply-To: <20070526132350.79EA75A510@mail.erlangsystems.com>
References:  <20070526132350.79EA75A510@mail.erlangsystems.com>
Message-ID: <13572.127.0.0.1.1180285778.squirrel@localhost>


For the record, the latest version, at
http://www.acooke.org/cute/ReducedRan0.html converges to the correct
solution in about 2 hours(*).

[I'm afraid the link contains language that may be NSFW - sorry]

Andrew

(*) I hope this isn't taken as criticism of Erlang - the long running time
reflects the hopelessly inefficient algorithm used, not the implementation
language.

> you use correct task, with only one solution possible, and here is it :
> 417 369 825
> 632 158 947
> 958 723 316
>
> 825 437 169
> 791 586 432
> 346 912 758
>
> 289 643 571
> 573 291 684
> 164 875 293
> --
> --- suicide proc near\n call death\n suicide endp
> _________________________________________________________
> Post sent from http://www.trapexit.org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>




From robert.virding@REDACTED  Mon May 28 00:41:27 2007
From: robert.virding@REDACTED (Robert Virding)
Date: Mon, 28 May 2007 00:41:27 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: 
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>	<200705212007.09584.als@iinet.net.au>	<9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com>
	
Message-ID: <465A0917.3000708@telia.com>

Sorry for the delay in commenting but I have been busy with other stuff.

Theway I see it there are two problems being dicussed here:

1) another syntax for strings
2) another representation for regular expressions

OK, some thoughts:

1) The basic problem is that there is quoting to allow "strange" 
characters to be entered.

While I don't think it would be really impossible to add something like 
Joe suggests it might cause problems at the token level if any specifier 
is allowed. It would be easy if you had a specifier to then call a 
function to parse the string, it would just have to observe the same 
protocol as the normal tokeniser.

An easier solution would be to introduce an alternate string form which 
has absolutely NO quoting at all. We use another delimiter, ~. So

X = ~[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*~

would work fine. To include ~ you double it ~~.

Y = ~string with a ~~ in it~

That is the only extra rule, all other characters go in literally. You 
could allow quoting it with \ but then you need to be able to quote \ 
with \\ and which solves nothing for regexps.

I would prefer to use backquote but I haven't worked out how to write it 
with this bloody swedish keyboard. Slash would look good but would 
probably be confused with the / operator.

How about // and only quoting / inside:

Z = //string with a \/ in it//

No, because then you would have to quote \ with \\ and we are back to 
where we started. You need no quoting only doubling to include string 
delimeter.

ZZ = //string with a // in it//

2) Using a more functional syntax to specify regexps would work well. I 
assume that this form would return the internal parsed form and not a 
string. My only question is how do we declare these functions to be 
special regexp functions? I suppose you could write:

X = regex (seq(any(".?!"), span("\"')]}")
                alt("\n", "\t", seq(" ",any(" \t\n"))),
                span(" \t\n")))

and then have a parse_transform. Or the compiler could recognise the 
regex/1 "call" and fix it. It might be difficult to add these functions 
now specials.

The major problem with this solution is that people won't be able to 
snip regexs directly out of Friedl's book but might actually be forced 
to understand them. :-)

I have absolutely no problems with doing something about this, but we 
need to decide which problem we are solving. How much are regular 
expressions ACTUALLY used in Erlang code? How much effort is it worth 
putting in to solve this problem?

Robert

ok wrote:
> On 21 May 2007, at 10:24 pm, Joe Armstrong wrote:
>    No - it changes the *syntax* of a string - normally you have to quote
>    backspashes
> 
>    Suppose I had a *simple* regexp like this:
> 
>       [.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*
> 
>    I'd like to say
> 
>       X = regexp "[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"
> 
>    and not the more obvious
> 
>       X =  "[.?!][]\\"')}]*\\\\($\\\\| $\\\\|\t\\\\|  \\\\)[ \\t\\n]*"
> 
> Let's look at this in two different ways.
> First, let's break the regexp up:
> 
>       [.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*
>       AAAAABBBBBBBBBCC(IJJ| KLL|MMOO|RSTT)UUUUUUUU
> 
> Note that regular expression syntax has weird quoting of its own.
> (One reason I want to write regexps in Erlang AS Erlang!)
> It looks as though [].... starts with an empty set, but in fact the
> right bracket is an element of the set.  It looks as though there
> are lots of backslashes, but (CC,JJ,LL,OO,TT), but on close
> inspection (how HARD this is to read!) this appears to presuppose
> a regular expression syntax in which the special meaning of (|) has
> to be turned ON with backslashes, instead of the usual syntax where
> backslashes turn the special meaning OFF.  (Just more reason NOT to
> want this construction.  Which of the many regular expression
> syntaxes do we actually get?)  Not only that, instead of \( \| \)
> we find doubled backslashes!  I don't know any regexp syntax that
> requires \\(...\\|...\\) for an alternation, and if I did, I would
> not want to use it.
> 
> So here's how I would like to write that:
> 
>      X = seq(any(".?!"), span("\"')]}"),
>               alt("\n", "\t", seq(" ",any(" \t\n"))),
>               span(" \t\n"))
> 
> This is BETTER than fancy regexp syntax, because it's just normal
> Erlang syntax that can include *any* computations we find useful.
> For example,
> 
> 	Stops = ".?!",
> 	Closers = "\"')]}",
> 	BigSpace = "\t\n",
> 	Space = " "++BigSpace,
> 	X = seq(any(Stops),span(Closers),
> 	        alt(any(BigSpace),seq(" ",any(Space)), span(Space))
> 
> Second, suppose for some reason we don't like function calls, and we
> do like regular expression syntax, with all the backslashes *that*
> requires.  Let me introduce you to the idea of a preprocessor.
> 
> Our input syntax will be
> 
> 	//
> 
> on one line by itself, possibly followed by a comma
> or semicolon, possibly followed by a comment.
> We want to replace this by
> 
> 	regexp:compile("")
> 
> where  is  with appropriate backslashes added,
> putting the comma or semicolon back if there was one.
> What do we need to quote?
> 	- double quotes
> 	- backslashes
> 
> Here we go.
> 
> 	#!/bin/awk -f
> 
> 	$0 ~ /^[ \t]*\/.*\/[,;]?[ \t]*(%.*)?$/ {
> 	    x = $0
> 	    match(x, /^[ \t]*\//)
> 	    head = substr(x, 1, RLENGTH-1)
> 	    x = substr(x, RLENGTH+1)
> 	    sub(/[ \t]*(%.*)?$/, "", x)
> 	    if (x ~ /[,;]$/) {
> 		tail = substr(x, length(x), 1)
> 		x = substr(x, 1, length(x) - 1)
> 	    } else {
> 		tail = ""
> 	    }
> 	    sub(/\/$/, "", x)
> 	    gsub(/["\\]/, "\\\\&", x)
> 	    print head "regexp:compile(\"" x "\")" tail
> 	    next
> 	}
> 	{
> 	    print
> 	}
> 
> I have tested this on some small examples and it seems to work.  It took
> some doing, precisely because regular expression syntax is so hard to
> work with, compared with normal Erlang syntax.
> 
> This preprocessor is just 16 SLOC of AWK.  For *THIS* we are to
> make Erlang lexical structure more complicated and to break editor
> support for the language?
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 


From horndude77@REDACTED  Mon May 28 01:10:37 2007
From: horndude77@REDACTED (Jay Anderson)
Date: Sun, 27 May 2007 23:10:37 +0000 (UTC)
Subject: [erlang-questions] Using different number types
Message-ID: 

>From what I've learned so far erlang has two numeric types: integers and floats.
I'd like to define some other types (rational, polynomial, vector, matrix) which
all support similar operations (add, subtract, multiply, divide, and various
comparison operators). I've already defined a rational type (see
http://en.literateprograms.org/Bernoulli_numbers_%28Erlang%29), but I'd like to
use all these types only through an interface. (I'm coming from the java and
ruby worlds where this is handled by defining objects which all implement the
same interface so if I'm way off base here let me know.) For example in making a
simple matrix module I'd like to be able to put rational numbers, polynomials,
floats, or whatever in a matrix and it will just work as long as that interface
it supported.

An idea I've thought of is to define a 'numeric operations' module which
represents these operations and knows how to delegate to the appropriate module.
There's still the problem of numeric coercion which I was thinking of solving
this in a way similar to ruby's coerce method. The problem with this is that
whenever a new type is created this 'numeric operations' module has to be
updated also.

Another idea would be to make each number a process and do something like: Num !
{self(), add, OtherNum}. and then receive the result. This way I don't need to
know anything about the types that I'm using in order to add them. I haven't
though much about the detail of this however.

What is the best way to handle this sort of problem in erlang?

(I know this is "off erlang's beaten path" but I'm having fun messing around.)

-----Jay



From ok@REDACTED  Mon May 28 06:12:02 2007
From: ok@REDACTED (ok)
Date: Mon, 28 May 2007 16:12:02 +1200
Subject: [erlang-questions] some language changes
In-Reply-To: <465A0917.3000708@telia.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>	<200705212007.09584.als@iinet.net.au>	<9b08084c0705210324p67bb5e1bhba34fb5cccd2db57@mail.gmail.com>
	
	<465A0917.3000708@telia.com>
Message-ID: <24B71F00-013F-4756-B7BE-84C07E98C6E5@cs.otago.ac.nz>

On 28 May 2007, at 10:41 am, Robert Virding wrote:
> The way I see it there are two problems being dicussed here:
>
> 1) another syntax for strings
> 2) another representation for regular expressions
>
> OK, some thoughts:
>
> 1) The basic problem is that there is quoting to allow "strange"  
> characters to be entered.

Note that " has to be counted as a "strange" character here.
If one had
	html "The programmer screamed "Help!""
it could get very confusing.

Alien strings, and long strings, are not new problems.  I would draw
the attention of readers to ECMA Eiffel, where we read

As the following syntax indicates, there are two ways to write a  
manifest string:
* A Basic_manifest_string, the most common case, is a sequence of
   characters in double quotes, as in "This text". Some of the  
characters
   may be special character codes, such as %N representing a new line.
   This variant is useful for such frequent applications as object  
names,
   texts of simple messages to be displayed, labels of buttons and other
   user interface elements, generally using fairly short and simple
   sequences of characters.  You may write the string over several lines
   by ending an interrupted line with a percent character % and starting
   the next one, after possible blanks and tabs, by the same character.
* A Verbatim_string is a sequence of lines to be taken exactly as they
   are (hence the name), bracketed by "{ at the end of the line that
   precedes the sequence and }" at the beginning of the line (or "[ and
   "] to left-align the lines). No special character codes apply. This
   is useful for embedding multi-line texts; applications include
   description entries of Notes clauses, inline C code, SQL or XML
   queries to be passed to some external program.

"{...}" keeps the enclosed text exactly as is; "[...]" strips leading
white space so that stuff can be indented nicely.  You can actually
have stuff between " and { or [, and between ] or } and ".

> An easier solution would be to introduce an alternate string form  
> which has absolutely NO quoting at all. We use another delimiter,  
> ~. So
>
> X = ~[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*~
>
> would work fine. To include ~ you double it ~~.

In Eiffel, just

	X := "[
	[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*
	]";

I'm not saying I particularly LIKE this notation, only that it IS an
existing notation used in a programming language with an ECMA standard,
so it could be worth a good look.  And of course any IDE which can
handle it in Eiffel should surely be able to handle it (or a slight
variation) in Erlang.  It's not particularly hard to lex, either.
There are two great advantages of this:
(a) Compared with Joe Armstrong's approach, it is ONE quoting
     convention to be used with ANY other embedded language.
(b) Compared with Robert Virding's suggestion, there need be NO change
     to the quoted text, not even doubling tildes.  With "{...}", there
     is no alteration at all; with "[...]" there is only as much
     alteration as your text editor's indentation command will do and
     even then no printing characters are magic.
(c) [So I'm bad at counting.]  No new characters are magic in Eiffel
     at all (nor would they be in Erlang).  The starting character for
     a multi-line verbatim string is the SAME character used for an
     ordinary string; it is just when a string ends in mid-air at the
     end of a line with a { or [ there that something different happens.
     So "foo", "{foo}", "bar[ugh]" and so on are no trouble.  If you can
     type Erlang strings, tuples, and lists on your keyboard, you can
     type Eiffel multi-line verbatim strings.
>


> 2) Using a more functional syntax to specify regexps would work  
> well. I assume that this form would return the internal parsed form  
> and not a string. My only question is how do we declare these  
> functions to be special regexp functions?

Whyever would we want to do THAT?  The whole point of using functional
form for regular expressions is that it ISN'T a special syntax and
DOESN'T require or get special treatment.

Let me give an example.  I'm currently writing a compiler front end for
a small C-like language in Haskell, using parser combinators.  One of
the things that makes like particularly EASY for me doing this is that
such combinators AREN'T special syntax in Haskell, so I can easily
roll my own.  For example, I can define

     pFold0 :: Parser t y -> (x -> y -> x) -> x -> Parser t x

     pFold0 p f x = p <*> pFold0 p f . f x <|> pSucceed x

"Given a parser p that returns interpretations of type y,
  an initial value x of type x, and a combining function
  f that combines an x and a y to give an x, match a sequence
  of things that p matches, and combine their results using f
  starting from x as initial value."

pSucceed matches an empty token list and returns its argument.
<|> is alternation.
p <*> q matches whatever p matches, and passes its result to q,
which returns a parser and matches whatever that matches.
. is function composition.

Having done that, I can then use pFold0 as a parser combinator on
a level with other parser combinators.  And this is one of the reasons
why the parsing part of the front end is tiny.

Now apply this to Erlang and regular expressions.  In Perl, case
handling is done by special weird backslash sequences.  But we can
do things like

	cilit(Cs) -> seq([any([tolower(C),toupper(C)]) || C <- Cs]).

and then use cilit(...) for case-independent literal matching anywhere,
INCLUDING WITH RUN-TIME DATA.

> I suppose you could write:
>
> X = regex (seq(any(".?!"), span("\"')]}")
>                alt("\n", "\t", seq(" ",any(" \t\n"))),
>                span(" \t\n")))

No, you would write

     X = regexp:compile(AST)

where AST is a regular expression abstract syntax tree made at run
time from run time data using any combination of library regular
expression functions and user-defined combinators.  In cases where
all the operands were known at compile time and no user-defined
combinators were involved, I suppose the compiler might pre-evaluate
such a thing, as the compiler may pre-evaluate anything it takes a
fancy to, but regular expressions are MUCH more useful if they are not
limited to what you know at compile time.  In particular, suppose you
decide that you want to match Vim regular expressions (which are not
the same as Perl or Java or AWK or ... ones, though they are similar).
You can write your own parser for them (not a very hard task) calling
the regular expression AST construction functions, but this ONLY works
if they can be called JUST LIKE ANY OTHER NORMAL FUNCTION.

What I am saying is that we get the most benefit from regular  
expressions
if (1) they are NOT built into the compiler, and
    (2) what IS provided in a library is a regexp AST kit (and compiler
        from ASTs to anything else, I care not what) which can be used
        by any number of special-purpose parsers and freely intermixed
        with user-defined functions.
>
> The major problem with this solution is that people won't be able  
> to snip regexs directly out of Friedl's book but might actually be  
> forced to understand them. :-)

They can't do that *NOW* because there is no such animal as "THE
regular expression syntax."  Right now, you cannot snip regexps
directly out of Friedl's book and expect to use them in Vim, or to
snip regexps directly out of the Vim book and expect to use them in
Java, or ... you get the picture.  Presumably Friedl's book explains
this.

>
> I have absolutely no problems with doing something about this, but  
> we need to decide which problem we are solving. How much are  
> regular expressions ACTUALLY used in Erlang code? How much effort  
> is it worth putting in to solve this problem?

The Erlang regular expression library is sufficiently limited (in its
coverage, in its features, and in its insistence that "regular  
expression"
is a kind of string, not a kind of expression, so that layering another
syntax on top of it is painfully hard) that its present level of use is
no indication of how much or what kind of use regular expressions might
have in Erlang if it were improved.

The great thing about the approach that I'm suggesting is that it  
requires
no changes to the Erlang language or compiler whatever; regular
expressions remain entirely a library issue.



From bengt.kleberg@REDACTED  Mon May 28 08:52:40 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Mon, 28 May 2007 08:52:40 +0200
Subject: [erlang-questions] Using different number types
In-Reply-To: 
References: 
Message-ID: <465A7C38.1050900@ericsson.com>

On 2007-05-28 01:10, Jay Anderson wrote:
...deleted
> An idea I've thought of is to define a 'numeric operations' module which
> represents these operations and knows how to delegate to the appropriate module.
> There's still the problem of numeric coercion which I was thinking of solving
> this in a way similar to ruby's coerce method. The problem with this is that
> whenever a new type is created this 'numeric operations' module has to be
> updated also.

to avoid changing the 'numeric operations' module you could make each 
number a tuple/record and have the appropriate module in the record.

-record( numeric_operation, {module, value}).

-module(numeric_operation).

-export([add/2]).

add( #numeric_operation(module=Module, value=Value1}, 
#numeric_operation(module=Module, value=Value2} ) ->
	Module:add( Value12, Value2 ).


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From bengt.kleberg@REDACTED  Mon May 28 09:13:28 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Mon, 28 May 2007 09:13:28 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <465769B0.6090405@telia.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>	<004001c79d45$9b05c7a0$6401a8c0@rubicon><6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>	<4654620E.40704@ericsson.com>	<6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se>
	<465537E5.7060803@ericsson.com> <465769B0.6090405@telia.com>
Message-ID: <465A8118.2010306@ericsson.com>

On 2007-05-26 00:56, Robert Virding wrote:
> Bengt Kleberg wrote:
>> if i understand you correctly then epp does not use the io module 
>> internally but have opened in raw mode. correct?
> 
> Epp does use (or at least used to use when it was written) the io module 
> without any strangities.

...deleted

>>
>>> This has been discussed in an earlier thread, and various workarounds 
>>> have been presented. Mine was to
>>> make a ram_file_io_server, which I thought was trivially easy (after 
>>> some study of the file IO
>>> system).

if the epp module uses the normal io module i do not understand why ulf 
wiger suggest using a ram_file_io_server.

why do we need the ability to have files?
they are handled by the file module which gives us the io device.

i admit that currently epp needs a file, and thus a ram_file_io_server. 
but if a small change to epp (allowing an io device as well as a file) 
then any io server (that is correct :-) would be ok. that way we could 
have any storage, instead of only a file.


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From ulf.wiger@REDACTED  Mon May 28 09:48:02 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 28 May 2007 09:48:02 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <465A8118.2010306@ericsson.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com><987E4FA7-E849-4666-B0D1-B9C9379DACF8@cs.otago.ac.nz>	<004001c79d45$9b05c7a0$6401a8c0@rubicon><6616D98C65DD514BA2E1DDC5F922315501F1B39D@esealmw115.eemea.ericsson.se>	<4654620E.40704@ericsson.com>	<6616D98C65DD514BA2E1DDC5F922315501F1B521@esealmw115.eemea.ericsson.se><465537E5.7060803@ericsson.com>
	<465769B0.6090405@telia.com> <465A8118.2010306@ericsson.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F82E8A@esealmw115.eemea.ericsson.se>

 
> Bengt Kleberg wrote:
> 
> if the epp module uses the normal io module i do not 
> understand why ulf wiger suggest using a ram_file_io_server.
> 
> why do we need the ability to have files?
> they are handled by the file module which gives us the io device.

I described the use of ram_file_io_server in this post:

http://www.erlang.org/pipermail/erlang-questions/2006-July/021348.html

To which you suggested using a string_io module, which would
of course work too. One could say that a ram file is just 
another type of io device that, in addition to supporting 
the io library, also supports file i/o (not that epp really 
needs that).

BR,
Ulf W



From raimo+erlang-questions@REDACTED  Mon May 28 10:00:36 2007
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Mon, 28 May 2007 10:00:36 +0200
Subject: [erlang-questions] :  Subtle behaviour of Erlang scheduler
In-Reply-To: <465759BB.7040105@ericsson.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
Message-ID: <20070528080036.GA11244@erix.ericsson.se>

I guess the solution for the problem at hand would be to make
sure all code for the high priority processes are loaded
before they are started, e.g by calling Module:module_info/0
on them. That trick is done by the code server itself
to ensure it can start without a running code server.



On Fri, May 25, 2007 at 11:48:43PM +0200, Rickard Green wrote:
> This behavior is due to the fact that the code server runs on priority 
> normal.
> 
> If the code for the timer module hasn't been loaded before you start 
> your program, proc1 will block forever in the call to timer:sleep 
> waiting for the code server to load the code for the timer module. Since 
> the code server runs on normal prio, it wont be scheduled until the high 
> prio run-queue is empty.
> 
> Try l(timer) before running you program, and everything will work as 
> expected.
> 
> This behavior is in my opinion unfortunate, and we will probably 
> increase the priority level of the code server some time in the future.
> 
> BR,
> Rickard Green, Erlang/OTP, Ericsson AB.
> 
> 
> KatolaZ wrote:
> > Dear Erlang Gurus,
> > 
> > we have tested the priority system of the processes and we are 
> > experiencing a very strange behaviour.
> > 
> > Take a look at the simple code attached: if you run "test:test()" from
> > the shell, the system hangs and "proc2" never ends blocking also
> > "proc1" and the shell. We think that this is due to the fact that
> > "proc2" hasn't any synchronization point, i.e. send or receive
> > messages, etc. In any case, this is quite strange since also "proc1"
> > has priority set to "high", so sooner or later, it should be selected
> > to be scheduled.
> > 
> > Now kill the shell (with CTRL+C, you don't have any other option!),
> > uncomment the "timer:sleep(1)" statement in proc2, recompile and
> > everything seems to work fine: "proc2" and "proc3" exit, and the value
> > reached by the counter proves that proc2 really runs with a higher
> > priority than proc3.
> > 
> > Well, now, don't exit from the shell, comment again the
> > "timer:sleep(1)" line, compile the code with "c(test)", and run it
> > again. Well, now it works!!! But if you (once again) exit the shell,
> > run "erl" again and launch "test:test()" once more.... it blocks!!!
> > 
> > What's behind this strange behaviour? An undocumented feature? A bug
> > in scheduler initialization? Too many beers before sitting down for
> > coding :-))) ???
> > 
> > All the best,
> > --Enzo and Corrado
> > 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From rickard.s.green@REDACTED  Mon May 28 12:33:31 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Mon, 28 May 2007 12:33:31 +0200
Subject: [erlang-questions] :  Subtle behaviour of Erlang scheduler
In-Reply-To: <20070528080036.GA11244@erix.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
Message-ID: <465AAFFB.6000705@ericsson.com>

Yes, this is the way to do it.

We had a discussion about these things this morning at OTP, and we have 
decided to leave things as they are (no propagation of prios, and leave 
code server on prio normal).

We reason like this: Priority levels other than normal, should normally 
not be used. When other priority levels are used, they have to be used 
with extreme care. The programmer have to take things like this into 
account.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.

Raimo Niskanen wrote:
> I guess the solution for the problem at hand would be to make
> sure all code for the high priority processes are loaded
> before they are started, e.g by calling Module:module_info/0
> on them. That trick is done by the code server itself
> to ensure it can start without a running code server.
> 
> 
> 
> On Fri, May 25, 2007 at 11:48:43PM +0200, Rickard Green wrote:
>> This behavior is due to the fact that the code server runs on priority 
>> normal.
>>
>> If the code for the timer module hasn't been loaded before you start 
>> your program, proc1 will block forever in the call to timer:sleep 
>> waiting for the code server to load the code for the timer module. Since 
>> the code server runs on normal prio, it wont be scheduled until the high 
>> prio run-queue is empty.
>>
>> Try l(timer) before running you program, and everything will work as 
>> expected.
>>
>> This behavior is in my opinion unfortunate, and we will probably 
>> increase the priority level of the code server some time in the future.
>>
>> BR,
>> Rickard Green, Erlang/OTP, Ericsson AB.
>>
>>
>> KatolaZ wrote:
>>> Dear Erlang Gurus,
>>>
>>> we have tested the priority system of the processes and we are 
>>> experiencing a very strange behaviour.
>>>
>>> Take a look at the simple code attached: if you run "test:test()" from
>>> the shell, the system hangs and "proc2" never ends blocking also
>>> "proc1" and the shell. We think that this is due to the fact that
>>> "proc2" hasn't any synchronization point, i.e. send or receive
>>> messages, etc. In any case, this is quite strange since also "proc1"
>>> has priority set to "high", so sooner or later, it should be selected
>>> to be scheduled.
>>>
>>> Now kill the shell (with CTRL+C, you don't have any other option!),
>>> uncomment the "timer:sleep(1)" statement in proc2, recompile and
>>> everything seems to work fine: "proc2" and "proc3" exit, and the value
>>> reached by the counter proves that proc2 really runs with a higher
>>> priority than proc3.
>>>
>>> Well, now, don't exit from the shell, comment again the
>>> "timer:sleep(1)" line, compile the code with "c(test)", and run it
>>> again. Well, now it works!!! But if you (once again) exit the shell,
>>> run "erl" again and launch "test:test()" once more.... it blocks!!!
>>>
>>> What's behind this strange behaviour? An undocumented feature? A bug
>>> in scheduler initialization? Too many beers before sitting down for
>>> coding :-))) ???
>>>
>>> All the best,
>>> --Enzo and Corrado
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
> 


From rickard.s.green@REDACTED  Mon May 28 12:35:05 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Mon, 28 May 2007 12:35:05 +0200
Subject: [erlang-questions] Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501F506F3@esealmw115.eemea.ericsson.se>
Message-ID: <465AB059.3080202@ericsson.com>

The 'max' priority is an undocumented feature for OTP internal use only.
Don't tell anyone about it :)

Scheduler threads will pick processes from the run queue(s) in the same
way as on the non-SMP system. When there exist high prio processes, only
high prio processes will be picked. Since there might be fewer runnable
high prio processes than scheduler threads, normal and low prio
processes may run at the same time as high prio processes.

The documentation of priorities could be improved. I've put this on the
todo list.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.

Ulf Wiger (TN/EAB) wrote:
> Ooh, didn't think of that. (:
> 
> BTW, where is it documented that 'high' and 'max'
> are strict priorities, and does this still hold
> true in an SMP environment (i.e. can one high
> priority process starve all normal priority 
> processes)? 
> 
> The code server is a pretty heavy process to 
> run on a blocking priority. One way to address
> the problem would be to make all priorities 
> non-strict, right?
> 
> BR,
> Ulf W
> 
> 
>> -----Original Message-----
>> From: erlang-questions-bounces@REDACTED 
>> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of 
>> Rickard Green
>> Sent: den 25 maj 2007 23:49
>> To: KatolaZ
>> Cc: erlang-questions@REDACTED
>> Subject: Re: [erlang-questions] Subtle behaviour of Erlang scheduler
>>
>> This behavior is due to the fact that the code server runs on 
>> priority normal.
>>
>> If the code for the timer module hasn't been loaded before 
>> you start your program, proc1 will block forever in the call 
>> to timer:sleep waiting for the code server to load the code 
>> for the timer module. Since the code server runs on normal 
>> prio, it wont be scheduled until the high prio run-queue is empty.
>>
>> Try l(timer) before running you program, and everything will 
>> work as expected.
>>
>> This behavior is in my opinion unfortunate, and we will 
>> probably increase the priority level of the code server some 
>> time in the future.
>>
>> BR,
>> Rickard Green, Erlang/OTP, Ericsson AB.
>>
>>
>> KatolaZ wrote:
>>> Dear Erlang Gurus,
>>>
>>> we have tested the priority system of the processes and we are 
>>> experiencing a very strange behaviour.
>>>
>>> Take a look at the simple code attached: if you run 
>> "test:test()" from 
>>> the shell, the system hangs and "proc2" never ends blocking also 
>>> "proc1" and the shell. We think that this is due to the fact that 
>>> "proc2" hasn't any synchronization point, i.e. send or receive 
>>> messages, etc. In any case, this is quite strange since also "proc1"
>>> has priority set to "high", so sooner or later, it should 
>> be selected 
>>> to be scheduled.
>>>
>>> Now kill the shell (with CTRL+C, you don't have any other option!), 
>>> uncomment the "timer:sleep(1)" statement in proc2, recompile and 
>>> everything seems to work fine: "proc2" and "proc3" exit, 
>> and the value 
>>> reached by the counter proves that proc2 really runs with a higher 
>>> priority than proc3.
>>>
>>> Well, now, don't exit from the shell, comment again the 
>>> "timer:sleep(1)" line, compile the code with "c(test)", and run it 
>>> again. Well, now it works!!! But if you (once again) exit 
>> the shell, 
>>> run "erl" again and launch "test:test()" once more.... it blocks!!!
>>>
>>> What's behind this strange behaviour? An undocumented 
>> feature? A bug 
>>> in scheduler initialization? Too many beers before sitting down for 
>>> coding :-))) ???
>>>
>>> All the best,
>>> --Enzo and Corrado
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> 



From bertil.karlsson@REDACTED  Mon May 28 12:51:40 2007
From: bertil.karlsson@REDACTED (Bertil Karlsson)
Date: Mon, 28 May 2007 12:51:40 +0200
Subject: [erlang-questions] ASN.1 asn1ct error
In-Reply-To: <20070525123030.D657819DC37C@mail.wavenet.lk>
References: <20070525123030.D657819DC37C@mail.wavenet.lk>
Message-ID: <465AB43C.9090800@ericsson.com>

Currently parameterized objects are not fully supported.
As soon as possible I will address this problem.

/Bertil Karlsson

Eranga Udesh wrote:
> Hi,
>
> Why could be the reason for asn1ct to return below error? I checked
> asn1ct:check_object_list/4, but I cannot find a case match for type pv. If
> you want me to send the asn.1 source to check the error, please let me know.
>
> asn1error:72:'Test':'ActivityTest2' {internal_error,
>                                      {error,
>                                       {'unknown object',
>                                        {pv,
>                                         {simpledefinedvalue,
>                                          32,
>                                          boundedExtension},
>                                         [{'Externalvaluereference',
>                                           32,
>                                           'IN-CS2-classes-test',
>                                           bound}]}},
>
>
> Thanks,
> - Eranga
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   


From me@REDACTED  Mon May 28 13:56:44 2007
From: me@REDACTED (KatolaZ)
Date: Mon, 28 May 2007 13:56:44 +0200
Subject: [erlang-questions] :  Subtle behaviour of Erlang scheduler
In-Reply-To: <465AAFFB.6000705@ericsson.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
Message-ID: <20070528115643.GA4649@katolaz.homeunix.net>

On Mon, May 28, 2007 at 12:33:31PM +0200, Rickard Green wrote:
> Yes, this is the way to do it.
> 
> We had a discussion about these things this morning at OTP, and we have 
> decided to leave things as they are (no propagation of prios, and leave 
> code server on prio normal).
> 
> We reason like this: Priority levels other than normal, should normally 
> not be used. When other priority levels are used, they have to be used 
> with extreme care. The programmer have to take things like this into 
> account.
> 

Users can take into account drawbacks of using higher priorities only
if they actually KNOW those drawbacks, and how they can arise :-)

IMHO, users should not be requested to know so much about Erlang
internals to decide if they can or cannot use a feature made available
by the language (such as higher priorities) and reported in the
official documentation. And the work-around of calling module_info
before executing a high-prio process is not so elegant, indeed... :-(
A real fix of these subtle behaviours would be a better solution,
expecially because we're talking about the process scheduler, and not
about an ancillary library....

I think that the Erlang environment itself should act safely (since it
has been built with safety and robustness in mind...), and ugly
behaviours should be avoided or at least well documented, if it is
actually not safe or possible to avoid them.

I agree with you: priority system lacks at least a complete and
consistent documentation, together with a couple of tiny examples
which explain what can go wrong, and WHY some code could not work as
expected.

The discussion about priority propagation/inversion is not related
with those things: it is just a proposal to speed-up message-passing
and interactions among processes with different priorities, and has
nothing to do with the actual behaviour of the scheduler.

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From ulf.wiger@REDACTED  Mon May 28 16:50:19 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 28 May 2007 16:50:19 +0200
Subject: [erlang-questions] :  Subtle behaviour of Erlang scheduler
In-Reply-To: <20070528080036.GA11244@erix.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net><465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501F83A0B@esealmw115.eemea.ericsson.se>


Raimo Niskanen wrote:
> 
> I guess the solution for the problem at hand would be to make 
> sure all code for the high priority processes are loaded 
> before they are started, e.g by calling Module:module_info/0 
> on them. That trick is done by the code server itself to 
> ensure it can start without a running code server.

For those who actually build OTP boot scripts, the command
line flag '-mode embedded' does the trick. In our experience,
it also has the effect of significantly shortening the 
startup time.

The drawback is that you must then explicitly load new 
modules to avoid getting 'undef' errors when calling 
them. This can be awkward during testing. There used to be
a -mode test, which loaded all code in the boot script,
but then enabled interactive code loading. I don't know
when it was removed, but I can't find it in any recent
OTP (I went back as far as R5B, which shows how often 
I've been using that feature. ;)

BR,
Ulf W



From david.hopwood@REDACTED  Mon May 28 17:25:28 2007
From: david.hopwood@REDACTED (David Hopwood)
Date: Mon, 28 May 2007 16:25:28 +0100
Subject: [erlang-questions] :  Subtle behaviour of Erlang scheduler
In-Reply-To: <465AAFFB.6000705@ericsson.com>
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
Message-ID: <465AF468.6080805@industrial-designers.co.uk>

Rickard Green wrote:
> Raimo Niskanen wrote:
> 
>> I guess the solution for the problem at hand would be to make
>> sure all code for the high priority processes are loaded
>> before they are started, e.g by calling Module:module_info/0
>> on them. That trick is done by the code server itself
>> to ensure it can start without a running code server.
>
> Yes, this is the way to do it.
> 
> We had a discussion about these things this morning at OTP, and we have 
> decided to leave things as they are (no propagation of prios, and leave 
> code server on prio normal).
> 
> We reason like this: Priority levels other than normal, should normally 
> not be used. When other priority levels are used, they have to be used 
> with extreme care. The programmer have to take things like this into 
> account.

I'm surprised at this conclusion. Most code should be able to consider the
existence of the code server process as an implementation detail. Certainly
the fact that this process runs at normal priority is an implementation
detail. What other facts about the Erlang/OTP implementation might we need
to know in order to be able to reliably run code at high priority?

-- 
David Hopwood 



From kenneth.lundin@REDACTED  Mon May 28 18:33:12 2007
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Mon, 28 May 2007 18:33:12 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465AF468.6080805@industrial-designers.co.uk>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
Message-ID: 

Hi,


We will add a better description about what the priority levels means and
how to use them. We will also add to the documentation that the use
of different priority levels than 'normal' is highly questionable.
The priority levels have been around for 10 years or more and the use
is to our knowledge VERY VERY RARE.

For all code in the Erlang/OTP distribution there are only
11 modules where process_flag(priority,Prio) is explicitly used.
Of these I would say that a handful of them can be questioned if they really
are necessary.

Summary:

It is important that we make clear in the documentation how priorities work and
that you have little or no reason to use them.

I hope we can close this discussion now.

/Regards Kenneth (Erlang/OTP team at Ericsson)

On 5/28/07, David Hopwood  wrote:
> Rickard Green wrote:
> > Raimo Niskanen wrote:
> >
> >> I guess the solution for the problem at hand would be to make
> >> sure all code for the high priority processes are loaded
> >> before they are started, e.g by calling Module:module_info/0
> >> on them. That trick is done by the code server itself
> >> to ensure it can start without a running code server.
> >
> > Yes, this is the way to do it.
> >
> > We had a discussion about these things this morning at OTP, and we have
> > decided to leave things as they are (no propagation of prios, and leave
> > code server on prio normal).
> >
> > We reason like this: Priority levels other than normal, should normally
> > not be used. When other priority levels are used, they have to be used
> > with extreme care. The programmer have to take things like this into
> > account.
>
> I'm surprised at this conclusion. Most code should be able to consider the
> existence of the code server process as an implementation detail. Certainly
> the fact that this process runs at normal priority is an implementation
> detail. What other facts about the Erlang/OTP implementation might we need
> to know in order to be able to reliably run code at high priority?
>
> --
> David Hopwood 
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf@REDACTED  Mon May 28 19:25:19 2007
From: ulf@REDACTED (Ulf Wiger)
Date: Mon, 28 May 2007 19:25:19 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
	
Message-ID: <8209f740705281025r223dbd38n36ad60c70da8e347@mail.gmail.com>

I agree. We've had a design rule for years saying that the
only place where 'high' priority is allowed is in "dispatch"
processes, such as middle men etc., which don't create
any work, but simply touch a job and pass it on. Putting
them on high priority is merely an attempt at minimizing
the per-call latency. I have no empirical evidence that it
actually does so on average.

If the code server were to be run at high priority, I don't
really see what's supposed to happen when it goes to the
file system to fetch the file; the file system can be arbitrarily
slow (try ClearCase, for example). Should the file system read
also run at high (blocking) priority?

We always run our systems with embedded code loading,
so if the module is not present, the call simply fails.

The documentation could state clearly that high priority
and on-demand code loading from disk simply do not play
well together. Luckily there's at least one remedy.

BR,
Ulf W


2007/5/28, Kenneth Lundin :
>
> Hi,
>
>
> We will add a better description about what the priority levels means and
> how to use them. We will also add to the documentation that the use
> of different priority levels than 'normal' is highly questionable.
> The priority levels have been around for 10 years or more and the use
> is to our knowledge VERY VERY RARE.
>
> For all code in the Erlang/OTP distribution there are only
> 11 modules where process_flag(priority,Prio) is explicitly used.
> Of these I would say that a handful of them can be questioned if they
> really
> are necessary.
>
> Summary:
>
> It is important that we make clear in the documentation how priorities
> work and
> that you have little or no reason to use them.
>
> I hope we can close this discussion now.
>
> /Regards Kenneth (Erlang/OTP team at Ericsson)
>
> On 5/28/07, David Hopwood 
> wrote:
> > Rickard Green wrote:
> > > Raimo Niskanen wrote:
> > >
> > >> I guess the solution for the problem at hand would be to make
> > >> sure all code for the high priority processes are loaded
> > >> before they are started, e.g by calling Module:module_info/0
> > >> on them. That trick is done by the code server itself
> > >> to ensure it can start without a running code server.
> > >
> > > Yes, this is the way to do it.
> > >
> > > We had a discussion about these things this morning at OTP, and we
> have
> > > decided to leave things as they are (no propagation of prios, and
> leave
> > > code server on prio normal).
> > >
> > > We reason like this: Priority levels other than normal, should
> normally
> > > not be used. When other priority levels are used, they have to be used
> > > with extreme care. The programmer have to take things like this into
> > > account.
> >
> > I'm surprised at this conclusion. Most code should be able to consider
> the
> > existence of the code server process as an implementation detail.
> Certainly
> > the fact that this process runs at normal priority is an implementation
> > detail. What other facts about the Erlang/OTP implementation might we
> need
> > to know in order to be able to reliably run code at high priority?
> >
> > --
> > David Hopwood 
> >
> > _______________________________________________
> > 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 csanto@REDACTED  Mon May 28 21:15:48 2007
From: csanto@REDACTED (Corrado Santoro)
Date: Mon, 28 May 2007 21:15:48 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>	<20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>
	
Message-ID: <465B2A64.90005@diit.unict.it>

Kenneth Lundin wrote:
> Summary:
> 
> It is important that we make clear in the documentation how priorities work and
> that you have little or no reason to use them.
> 
> I hope we can close this discussion now.
We can close the discussion, if you want, but IMHO it's quite strange to 
say, in an official documentation, that a feature is present but there's 
no reason to use it. A normal question, in this case, could be: why to 
not remove the feature, if it's useless?

In any case, I think that it's extermely rare to use Erlang for a 
CPU-bound computation like the simple code we posted. As far as I know, 
an Erlang program is made of many processes that exchange messages and 
use few CPU to process such messages. So the situation we experienced 
should never happen.

But this does not mean that, in my opinion, the Erlang priority system 
has a serious flaw and should be rethought. Probably, in a 
telecommunication system, priorities could not be so important, but if 
you use Erlang in real-time embedded environment (and it's argued that 
Erlang is for soft-real-time systems), such as automation or even 
robotics (and this is our application field), priorities are 
fundamental, together with correct or predictable behaviour of the 
scheduler.

Unless we want to exclude Erlang from some *very interesting* 
application fields....

All the best,
--Corrado

-- 
==================================================================
Eng. Corrado Santoro, Ph.D.
University of Catania - ITALY - Engineering Faculty

Tel: +39 095 7382380        VoIP: sip:7035@REDACTED

Personal Home Page: http://www.diit.unict.it/users/csanto
     NUXI Home Page: http://nuxi.diit.unict.it
==================================================================



From ulf.wiger@REDACTED  Mon May 28 22:52:58 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 28 May 2007 22:52:58 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465B2A64.90005@diit.unict.it>
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>	<20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>


Corrado Santoro wrote:
> 
> But this does not mean that, in my opinion, the Erlang 
> priority system has a serious flaw and should be rethought. 
> Probably, in a telecommunication system, priorities could not 
> be so important, but if you use Erlang in real-time embedded 
> environment (and it's argued that Erlang is for 
> soft-real-time systems),

Indeed, telecommunication systems are soft-real-time,
which means that it is sufficient to meet deadlines 
in a high percentage of the cases, but missing a 
deadline is not considered a fatal error.

Erlang shines in this regard, IMO, but in my experience,
process priorities don't do much to help in this type
of system. Thus the recommendation to use 'normal'
priority in the vast majority of cases.

What is important in a complex, massively concurrent
soft-real-time system, is a way of queueing jobs in
overload situations. In a hard-real-time system, 
you should never get into CPU overload, but in the 
types of system we build, not only must you be able
to handle it - you must be able to handle several
hundreds of percent overload without keeling over
(One of our requirements is that we should withstand
500% overload(*) without losing established calls.)
Also note that we must always handle emergency calls,
if at all possible, even when we are rejecting 
requests due to overload.

Rather than using process priorities here, we rely
on _job_prioritization_. We may employ perhaps a 
dozen processes to service a request, all processes
running on normal priority. The job itself is 
identified and prioritized according to type, e.g.

- initial setup request: rejectable
- emergency setup req: rejectable only as last resort
- hangup request: non-rejectable, but not high prio
- etc.

(*) Overload here meaning that the system is asked 
to handle more traffic than the maximum capacity. This
is solved by rejecting requests, which (again) is 
perfectly fine in a soft-real-time system, but not 
in a hard-real-time system.

Once this scheme is tuned, we typically run out of 
traffic generators before we're able to kill the 
system.

> such as automation or even robotics 
> (and this is our application field), priorities are 
> fundamental, together with correct or predictable behaviour 
> of the scheduler.
> 
> Unless we want to exclude Erlang from some *very 
> interesting* application fields....

If we can agree that the current priority scheme in
Erlang reflects its focus on soft real-time, as 
described above, we can probably also agree that 
this scheme is very different from what most real-time
environments, such as VxWorks and OSE Delta, use.

Aren't we then talking about supporting a much larger
number of priorities, rather than tweaking the 
semantics of the current scheme?

BR,
Ulf W



From billclem@REDACTED  Mon May 28 23:14:49 2007
From: billclem@REDACTED (Bill Clementson)
Date: Mon, 28 May 2007 14:14:49 -0700
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
Message-ID: 

I posted about Emacs/erlang-mode/Distel on my weblog today:
http://bc.tech.coop/blog/070528.html

Being new to Erlang, I would appreciate any comments/suggestions 
on ways experienced Erlang users "tweak" their .emacs files for 
Erlang use.

Thanks.

--
Bill Clementson



From mogorman@REDACTED  Tue May 29 00:08:46 2007
From: mogorman@REDACTED (Matthew O'Gorman)
Date: Mon, 28 May 2007 17:08:46 -0500
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
In-Reply-To: 
References: 
Message-ID: 

These are the additional emacs erlang stuff i use.
(add-hook 'erlang-mode-hook 'flyspell-prog-mode 1)
(add-hook 'erlang-mode-hook
          (function (lambda ()
                      (local-set-key (kbd "") 'indent-or-complete))))
(add-hook 'erlang-mode-hook
          (function (lambda ()
                      (local-set-key (kbd "\C-c\C-c")
'comment-or-uncomment-region))))



And just some general niceness

(require 'saveplace)
(setq-default save-place t)
(setq user-mail-address "mogorman@REDACTED")
(setq user-full-name "Matthew O'Gorman")
(fset 'yes-or-no-p 'y-or-n-p)
(defun my-turn-on-flyspell () (flyspell-mode 1))
(easy-mmode-define-global-mode
 global-flyspell-mode flyspell-mode my-turn-on-flyspell)
(global-flyspell-mode 1)
(global-set-key "\C-l" 'goto-line)         ; goto line
(defun indent-or-complete ()
  "Complete if point is at end of a word, otherwise indent line."
  (interactive)
  (if (looking-at "\\>")
      (dabbrev-expand nil)
    (indent-for-tab-command)
    ))


all very nice things, anyone have any other cool things?

mog
On 5/28/07, Bill Clementson  wrote:
> I posted about Emacs/erlang-mode/Distel on my weblog today:
> http://bc.tech.coop/blog/070528.html
>
> Being new to Erlang, I would appreciate any comments/suggestions
> on ways experienced Erlang users "tweak" their .emacs files for
> Erlang use.
>
> Thanks.
>
> --
> Bill Clementson
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From sanjaya@REDACTED  Tue May 29 05:56:04 2007
From: sanjaya@REDACTED (Sanjaya Vitharana)
Date: Tue, 29 May 2007 09:26:04 +0530
Subject: [erlang-questions] ASN.1 XER
Message-ID: <005b01c7a1a5$5f7c83e0$9a0810ac@wavenet.lk>

Hi 

Are there any plan to support XER ?

Thanks in advance,

Sanjaya Vitharana

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From fritchie@REDACTED  Tue May 29 06:17:59 2007
From: fritchie@REDACTED (Scott Lystig Fritchie)
Date: Mon, 28 May 2007 23:17:59 -0500
Subject: [erlang-questions] Lamport/logical clocks?
Message-ID: <200705290417.l4T4HxIE061537@snookles.snookles.com>

Greetings to all in distributed computing land.  I was about to do
some coding for a Lamport/logical clock ... because I need one and
it'd be easy to write ... but then stopped myself and decided to look
for prior Erlang art.

Armed with "grep" and a deadline before I needed to start cooking
supper, I didn't find much.

The closest that I've found is in the 'seq_trace' module in the
'kernel' OTP docs(*).  The "Serial" value described there looks
remarkably like a Lamport clock.  The fact that that serial # is
attached "for free" to all suitably traced processes is nifty...

1. ... except that seq_trace at the shell doesn't seem to work
correctly.  All of the trace flags are reset to their defaults
after/before? each shell command.  The same thing happens for send,
'receive', print, and label.

    (foo@REDACTED)5> self().
    <0.38.0>
    (foo@REDACTED)6> seq_trace:set_token(print, true).
    false
    (foo@REDACTED)7> seq_trace:set_token(print, true).
    false
    (foo@REDACTED)8> seq_trace:set_token(print, true).
    false
    (foo@REDACTED)9> self().                          
    <0.38.0>
    (foo@REDACTED)10> [ io:format("~p\n", [seq_trace:set_token(print, true)]) || _ <- lists:seq(1,5) ]. 
    false
    true
    true
    true
    true
    [ok,ok,ok,ok,ok]
    (foo@REDACTED)11> seq_trace:set_token(print, true).                            false
    
2. It looks like none of the apps bundled with OTP are using the
seq_trace Serial value of the Lamport clock for event sorting?

Inviso uses the (optional) timestamp, but that's the erlang:now()
value, and even an NTP time sync may not be good enough for a busy
system to avoid bogus event ordering.  I have enough problems with NTP
on or lab machines -- it shouldn't be hard, but apparently it is,
because their NTP daemons aren't running 1 time in 8.

Don't get me started about time drift in Linux virtual machines,
VMware and Xen both.  {sigh}

3. Have some docs drifted out of sync, like the ET app's User's Guide
saying "In the Megaco application of Erlang/OTP, the code is carefully
instrumented with calls to et:report_event/5." when "grep" couldn't
find a single one?

-Scott


From sanjaya@REDACTED  Tue May 29 07:03:54 2007
From: sanjaya@REDACTED (Sanjaya Vitharana)
Date: Tue, 29 May 2007 10:33:54 +0530
Subject: [erlang-questions] inets - http:request with invalid host ip
Message-ID: <008501c7a1ae$d9e8e9d0$9a0810ac@wavenet.lk>

Hi,

Of cource I put an ip which is not visible (and url also not there). 

2> test:test_url().
 URL="http://202.124.160.149/src/cf/1414/cricket/scoreline_odi/menu.php?key=1&session=a02857230011801002496201&ch=58&serverid=1"
 Time for Synchronous request 189028171 microseconds ResSync={error,etimedout}
 Time for Asynchronous request 188972235 microseconds ResASync={ok,
                                                                #Ref<0.0.0.119>}

Check the above results for time taken to execute http:request. (test code attached)

1.) It has taken a large amount of time to execute both requests
2.) And time difference to exit from Synchronous and Asynchronous request are approximately same.

Is this OK ???

What I am thinking is the time taken to perform Asynchronous request as not acceptable. Am I wrong ?
If the IP is not visible (or not available) Why such long time taken to give ANY result ?

Is this a bug ?

Thanks in advance,

Sanjaya Vitharana.


[root@REDACTED root]# uname -a
Linux es3 2.4.21-27.0.1.EL #1 Fri Dec 24 13:49:49 EST 2004 i686 i686 i386 GNU/Linux
[root@REDACTED root]# 
[root@REDACTED root]# erl -version
Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.5.4
[root@REDACTED root]#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: application/octet-stream
Size: 778 bytes
Desc: not available
URL: 

From mogorman@REDACTED  Tue May 29 08:19:16 2007
From: mogorman@REDACTED (Matthew O'Gorman)
Date: Tue, 29 May 2007 01:19:16 -0500
Subject: [erlang-questions] binary_comprehension support
Message-ID: 

Hi i was toying around with binary comprehension support but I cant
get a simple test of it to work for example
-module(test).
-compile([export_all, binary_comprehension]).

foo(Bin) -> [ X || <> <- Bin].

wont work no matter what type of binary i put in,  I have r11b4 and
binary_comprehension turned on in my compile flag but i get the
following error.

(mog@REDACTED)9> test:foo(<<1:8, 2:8>>).

=ERROR REPORT==== 29-May-2007::01:17:49 ===
Error in process <0.91.0> on node 'mog@REDACTED' with exit value:
{function_clause,[{test,'-foo/1-lc$^0/1-0-',[<<2
bytes>>]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

** exited: {function_clause,[{test,'-foo/1-lc$^0/1-0-',[<<1,2>>]},
                             {erl_eval,do_apply,5},
                             {shell,exprs,6},
                             {shell,eval_loop,3}]} **
(mog@REDACTED)10>


anyone have experience with this new feature?

mog


From vladdu55@REDACTED  Tue May 29 08:35:01 2007
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Tue, 29 May 2007 08:35:01 +0200
Subject: [erlang-questions] binary_comprehension support
In-Reply-To: 
References: 
Message-ID: <95be1d3b0705282335t14428627vafe0764886ece767@mail.gmail.com>

Hi!

On 5/29/07, Matthew O'Gorman  wrote:
> -module(test).
> -compile([export_all, binary_comprehension]).
>
> foo(Bin) -> [ X || <> <- Bin].
>
> (mog@REDACTED)9> test:foo(<<1:8, 2:8>>).

In this particular example, you might want to write something like

foo(Bin) -> [ X || <> <- Bin].

because your code will only match a binary with one element.

best regards,
Vlad


From bertil.karlsson@REDACTED  Tue May 29 08:25:59 2007
From: bertil.karlsson@REDACTED (Bertil Karlsson)
Date: Tue, 29 May 2007 08:25:59 +0200
Subject: [erlang-questions] ASN.1 XER
In-Reply-To: <005b01c7a1a5$5f7c83e0$9a0810ac@wavenet.lk>
References: <005b01c7a1a5$5f7c83e0$9a0810ac@wavenet.lk>
Message-ID: <465BC777.8030401@ericsson.com>

Yes, we have plans to implement that, though it has been postponed into 
some future release.

/Bertil

Sanjaya Vitharana wrote:
> Hi
>  
> Are there any plan to support XER ?
>  
> Thanks in advance,
>  
> Sanjaya Vitharana
>  


From kenneth.lundin@REDACTED  Tue May 29 08:47:04 2007
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Tue, 29 May 2007 08:47:04 +0200
Subject: [erlang-questions] Lamport/logical clocks?
In-Reply-To: <200705290417.l4T4HxIE061537@snookles.snookles.com>
References: <200705290417.l4T4HxIE061537@snookles.snookles.com>
Message-ID: 

On 5/29/07, Scott Lystig Fritchie  wrote:
> Greetings to all in distributed computing land.  I was about to do
> some coding for a Lamport/logical clock ... because I need one and
> it'd be easy to write ... but then stopped myself and decided to look
> for prior Erlang art.
>
> Armed with "grep" and a deadline before I needed to start cooking
> supper, I didn't find much.
>
> The closest that I've found is in the 'seq_trace' module in the
> 'kernel' OTP docs(*).  The "Serial" value described there looks
> remarkably like a Lamport clock.  The fact that that serial # is
> attached "for free" to all suitably traced processes is nifty...
>
The serial used in sequential tracing (seq_trace) is indeed working as a
Lamport clock.
Seq_trace is the support for sequential tracing and the the purpose
with the serial is to enable correct ordering the trace events.
The serial is not to be used for any other purposes than the ordering of
sequential trace events.
With sequential tracing it is possible to follow a "trace" from start to end
passing many different processes and the "trace" will not be disturbed by
any other events possibly handled by the involved processes.

> 1. ... except that seq_trace at the shell doesn't seem to work
> correctly.  All of the trace flags are reset to their defaults
> after/before? each shell command.  The same thing happens for send,
> 'receive', print, and label.

seq_trace works like this:
If the trace_token is set for a process A it will contaminate other processes
with the trace_token as well when A sends a message to another process.
If process A receives a message where the trace token is not set it's own
trace token will be reset automatically.

This is what happens when you set the trace token in the shell (for
the shell process). Before the next prompt the shell process will have
received
one or several messages without trace token and thus the trace token is reset.

You can try the following sequence in the shell to see that it actually works.

1> seq_trace:set_system_tracer(self()).
false
2> seq_trace:set_token(send,true).
false
3> flush().
Shell got {seq_trace,
              0,
              {send,
                  {0,1},
                  <0.24.0>,
                  <0.23.0>,
                  {io_request,<0.24.0>,<0.23.0>,{put_chars,<<"false">>}}}}
Shell got {seq_trace,0,
                     {send,{1,2},
                           <0.23.0>,
                           <0.21.0>,
                           {<0.23.0>,{put_chars,<<"false">>}}}}
Shell got {seq_trace,0,{send,{1,3},<0.23.0>,<0.24.0>,{io_reply,<0.23.0>,ok}}}
Shell got {seq_trace,0,
                     {send,{2,3},
                           <0.21.0>,
                           #Port<0.64>,
                           {<0.21.0>,{command,[0|<<"false">>]}}}}
Shell got {seq_trace,0,
                     {send,{3,4},
                           <0.24.0>,
                           <0.23.0>,
                           {io_request,<0.24.0>,<0.23.0>,{put_chars,"\n"}}}}
Shell got {seq_trace,0,
                     {send,{4,5},
                           <0.23.0>,
                           <0.21.0>,
                           {<0.23.0>,{put_chars,<<"\n">>}}}}
Shell got {seq_trace,0,{send,{4,6},<0.23.0>,<0.24.0>,{io_reply,<0.23.0>,ok}}}
Shell got {seq_trace,0,
                     {send,{5,6},
                           <0.21.0>,
                           #Port<0.64>,
                           {<0.21.0>,{command,[0|<<"\n">>]}}}}
ok
4>

This is a sequential trace over what happens in the shell process immediately
after that the seq_trace_set_token(send,true) has been executed.
In this case tracing only on sent messages (send,true) as a result of
the printout handling in the shell.

/Kenneth


>
>     (foo@REDACTED)5> self().
>     <0.38.0>
>     (foo@REDACTED)6> seq_trace:set_token(print, true).
>     false
>     (foo@REDACTED)7> seq_trace:set_token(print, true).
>     false
>     (foo@REDACTED)8> seq_trace:set_token(print, true).
>     false
>     (foo@REDACTED)9> self().
>     <0.38.0>
>     (foo@REDACTED)10> [ io:format("~p\n", [seq_trace:set_token(print, true)]) || _ <- lists:seq(1,5) ].
>     false
>     true
>     true
>     true
>     true
>     [ok,ok,ok,ok,ok]
>     (foo@REDACTED)11> seq_trace:set_token(print, true).                            false
>
> 2. It looks like none of the apps bundled with OTP are using the
> seq_trace Serial value of the Lamport clock for event sorting?
>
> Inviso uses the (optional) timestamp, but that's the erlang:now()
> value, and even an NTP time sync may not be good enough for a busy
> system to avoid bogus event ordering.  I have enough problems with NTP
> on or lab machines -- it shouldn't be hard, but apparently it is,
> because their NTP daemons aren't running 1 time in 8.
>
> Don't get me started about time drift in Linux virtual machines,
> VMware and Xen both.  {sigh}
>
> 3. Have some docs drifted out of sync, like the ET app's User's Guide
> saying "In the Megaco application of Erlang/OTP, the code is carefully
> instrumented with calls to et:report_event/5." when "grep" couldn't
> find a single one?
>
> -Scott
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From sanjaya@REDACTED  Tue May 29 08:36:16 2007
From: sanjaya@REDACTED (Sanjaya Vitharana)
Date: Tue, 29 May 2007 12:06:16 +0530
Subject: [erlang-questions] Fw: inets - http:request with invalid host ip
Message-ID: <00c201c7a1bb$ccf9fcc0$9a0810ac@wavenet.lk>

Hi,

I have done another test, check the code and results. If Asynchronous request hangs it causes to crash the server when 2nd request receives.

Thanks in advance,

Sanjaya Vitharana.

----- Original Message ----- 
From: Sanjaya Vitharana 
To: erlang-questions@REDACTED 
Sent: Tuesday, 29 May 2007 10:33 am
Subject: inets - http:request with invalid host ip


Hi,

Of cource I put an ip which is not visible (and url also not there). 

2> test:test_url().
 URL="http://202.124.160.149/src/cf/1414/cricket/scoreline_odi/menu.php?key=1&session=a02857230011801002496201&ch=58&serverid=1"
 Time for Synchronous request 189028171 microseconds ResSync={error,etimedout}
 Time for Asynchronous request 188972235 microseconds ResASync={ok,
                                                                #Ref<0.0.0.119>}

Check the above results for time taken to execute http:request. (test code attached)

1.) It has taken a large amount of time to execute both requests
2.) And time difference to exit from Synchronous and Asynchronous request are approximately same.

Is this OK ???

What I am thinking is the time taken to perform Asynchronous request as not acceptable. Am I wrong ?
If the IP is not visible (or not available) Why such long time taken to give ANY result ?

Is this a bug ?

Thanks in advance,

Sanjaya Vitharana.


[root@REDACTED root]# uname -a
Linux es3 2.4.21-27.0.1.EL #1 Fri Dec 24 13:49:49 EST 2004 i686 i686 i386 GNU/Linux
[root@REDACTED root]# 
[root@REDACTED root]# erl -version
Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.5.4
[root@REDACTED root]#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: application/octet-stream
Size: 778 bytes
Desc: not available
URL: 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: results-test1.txt
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.erl
Type: application/octet-stream
Size: 1189 bytes
Desc: not available
URL: 

From bengt.kleberg@REDACTED  Tue May 29 08:55:08 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Tue, 29 May 2007 08:55:08 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net>	<465759BB.7040105@ericsson.com>	<20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
Message-ID: <465BCE4C.4080307@ericsson.com>

On 2007-05-28 22:52, Ulf Wiger (TN/EAB) wrote:
> Corrado Santoro wrote:
>> But this does not mean that, in my opinion, the Erlang 
>> priority system has a serious flaw and should be rethought. 
>> Probably, in a telecommunication system, priorities could not 
>> be so important, but if you use Erlang in real-time embedded 
>> environment (and it's argued that Erlang is for 
>> soft-real-time systems),

1 imho embedded and real-time are orthogonal. ie, a system can be 
embedded and not real-time. (yes, i am including both hard and soft real 
time here).

2 when taking some computer courses at the local university i found that 
the view held by the teachers/researchers there was that priorities was 
not a correct way to design hard real time systems. they where only 
suitable for soft real time. since i was at the time working for a real 
time operating systems company selling a priority based real time system 
  for hard real time i tried to argue against this. it turned out that 
they had a much harder view of hard real time than we did. our operating 
system was originally created for soft real time.


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From me@REDACTED  Tue May 29 10:22:23 2007
From: me@REDACTED (KatolaZ)
Date: Tue, 29 May 2007 10:22:23 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
Message-ID: <20070529082223.GE4649@katolaz.homeunix.net>

On Mon, May 28, 2007 at 10:52:58PM +0200, Ulf Wiger (TN/EAB) wrote:
> 
> Corrado Santoro wrote:
> > 
> > But this does not mean that, in my opinion, the Erlang 
> > priority system has a serious flaw and should be rethought. 
> > Probably, in a telecommunication system, priorities could not 
> > be so important, but if you use Erlang in real-time embedded 
> > environment (and it's argued that Erlang is for 
> > soft-real-time systems),
> 
> Indeed, telecommunication systems are soft-real-time,
> which means that it is sufficient to meet deadlines 
> in a high percentage of the cases, but missing a 
> deadline is not considered a fatal error.
> 
> Erlang shines in this regard, IMO, but in my experience,
> process priorities don't do much to help in this type
> of system. Thus the recommendation to use 'normal'
> priority in the vast majority of cases.

Well, guys, I thought Erlang was really going to be used in many
different application fields, from telecommunication platforms to web
apps, from massively concurrent systems to distributed high
performance applications.

I also dreamed about Erlang as a real, affordable, safe and robust
alternative to many ugly and still widely-used languages and
platforms, such as C#/.net and Java, or at least I understood so,
attending the last two Erlang User Conferences in 2005 and 2006.
I also started to talk about erlang at university courses.....

But the last two mails, which suddenly close the Pandora Vase we
opened looking a little deep inside the process scheduler, simply
explain that Erlang developers (or at least Ericsson OTP group), has
little or no interest on having a real robust, affordable,
distributed, secure and real-time platform.

After we discovered a big bug in the scheduler, and reported it to the
community, the only answer we got was: we don't use that scheduler
code in OTP, this bug does not heavily affect OTP, processes in
telecom apps usually use normal priority and since telecom apps are
our main business and represent 90% of actual Erlang code, it does not
matter for us. 

Well, maybe it does not matter for telecom apps, maybe it does not
matter for 90% of Erlang code, maybe it is a so rarely used feature,
but ERLANG HAS A BUGGY SCHEDULER, EVEN IF YOU DON'T WANT TO ADMIT IT. 

The discussion is closed, also for me. But I would rather prefer to
avoid this kind of mails......

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From ulf.wiger@REDACTED  Tue May 29 11:02:23 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Tue, 29 May 2007 11:02:23 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529080444.GC4649@katolaz.homeunix.net>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>

 
KatolaZ wrote:
> 
> Well, guys, I thought Erlang was really going to be used in 
> many different application fields, from telecommunication 
> platforms to web apps, from massively concurrent systems to 
> distributed high performance applications.

It _is_ used in telecommunication platforms, web apps,
massively concurrent systems to distributed high 
performance platforms. It is also used in banking and
invoicing systems.


> I also dreamed about Erlang as a real, affordable, safe and 
> robust alternative to many ugly and still widely-used 
> languages and platforms, such as C#/.net and Java, or at 
> least I understood so, attending the last two Erlang User 
> Conferences in 2005 and 2006.
> I also started to talk about erlang at university courses.....
>
> But the last two mails, which suddenly close the Pandora Vase 
> we opened looking a little deep inside the process scheduler, 
> simply explain that Erlang developers (or at least Ericsson 
> OTP group), has little or no interest on having a real 
> robust, affordable, distributed, secure and real-time platform.

We must have been talking past each other then.
My mail attempted to convey the message that we've 
found OTP to perform excellently in soft-real-time
systems. There have been discussions before about
"fixing" the process priorities in Erlang, but they 
usually end up in lack of consensus regarding what 
would be a better priority system. 

To really get to the bottom of how priorities work,
you should also analyse the effects of using 
selective receive. It's a very powerful construct,
but one of the drawbacks is that you make it much
more difficult to reason formally about reachability
and, I would assume, reactivity. This, and the fact
that Erlang tends to be used for extremely complex
soft-real-time systems, makes it very difficult to
predict the actual effects of different process
priority schemes.

I tried to highlight this. I did NOT mean to say
that because of this, we do not want to support
priority schemes that would be more suitable in
other applications. Obviously, if an application
works best if all processes run on normal priority,
this is simple enough to accomplish, even if there
are 256 priority levels available.

This should probably be documented, preferably with
a deep discussion on the challenges involved.

(Also, to clarify, Bengt and I are users of Erlang,
and have little to say about what they choose to 
implement. Like other users, we can request 
changes and new features. Since we happen to 
represent the largest Erlang-based product line,
we may have a bit more influence than some, but
we don't speak for OTP. Kenneth does.)

 
> After we discovered a big bug in the scheduler, and
> reported it to the community, the only answer we got
> was: we don't use that scheduler code in OTP,

No, this is not what the answer was.

Richard Green explained that it was not, in fact,
a scheduler bug (and if I understand him correctly,
your example would most likely not have locked up in 
an SMP environment with a sufficient amount of 
scheduler threads.)

The problem was unfortunate interaction between your
process and the code loader. The code loader, sensibly,
runs on normal priority. Its job is to fetch code from
the file system (or possibly from another erlang node
on the network), and this job shouldn't run as a 
blocking high-priority task - obviously, the file 
system is far too slow, and would potentially block
all work in the VM for a significant amount of time.

(Perhaps one way to address this problem would be 
to have the error handler detect that the calling
process is running on high priority, and then 
simply raise an exception if the code isn't loaded.
This would at least be better than calling on the
code loader, since that obviously has disastrous
consequences. In effect, high priority would mean
that you opt out of interactive code loading, which
I think is also fairly logical.)

If you want to run a process on high priority, it 
is advisable to make sure that all the code that this
process needs to execute has been loaded into memory.
This should be documented in big boldface print.

Now, Erlang has support for making sure that all the
code is available, and loaded, before applications 
are started. It's called embedded mode, and when 
enabled, it will load all code listed in the boot 
script.

If you want to use Erlang for applications where 
reactivity is of the essence, you should definitely
use embedded code loading.

BR,
Ulf W



From oscar@REDACTED  Tue May 29 11:04:00 2007
From: oscar@REDACTED (=?UTF-8?B?T3NjYXIgSGVsbHN0csO2bQ==?=)
Date: Tue, 29 May 2007 10:04:00 +0100
Subject: [erlang-questions] is there something like #line
In-Reply-To: <46598E76.6080008@fiit.stuba.sk>
References: <46598E76.6080008@fiit.stuba.sk>
Message-ID: <465BEC80.4040305@erlang-consulting.com>

Hi all,

Matej Kosik wrote:
> Hello,
> 
> Some languages provide mechanisms for "redefining" the current filename and line number. This is done via #line directive. It is not very useful if one writes the code in Erlang, but it is useful when the Erlang code is generated from some other file. For example from a noweb file. I can tangle the actual code so that before each code chunk will be placed correct
> 
> 	# line  
> 
> command. This way it is possible to influence the compiler error messages and warnings so that they refer to the original file (and line number) rather than to the line number in the generated file.
> 
> Is there a similar directive in Erlang? I have tried to google it out, but with little luck. In `Erlang Reference Manual', section 7.2 there I see two interesting macros:
> 
> 	?FILE.
> 	    The file name of the current module. 
> 	?LINE.
> 	    The current line number.
 >
> 
> Unfortunatelly, when I tried to redefine it, the compiler rejected such redefinitions. Any hint is appreciated.
> 
> PS: I am still not 100% sure that using noweb with Erlang is a good idea. But I have used noweb elsewhere (with C and with Pict) so in my current interesting Erlang-task I decided to try it too.
> 
> Regards
> 
> 

Interesting, I would have thought that putting the following before any 
definition of FILE/LINE macros would work.
-undef(LINE).
-undef(FILE).

Using the following code, test/0 returns the actual line number, not 0.
-module(test).
-compile(export_all).

-undef(LINE).
-define(LINE, 0).


start() -> ?LINE.

Best Regards
-- 
Oscar Hellstr?m, oscar@REDACTED
Erlang Training and Consulting
http://www.erlang-consulting.com/


From sean.hinde@REDACTED  Tue May 29 11:08:42 2007
From: sean.hinde@REDACTED (Sean Hinde)
Date: Tue, 29 May 2007 10:08:42 +0100
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529082223.GE4649@katolaz.homeunix.net>
References: <20070529082223.GE4649@katolaz.homeunix.net>
Message-ID: <599F0BD4-C05B-472D-8C94-74EB9B5F8EF8@gmail.com>


On 29 May 2007, at 09:22, KatolaZ wrote:

>
> After we discovered a big bug in the scheduler, and reported it to the
> community, the only answer we got was: we don't use that scheduler
> code in OTP, this bug does not heavily affect OTP, processes in
> telecom apps usually use normal priority and since telecom apps are
> our main business and represent 90% of actual Erlang code, it does not
> matter for us.

I have been following this thread with interest, and I remember it  
quite differently to your description. What I saw was one mail from  
Rickard Green saying that the issue would be fixed in a future  
release, and a number of other people offering workarounds until that  
time, along with their experiences. I was rather heartened by this.

>
> Well, maybe it does not matter for telecom apps, maybe it does not
> matter for 90% of Erlang code, maybe it is a so rarely used feature,
> but ERLANG HAS A BUGGY SCHEDULER, EVEN IF YOU DON'T WANT TO ADMIT IT.

See above.

>
> The discussion is closed, also for me. But I would rather prefer to
> avoid this kind of mails......

Well, don't write them :-)

Sean



From vladdu55@REDACTED  Tue May 29 11:16:36 2007
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Tue, 29 May 2007 11:16:36 +0200
Subject: [erlang-questions] is there something like #line
In-Reply-To: <465BEC80.4040305@erlang-consulting.com>
References: <46598E76.6080008@fiit.stuba.sk>
	<465BEC80.4040305@erlang-consulting.com>
Message-ID: <95be1d3b0705290216i6eea059l85bfb355cf042aa4@mail.gmail.com>

Hi,

> Matej Kosik wrote:
> > Some languages provide mechanisms for "redefining" the current filename and line number. This is done via #line directive.
> >
> > Is there a similar directive in Erlang? I have tried to google it out, but with little luck. In `Erlang Reference Manual', section 7.2 there I see two interesting macros:
> >
> >       ?FILE.
> >           The file name of the current module.
> >       ?LINE.
> >           The current line number.

These are handled by the preprocessor in a special way, and so can't
be redefined.

The solution is to use the for example
  -file("path/to/other/file", 34).

best regards,
Vlad


From ingela@REDACTED  Tue May 29 11:18:36 2007
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Tue, 29 May 2007 11:18:36 +0200
Subject: [erlang-questions] inets - http:request with invalid host ip
	(Sanjaya Vitharana)
In-Reply-To: 
References: 
Message-ID: <465BEFEC.7000207@erix.ericsson.se>


> Hi,
>
> Of cource I put an ip which is not visible (and url also not there). 
>
> 2> test:test_url().
>  URL="http://202.124.160.149/src/cf/1414/cricket/scoreline_odi/menu.php?key=1&session=a02857230011801002496201&ch=58&serverid=1"
>  Time for Synchronous request 189028171 microseconds ResSync={error,etimedout}
>  Time for Asynchronous request 188972235 microseconds ResASync={ok,
>                                                                 #Ref<0.0.0.119>}
>
> Check the above results for time taken to execute http:request. (test code attached)
>
> 1.) It has taken a large amount of time to execute both requests
> 2.) And time difference to exit from Synchronous and Asynchronous request are approximately same.
>
> Is this OK ???
>
> What I am thinking is the time taken to perform Asynchronous request as not acceptable. Am I wrong ?
> If the IP is not visible (or not available) Why such long time taken to give ANY result ?
>
> Is this a bug ?
>   
Which version of inets are you using? I just tried your URL and for a  
synchronous request
I got {ok,{{"HTTP/1.1",503,"Service Unavailable"}, ...  after some time 
and the asynchronous
version almost immediately  returned  {ok, #Ref<0.0.0.97>} as expected.

Regards Ingela - OTP team





From me@REDACTED  Tue May 29 11:26:29 2007
From: me@REDACTED (me@REDACTED)
Date: Tue, 29 May 2007 11:26:29 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
Message-ID: <20070529092629.GA25656@katolaz.homeunix.net>

On Tue, May 29, 2007 at 11:02:23AM +0200, Ulf Wiger (TN/EAB) wrote:
>  
> (Also, to clarify, Bengt and I are users of Erlang,
> and have little to say about what they choose to 
> implement. Like other users, we can request 
> changes and new features. Since we happen to 
> represent the largest Erlang-based product line,
> we may have a bit more influence than some, but
> we don't speak for OTP. Kenneth does.)

Dear Ulf, I know you're not talking on behalf of OTP group :-) My mail
would just say that if we (the community of Erlang users and
developers) want Erlang to be used as a general-purpose robust
solution for different problems and applications, we should
communicate, talk, discuss, exchange ideas and propose new or better
features for the platform we use on our every-day work (or fun),
thinking also to new and possibly unexplored fields where Erlang
features can be exploited.

I'm trying to do so. I'm trying to give my contribute to the Erlang
community, as many people have done in the last years. Without
suggestions, proposals, work and code from people *outside* the OTP
group, Erlang would perhaps remain one of the unknown "company
languages". 

Regards

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From bjorn@REDACTED  Tue May 29 11:55:10 2007
From: bjorn@REDACTED (Bjorn Gustavsson)
Date: 29 May 2007 11:55:10 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529082223.GE4649@katolaz.homeunix.net>
References: <20070529082223.GE4649@katolaz.homeunix.net>
Message-ID: 

KatolaZ  writes:
> 
> Well, maybe it does not matter for telecom apps, maybe it does not
> matter for 90% of Erlang code, maybe it is a so rarely used feature,
> but ERLANG HAS A BUGGY SCHEDULER, EVEN IF YOU DON'T WANT TO ADMIT IT. 

Using capitals letters doesn't make your statement more true.
Rather it seems that you are shouting.

That the scheduler does not have all the features you think you'll need
does not mean that it is buggy.

If we just had unlimited time, people and money, we would fix everything
that every single user demanded so that Erlang could be used for every
possible application. The reality is that we must base our developement
on priorities and first work on features that will benefit the majority
of the users.

In this case, the behaviour of the code loader is unfortunate, but it is
extremely easy to work around once you know about it. Trying to fix the
issue in OTP by giving the code server higher priority is not as trivial
as it might seem. We would have to make sure that the change would not
break existing applications. Also, the code server in turn calls other
processes to actually load the code from the disk, so those processes
would have to have their priorities raised too. All this means that there
is a risk of breaking old applications if you make a careless "fix" to
the problem.

Regarding the suggested new features, such as priority propagation or
more priority levels, those are new FEATURES that could be considered for
a future release. Obviously, they would have been to been weighted against
other new features.

/Bjorn
-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB



From kenneth.lundin@REDACTED  Tue May 29 12:02:48 2007
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Tue, 29 May 2007 12:02:48 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529082223.GE4649@katolaz.homeunix.net>
References: <20070529082223.GE4649@katolaz.homeunix.net>
Message-ID: 

See comments inline.

On 5/29/07, KatolaZ  wrote:
> On Mon, May 28, 2007 at 10:52:58PM +0200, Ulf Wiger (TN/EAB) wrote:
> >
> > Corrado Santoro wrote:
> > >
> > > But this does not mean that, in my opinion, the Erlang
> > > priority system has a serious flaw and should be rethought.
> > > Probably, in a telecommunication system, priorities could not
> > > be so important, but if you use Erlang in real-time embedded
> > > environment (and it's argued that Erlang is for
> > > soft-real-time systems),
> >
> > Indeed, telecommunication systems are soft-real-time,
> > which means that it is sufficient to meet deadlines
> > in a high percentage of the cases, but missing a
> > deadline is not considered a fatal error.
> >
> > Erlang shines in this regard, IMO, but in my experience,
> > process priorities don't do much to help in this type
> > of system. Thus the recommendation to use 'normal'
> > priority in the vast majority of cases.
>
> Well, guys, I thought Erlang was really going to be used in many
> different application fields, from telecommunication platforms to web
> apps, from massively concurrent systems to distributed high
> performance applications.

YES, Erlang is already successfully used for this and the use for this
kind of applications will most probably increase taking the SMP
support and the
easy way to utilize multi core CPU's into account.

>
> I also dreamed about Erlang as a real, affordable, safe and robust
> alternative to many ugly and still widely-used languages and
> platforms, such as C#/.net and Java, or at least I understood so,
> attending the last two Erlang User Conferences in 2005 and 2006.
> I also started to talk about erlang at university courses.....

Also a correct observation from your side.
Very good that you started to talk about Erlang at university courses it is
inline with the common opinion among SW research that functional languages
Like Erlang, Haskell etc. have advantages because of their higher
abstraction level
compared with languages like C, C++ when it comes to multithreaded
programming, which is needed in order to utilize multi  core CPU's.

>
> But the last two mails, which suddenly close the Pandora Vase we
> opened looking a little deep inside the process scheduler, simply
> explain that Erlang developers (or at least Ericsson OTP group), has
> little or no interest on having a real robust, affordable,
> distributed, secure and real-time platform.

Erlang was originally designed to be an efficient development environment for
rubust, parallel possibly distributed control systems with soft
real-time requirements. Erlang fulfill that purpose very well.
The erlang distribution protocol is designed to be used in a local
network and lacks many security mechanisms that might be needed if
used over the public internet.
(If that is what you mean with secure?).

Supporting 'hard' real-time is a completely different thing which would require
a major redesign of the virtual machine possibly also many new
primitives and changes to language.

To start with Erlang is most typically run on an operating system
(Linux, Solaris,Windows) which is
not categorized as a real time operatring system.
So real-time characteristics of Erlang can not be better than what the OS offers
to the OS process and threads that the Erlang VM executes in.

In my view however the bulk of SW used in applications don't need
"hard" real-time
characteristics and the small fractions that need can be implemented
as separate processes, drivers etc. which are then interfaced from
Erlang (provided that
the OS supports "hard" realtime to som e extent.

>
> After we discovered a big bug in the scheduler, and reported it to the
> community, the only answer we got was: we don't use that scheduler
> code in OTP, this bug does not heavily affect OTP, processes in
> telecom apps usually use normal priority and since telecom apps are
> our main business and represent 90% of actual Erlang code, it does not
> matter for us.
>
As already explained you have not found a big bug.
You have found something that needs to be explained better in the docs and
that the behaviour of the system with regards to priorities could
perhaps be improved if it becomes evident that it is something that
give problems to many users.

I try to remember how many issues or questions regarding process
priorities we have had over the last 10 years and it is less than a
handful (this thread included).
So it seems not very disturbing for the majority of users.

> Well, maybe it does not matter for telecom apps, maybe it does not
> matter for 90% of Erlang code, maybe it is a so rarely used feature,
> but ERLANG HAS A BUGGY SCHEDULER, EVEN IF YOU DON'T WANT TO ADMIT IT.

See Rickard Greens explanation about the scheduler.


/Regards Kenneth (Erlang/OTP responsible within Ericsson)


From sanjaya@REDACTED  Tue May 29 12:00:33 2007
From: sanjaya@REDACTED (Sanjaya Vitharana)
Date: Tue, 29 May 2007 15:30:33 +0530
Subject: [erlang-questions] inets - http:request with invalid host
	ip(Sanjaya Vitharana)
References: 
	<465BEFEC.7000207@erix.ericsson.se>
Message-ID: <015401c7a1d8$51853240$9a0810ac@wavenet.lk>

Erlang Release R11B-4 with inets-4.7.11

Also for the same url "links" gives the similler result. I mean it hangs for
a long time & gives below output. Also I tried with traceroute, it also
takes a long time to compete the below output.

Since all these tools takes long time, can't this be any related to any
network configuration (NAT or something ) ?

Also where documented "etimedout" ??

If you need further infomation I can provide you with traces. Please guide
me about the traces you need

Thanks

Sanjaya Vitharana

[root@REDACTED erlang]# links -source
"http://202.124.160.149/src/cf/1414/cricket/scoreline_odi/menu.php?key=1&ses
sion=a02857230011801002496201&ch=58&serverid=1"
ERROR at dump.c:188: Receive timeout

[root@REDACTED erlang]#

4>

Last login: Mon May 28 15:20:21 2007 from 202.124.181.34
[root@REDACTED ~]# traceroute 202.124.160.149
traceroute to 202.124.160.149 (202.124.160.149), 30 hops max, 38 byte
packets
 1  202.124.160.37 (202.124.160.37)  1.119 ms  1.287 ms  1.097 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
[root@REDACTED ~]#




----- Original Message -----
From: "Ingela Anderton Andin" 
To: 
Sent: Tuesday, 29 May 2007 02:48 pm
Subject: Re: [erlang-questions] inets - http:request with invalid host
ip(Sanjaya Vitharana)


>
> > Hi,
> >
> > Of cource I put an ip which is not visible (and url also not there).
> >
> > 2> test:test_url().
> >
URL="http://202.124.160.149/src/cf/1414/cricket/scoreline_odi/menu.php?key=1
&session=a02857230011801002496201&ch=58&serverid=1"
> >  Time for Synchronous request 189028171 microseconds
ResSync={error,etimedout}
> >  Time for Asynchronous request 188972235 microseconds ResASync={ok,
> >
#Ref<0.0.0.119>}
> >
> > Check the above results for time taken to execute http:request. (test
code attached)
> >
> > 1.) It has taken a large amount of time to execute both requests
> > 2.) And time difference to exit from Synchronous and Asynchronous
request are approximately same.
> >
> > Is this OK ???
> >
> > What I am thinking is the time taken to perform Asynchronous request as
not acceptable. Am I wrong ?
> > If the IP is not visible (or not available) Why such long time taken to
give ANY result ?
> >
> > Is this a bug ?
> >
> Which version of inets are you using? I just tried your URL and for a
> synchronous request
> I got {ok,{{"HTTP/1.1",503,"Service Unavailable"}, ...  after some time
> and the asynchronous
> version almost immediately  returned  {ok, #Ref<0.0.0.97>} as expected.
>
> Regards Ingela - OTP team
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>




From ulf.wiger@REDACTED  Tue May 29 12:11:38 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Tue, 29 May 2007 12:11:38 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529092629.GA25656@katolaz.homeunix.net>
References: <20070524100740.GF7300@katolaz.homeunix.net>
	<465759BB.7040105@ericsson.com>
	<20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
	<20070529092629.GA25656@katolaz.homeunix.net>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>


me@REDACTED wrote
> 
> Dear Ulf, I know you're not talking on behalf of OTP group 
> :-) My mail would just say that if we (the community of 
> Erlang users and
> developers) want Erlang to be used as a general-purpose 
> robust solution for different problems and applications, we 
> should communicate, talk, discuss, exchange ideas and propose 
> new or better features for the platform we use on our 
> every-day work (or fun), thinking also to new and possibly 
> unexplored fields where Erlang features can be exploited.

So, for the purposes of discussion, how would you feel 
about a change as the one I suggested - do simply disallow
on-demand code loading for high priority processes?

I would assume that it wouldn't hurt the existing code
base, since there are so few processes running on 
high priority, and the designers have thought carefully
about these aspects...

... or so I thought, until I implemented it.

Below is a diff for the error_handler.erl. 
It simply checks if the process has priority
high or max, and if so doesn't call on the code
server.

Interestingly, running with this patch causes 
global_group to crash at startup with an undef,
when calling net_kernel. :-D

I fixed that temporarily by moving the call to 
process_flag(priority, max) to the end of the init/1
function in global_group.erl.

On-demand code loading obviously works for global_group
because there isn't any high-priority process caught in
a busy loop, as in your example. Here, the global_group
process will simply yield until the code is available
and then continue. Also, this code is guaranteed to 
run without interference as long as you don't add the 
flag -risky_shell (or something), since it happens 
during the kernel boot process.

Anyway - see how easy it is to break existing code? ;-)

BR,
Ulf W

$> diff error_handler.erl
$OTP_ROOT/lib/kernel-2.10.11/src/error_handler.erl
73,94c73,86
<     {priority, Prio} = process_info(self(), priority),
<     if Prio == high; Prio == max ->
<           case erlang:module_loaded(Module) of
<               true -> {module, Module};
<               false -> false
<           end;
<        true ->
<           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 pid(Pid) ->
<                   code:ensure_loaded(Module);
<               _ ->
<                   init:ensure_loaded(Module)
<           end
---
>     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 pid(Pid) ->
>           code:ensure_loaded(Module);
>       _ ->
>           init:ensure_loaded(Module)



From bjorn@REDACTED  Tue May 29 12:19:51 2007
From: bjorn@REDACTED (Bjorn Gustavsson)
Date: 29 May 2007 12:19:51 +0200
Subject: [erlang-questions] binary_comprehension support
In-Reply-To: 
References: 
Message-ID: 

Standard disclaimer: Binary comprehensions are an experimental feature,
and there may be changes in it (even incompatible), before it is officially
supported. :-)

How to get your example work:

-module(test).
-compile([export_all, bitlevel_binaries, binary_comprehension]).

foo(Bin) -> [ X || <> <= Bin].

/Bj?rn

"Matthew O'Gorman"  writes:

> Hi i was toying around with binary comprehension support but I cant
> get a simple test of it to work for example
> -module(test).
> -compile([export_all, binary_comprehension]).
> 
> foo(Bin) -> [ X || <> <- Bin].
> 
> wont work no matter what type of binary i put in,  I have r11b4 and
> binary_comprehension turned on in my compile flag but i get the
> following error.
> 
> (mog@REDACTED)9> test:foo(<<1:8, 2:8>>).
> 
> =ERROR REPORT==== 29-May-2007::01:17:49 ===
> Error in process <0.91.0> on node 'mog@REDACTED' with exit value:
> {function_clause,[{test,'-foo/1-lc$^0/1-0-',[<<2
> bytes>>]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
> 
> ** exited: {function_clause,[{test,'-foo/1-lc$^0/1-0-',[<<1,2>>]},
>                              {erl_eval,do_apply,5},
>                              {shell,exprs,6},
>                              {shell,eval_loop,3}]} **
> (mog@REDACTED)10>
> 
> 
> anyone have experience with this new feature?
> 
> mog
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB



From me@REDACTED  Tue May 29 12:20:08 2007
From: me@REDACTED (KatolaZ)
Date: Tue, 29 May 2007 12:20:08 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070529082223.GE4649@katolaz.homeunix.net>
	
Message-ID: <20070529102008.GB25656@katolaz.homeunix.net>

On Tue, May 29, 2007 at 12:02:48PM +0200, Kenneth Lundin wrote:
> >
> >But the last two mails, which suddenly close the Pandora Vase we
> >opened looking a little deep inside the process scheduler, simply
> >explain that Erlang developers (or at least Ericsson OTP group), has
> >little or no interest on having a real robust, affordable,
> >distributed, secure and real-time platform.
> 
> Erlang was originally designed to be an efficient development environment 
> for
> rubust, parallel possibly distributed control systems with soft
> real-time requirements. Erlang fulfill that purpose very well.
> The erlang distribution protocol is designed to be used in a local
> network and lacks many security mechanisms that might be needed if
> used over the public internet.
> (If that is what you mean with secure?).
> 
> Supporting 'hard' real-time is a completely different thing which would 
> require
> a major redesign of the virtual machine possibly also many new
> primitives and changes to language.

Thank you very much, Kenneth. This is the answer I expected from the
OTP group: a really *technical* explanation, not a *commercial* one
:-)

I mostly agree with you: implementing hard real-time in Erlang would
require a non-trivial effort, and I understand that it is not easy to
face all problems related to hard real-time support: this would
probably require a re-implementation of the Erlang scheduler, or at
least a deep review of process priority system.

But I'm still convinced that it could be interesting to try. And I
suppose we'll try to do something in that direction. :-)

Best Regards

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From ulf.wiger@REDACTED  Tue May 29 12:23:45 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Tue, 29 May 2007 12:23:45 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
References: <20070524100740.GF7300@katolaz.homeunix.net><465759BB.7040105@ericsson.com><20070528080036.GA11244@erix.ericsson.se><465AAFFB.6000705@ericsson.com><465AF468.6080805@industrial-designers.co.uk><465B2A64.90005@diit.unict.it><6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se><20070529080444.GC4649@katolaz.homeunix.net><6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se><20070529092629.GA25656@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FB0D86@esealmw115.eemea.ericsson.se>



Just so the rest of you won't need to spend 
time pointing out the obvious, the problem
wasn't the high-priority process calling timer,
but the other high-priority process caught in
a busy loop.

 



From ulf.wiger@REDACTED  Tue May 29 12:32:27 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Tue, 29 May 2007 12:32:27 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
References: <20070524100740.GF7300@katolaz.homeunix.net><465759BB.7040105@ericsson.com><20070528080036.GA11244@erix.ericsson.se><465AAFFB.6000705@ericsson.com><465AF468.6080805@industrial-designers.co.uk><465B2A64.90005@diit.unict.it><6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se><20070529080444.GC4649@katolaz.homeunix.net><6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se><20070529092629.GA25656@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FB0DB7@esealmw115.eemea.ericsson.se>

 
Argh! The combination of using Outlook and having
emacs keyboard shortcuts wired into the brain is
also lethal...

I meant to write that running the original test
program with my patch still locks up, since 
'proc2' effectively keeps the shell process and
proc3 from ever executing. Proc1 dies as it should, 
since timer isn't loaded, but since the processes 
aren't linked, the others don't notice, and proc2 
keeps locking up the system, waiting for a message 
that will never arrive.

Changing the spawns to spawn_link will cause the 
program to terminate.

So we moved from one subtle problem to another one,
all having to do with the looping high priority
process.

Obviously, if you have constant work on high priority,
the concrete effect will be that you starve all other
work, and there will be no useful prioritization 
anyway (all work getting done is done with the 
same priority.)

BR,
Ulf W

> -----Original Message-----
> From: Ulf Wiger (TN/EAB) 
> Sent: den 29 maj 2007 12:24
> To: Ulf Wiger (TN/EAB); me@REDACTED
> Cc: Erlang/OTP discussions
> Subject: RE: [erlang-questions] : Subtle behaviour of Erlang scheduler
> 
> 
> 
> Just so the rest of you won't need to spend time pointing out 
> the obvious, the problem wasn't the high-priority process 
> calling timer, but the other high-priority process caught in 
> a busy loop.
> 
>  
> 



From me@REDACTED  Tue May 29 12:34:41 2007
From: me@REDACTED (KatolaZ)
Date: Tue, 29 May 2007 12:34:41 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
References: <20070528080036.GA11244@erix.ericsson.se>
	<465AAFFB.6000705@ericsson.com>
	<465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
	<20070529092629.GA25656@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
Message-ID: <20070529103441.GC25656@katolaz.homeunix.net>

On Tue, May 29, 2007 at 12:11:38PM +0200, Ulf Wiger (TN/EAB) wrote:
> 
> So, for the purposes of discussion, how would you feel 
> about a change as the one I suggested - do simply disallow
> on-demand code loading for high priority processes?
> 
> I would assume that it wouldn't hurt the existing code
> base, since there are so few processes running on 
> high priority, and the designers have thought carefully
> about these aspects...
> 
> ... or so I thought, until I implemented it.
> 
> Below is a diff for the error_handler.erl. 
> It simply checks if the process has priority
> high or max, and if so doesn't call on the code
> server.
> 
> Interestingly, running with this patch causes 
> global_group to crash at startup with an undef,
> when calling net_kernel. :-D
> 
> I fixed that temporarily by moving the call to 
> process_flag(priority, max) to the end of the init/1
> function in global_group.erl.

:-DDD

I perfectly understand what the point is :-) It seems too much easy to
break existing code, in a way or another, and it is quite normal in a
ten-years development. For this precise reason I thought that running 
code server with high priority would somehow solve the problem, but I 
agree with the fact that filesystem interaction could also be heavy and
slow...

So, just for the purpose of discussion, why don't think at "virtual"
synchronisation points for high priority procs ? I.e., if a high
priority task has not been interrupted for X reductions (beeing X a
relatively large integer), then goto do_schedule1 anyway, letting
other high priority process to run.... In this way, code server could
be put into high-prio queue, without problems for other high-prio
procs...

I think I'm going to test this solution, and let you know if it
works...

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From me@REDACTED  Tue May 29 12:40:19 2007
From: me@REDACTED (KatolaZ)
Date: Tue, 29 May 2007 12:40:19 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070529082223.GE4649@katolaz.homeunix.net>
	
Message-ID: <20070529104019.GD25656@katolaz.homeunix.net>

On Tue, May 29, 2007 at 11:55:10AM +0200, Bjorn Gustavsson wrote:
> KatolaZ  writes:
> > 
> > Well, maybe it does not matter for telecom apps, maybe it does not
> > matter for 90% of Erlang code, maybe it is a so rarely used feature,
> > but ERLANG HAS A BUGGY SCHEDULER, EVEN IF YOU DON'T WANT TO ADMIT IT. 
> 
> Using capitals letters doesn't make your statement more true.
> Rather it seems that you are shouting.

You're right. Sorry for that. It was not my intention to shout out. :-|

> 
> That the scheduler does not have all the features you think you'll need
> does not mean that it is buggy.
> 
> If we just had unlimited time, people and money, we would fix everything
> that every single user demanded so that Erlang could be used for every
> possible application. The reality is that we must base our developement
> on priorities and first work on features that will benefit the majority
> of the users.
> 
> In this case, the behaviour of the code loader is unfortunate, but it is
> extremely easy to work around once you know about it. Trying to fix the
> issue in OTP by giving the code server higher priority is not as trivial
> as it might seem. We would have to make sure that the change would not
> break existing applications. Also, the code server in turn calls other
> processes to actually load the code from the disk, so those processes
> would have to have their priorities raised too. All this means that there
> is a risk of breaking old applications if you make a careless "fix" to
> the problem.
> 

Well, I proposed a solution, based on "virtual" synchronisation points
and high-prio for code server, in another mail. We can discuss it, if
you want, and try how it works with legacy code. I'm going to do that
;-)

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From chsu79@REDACTED  Tue May 29 13:31:06 2007
From: chsu79@REDACTED (Christian S)
Date: Tue, 29 May 2007 13:31:06 +0200
Subject: [erlang-questions] regexp sux!
In-Reply-To: <200705211555.l4LFtCjV074597@shell.accesscom.com>
References:  <45F27E12.2000102@ericsson.com>
	 <45F47F3F.20009@telia.com>
	 <4650365F.5080500@telia.com>
	
	<200705210602.l4L62hkT012941@shell.accesscom.com>
	
	<200705211555.l4LFtCjV074597@shell.accesscom.com>
Message-ID: 

Would it be easy to make regexps incremental, in such that i can
feed a regexp a string, and then find out if the string contained enough
for the regexp to match/halt, or if i need to continue feeding it with
more data.

Imagine I am receiving data blocks with an active gen_tcp socket, and
my potential regexp match is across the boundary of two received data
blocks.

I'm imagining an interface somewhat similar to md5_init/md5_update but
with an exit to let me know there was a match, at which point i would
get the matched part and the remaining part returned to me so i can
continue matching on the latter when i have processed the matched
block.

On 5/21/07, Darius Bacon  wrote:
> Luke Gorrie  wrote:
> > Darius Bacon  writes:
> >
> > > Here's a lightly-tested hack -- I'm not familiar with the existing
> > > libraries so this is from scratch.
> >
> > You bloody showoff. :-) Works great!
>
> Guilty. :-)
>
> > I had to add . (dot) but nothing else really obvious is missing.
> > Feel free to draw my attention to anything I'm overlooking though :-)
>
> There's no attempt to conform to any standard, and the regex parser
> ought to be replaced with a real one that understands char ranges,
> inverted char classes, escaping, etc.
>
> > Can I steal this code and use it at work?
>
> Sure, I guess an MIT license would be appropriate. I'd appreciate
> getting back any improvements/tests -- don't know when I'll get around
> to the quickcheck tests.
>
> > NB: I would still feel more comfortable if this were quickcheck'd a
> > bit for divergence etc. I can't help but think that a free quickcheck
> > clone is likely to surface soon. I hope that John & Thomas are happy
> > with this idea or if not that they make their one accessible to us
> > random hackers on the list somehow soon :-)
>
> Their automatic error-case shrinking sounds really cool and useful.
>
> Darius
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From bengt.kleberg@REDACTED  Tue May 29 13:31:48 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Tue, 29 May 2007 13:31:48 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: 
References: <20070529082223.GE4649@katolaz.homeunix.net>
	
Message-ID: <465C0F24.6040003@ericsson.com>

On 2007-05-29 11:55, Bjorn Gustavsson wrote:
...deleted
> If we just had unlimited time, people and money, we would fix everything
> that every single user demanded so that Erlang could be used for every
> possible application. The reality is that we must base our developement

would not this kind of development lead to bloat and inconsistencies? :-)


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From thomasl_erlang@REDACTED  Tue May 29 13:46:48 2007
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Tue, 29 May 2007 04:46:48 -0700 (PDT)
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
In-Reply-To: 
Message-ID: <182334.65156.qm@web38808.mail.mud.yahoo.com>


--- Bill Clementson  wrote:

> I posted about Emacs/erlang-mode/Distel on my weblog
> today:
> http://bc.tech.coop/blog/070528.html
> 
> Being new to Erlang, I would appreciate any
> comments/suggestions 
> on ways experienced Erlang users "tweak" their
> .emacs files for 
> Erlang use.

Well, Bill, from your post I'd guess you still would
qualify in the top 10% of erlang emacs users :-) I
have to confess I don't normally use distel, though I
have a nagging feeling I should.

Best,
Thomas



 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/


From ingela@REDACTED  Tue May 29 14:07:23 2007
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Tue, 29 May 2007 14:07:23 +0200
Subject: [erlang-questions] inets - http:request with invalid host
In-Reply-To: 
References: 
Message-ID: <465C177B.1060905@erix.ericsson.se>

Hi!
> Also for the same url "links" gives the similler result. I mean it hangs for
> a long time & gives below output. Also I tried with traceroute, it also
> takes a long time to compete the below output.
>
> Since all these tools takes long time, can't this be any related to any
> network configuration (NAT or something ) ?
>
>   
It is of course  possible that you   have  some  more general network 
problem  not related
to Erlang or inets.  
> Also where documented "etimedout" ??
>
>   
That value comes from the inet-driver.  inet(3)

> If you need further infomation I can provide you with traces. Please guide
> me about the traces you need
>   
If you want to know what the http inets client is doing you can use the 
function
http:set_options([{verbose, VerboseMode}]).

*|VerboseMode = false | verbose |debug | trace |*
By default false. This option unless it is set to false switches on 
different levels of erlang trace on the client. It is a debug feature.

Regards Ingela - OTP team







From Erik.Stenman@REDACTED  Tue May 29 15:39:26 2007
From: Erik.Stenman@REDACTED (Erik Stenman)
Date: Tue, 29 May 2007 15:39:26 +0200
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
In-Reply-To: 
References: 
Message-ID: <465C2D0E.9020006@Kreditor.se>

Bill Clementson wrote:
[...]
> Being new to Erlang, I would appreciate any comments/suggestions 
> on ways experienced Erlang users "tweak" their .emacs files for 
> Erlang use.

Most Erlang projects I work on have a file structure like:
project
  |-doc
  |-config
  |-lib
    |-app1
    | |-doc
    | |-include
    | |-src
    |
    |-app2

I use the following functions to find keywords in all src files in the project.
It requires some basic unix commands and assumes you are using subversion,
it works for me, but it might not work for you.

;;; Find in erlang project dirs
(defun kfind-at (path word)
    (grep-find (concat "find " path (concat " -name '.svn' -prune -o -name '*~' -prune -o -name '*html' -prune -o -type f -print0 | xargs -0 -e grep -n -e " word))))

(defun kfind (word)
   (interactive "MFind: ")
   (kfind-at
    (concat
     (car (split-string (buffer-file-name) "lib"))
     "lib/")
    word)
   )


I bind it to keys like:
(global-set-key (quote [67108910])  'next-error)     ;; C-.
(global-set-key (quote [67108908]) 'previous-error)  ;; C-,
(setq ctrl-z-map (make-keymap))
(global-set-key "\C-z" ctrl-z-map)
(global-set-key "\C-zf" 'kfind)

Then, when I am in a buffer of some file in project/lib/appX/src/
I can do C-zf frotz to find all uses of frotz, and I can move through
the result with C-. and C-,

It might seem useless when you have M-. to jump to a function definition,
but after the first time you have used it to answer a question like
   "Where is the atom "frotz" used?"
you will never go back.

/Happi


From mats.cronqvist@REDACTED  Tue May 29 16:25:27 2007
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Tue, 29 May 2007 16:25:27 +0200
Subject: [erlang-questions] Syntax highlight erlang code with erlang
In-Reply-To: <46541826.30804@it.uu.se>
References: <00E47B21F2156640838B288A86560DB6020BA592@esealmw107.eemea.ericsson.se>		<00E47B21F2156640838B288A86560DB6020BA593@esealmw107.eemea.ericsson.se>
	<46541826.30804@it.uu.se>
Message-ID: <465C37D7.7070502@ericsson.com>

Richard Carlsson wrote:
> Petter Larsson XA (TN/EAB) wrote:
>> I would actually prefer doing it in erlang code, soo I can create links
>> fo other filer etc. when possible.
>>
>> Doesn't anyone have an example code of highligting erlang code with
>> erl_syntax etc.
> 
> I don't have any example code at hand, but you can do it fairly easily,
> the following way:
> 
>    1. Traverse the syntax tree (use erl_syntax:subtrees/1) and add
>       annotations (erl_syntax:add_ann/2) on nodes of interest.
> 
>    2. Use erl_prettypr:format/2 and pass it a hook function that adds
>       additional markup depending on the annotation. (See the
>       documentation for a trivial example.)
> 

   i have code that does exactly this. i intend to post it on google code shortly.
   there are some issues;

* "non-syntactic" macros are not handled well.
* code is re-indented (IMHO a feature, since improperly indented code becomes 
legible)
* keywords such as "case" and "catch" can not be marked up(?)

   mats


From casper2000a@REDACTED  Tue May 29 18:39:06 2007
From: casper2000a@REDACTED (Eranga Udesh)
Date: Tue, 29 May 2007 22:09:06 +0530
Subject: [erlang-questions] ASN.1 asn1ct error
In-Reply-To: <465AB43C.9090800@ericsson.com>
Message-ID: <20070529163917.17AB419DC1CD@mail.wavenet.lk>

Thanks for the update. Do you think this support will be available soon? For
unsupported types, will it be possible to change to compiler to take as type
ANY?

- Eranga


-----Original Message-----
From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Bertil Karlsson
Sent: Monday, May 28, 2007 4:22 PM
Cc: erlang-questions@REDACTED
Subject: Re: [erlang-questions] ASN.1 asn1ct error

Currently parameterized objects are not fully supported.
As soon as possible I will address this problem.

/Bertil Karlsson

Eranga Udesh wrote:
> Hi,
>
> Why could be the reason for asn1ct to return below error? I checked
> asn1ct:check_object_list/4, but I cannot find a case match for type pv. If
> you want me to send the asn.1 source to check the error, please let me
know.
>
> asn1error:72:'Test':'ActivityTest2' {internal_error,
>                                      {error,
>                                       {'unknown object',
>                                        {pv,
>                                         {simpledefinedvalue,
>                                          32,
>                                          boundedExtension},
>                                         [{'Externalvaluereference',
>                                           32,
>                                           'IN-CS2-classes-test',
>                                           bound}]}},
>
>
> Thanks,
> - Eranga
>
> _______________________________________________
> 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 g.olgeni@REDACTED  Tue May 29 19:03:24 2007
From: g.olgeni@REDACTED (Giacomo Olgeni)
Date: Tue, 29 May 2007 19:03:24 +0200
Subject: [erlang-questions] Dialyzer 1.6.0 anc qlc
Message-ID: <465C5CDC.6030304@colby.it>

Hello,

I ran Dialyzer 1.6.0 (R11B-4) over my compiled beam files, and got a lot 
of these error messages:

Checking whether the initial PLT exists and is up-to-date... yes
Proceeding with analysis... .:none: internal error in core_module;
crash reason: {function_clause,
                  [{v3_core,
                       lineno_anno,
                       [{'X',313},
                        {core,
                            14,
                            0,
                            false,
                            [],
                            [{file,"./epg_service_server.erl"}]}]},
                   {v3_core,expr,2},
                   {v3_core,safe,2},
                   {v3_core,expr,2},
                   {v3_core,safe,2},
                   {v3_core,'-safe_list/2-anonymous-0-',2},
                   {lists,foldr,3},
                   {v3_core,expr,2}]}

They are always associated with qlc function calls, like this:

    qlc:e (qlc:q ([X || X <- mnesia:table (epg_ftp_feed), 
X#epg_ftp_feed.service_id == ServiceId]))

Dialyzer from R11B-3 worked fine with the same files.

Should I do something special to let it recognize the qlc code?

bye,
    Jimmy


From billclem@REDACTED  Tue May 29 19:06:09 2007
From: billclem@REDACTED (Bill Clementson)
Date: Tue, 29 May 2007 10:06:09 -0700
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
References: 
	<182334.65156.qm@web38808.mail.mud.yahoo.com>
Message-ID: 

Thomas Lindgren  writes:

> --- Bill Clementson  wrote:
>
>> I posted about Emacs/erlang-mode/Distel on my weblog
>> today:
>> http://bc.tech.coop/blog/070528.html
>> 
>> Being new to Erlang, I would appreciate any
>> comments/suggestions 
>> on ways experienced Erlang users "tweak" their
>> .emacs files for 
>> Erlang use.
>
> Well, Bill, from your post I'd guess you still would
> qualify in the top 10% of erlang emacs users :-) I
> have to confess I don't normally use distel, though I
> have a nagging feeling I should.

It is actually quite useful! ;-)

- Bill



From billclem@REDACTED  Tue May 29 19:24:33 2007
From: billclem@REDACTED (Bill Clementson)
Date: Tue, 29 May 2007 10:24:33 -0700
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
References:  <465C2D0E.9020006@Kreditor.se>
Message-ID: 

Erik Stenman  writes:

> Bill Clementson wrote:
> [...]
>> Being new to Erlang, I would appreciate any comments/suggestions 
>> on ways experienced Erlang users "tweak" their .emacs files for 
>> Erlang use.
>
> Most Erlang projects I work on have a file structure like:
> project
>   |-doc
>   |-config
>   |-lib
>     |-app1
>     | |-doc
>     | |-include
>     | |-src
>     |
>     |-app2
>
> I use the following functions to find keywords in all src files in the project.
> It requires some basic unix commands and assumes you are using subversion,
> it works for me, but it might not work for you.
>
> ;;; Find in erlang project dirs
> (defun kfind-at (path word)
>     (grep-find (concat "find " path (concat " -name '.svn' -prune -o -name '*~' -prune -o -name '*html' -prune -o -type f -print0 | xargs -0 -e grep -n -e " word))))
>
> (defun kfind (word)
>    (interactive "MFind: ")
>    (kfind-at
>     (concat
>      (car (split-string (buffer-file-name) "lib"))
>      "lib/")
>     word)
>    )
>
>
> I bind it to keys like:
> (global-set-key (quote [67108910])  'next-error)     ;; C-.
> (global-set-key (quote [67108908]) 'previous-error)  ;; C-,
> (setq ctrl-z-map (make-keymap))
> (global-set-key "\C-z" ctrl-z-map)
> (global-set-key "\C-zf" 'kfind)
>
> Then, when I am in a buffer of some file in project/lib/appX/src/
> I can do C-zf frotz to find all uses of frotz, and I can move through
> the result with C-. and C-,
>
> It might seem useless when you have M-. to jump to a function definition,
> but after the first time you have used it to answer a question like
>    "Where is the atom "frotz" used?"
> you will never go back.

Yes, I can see how your find function would be useful with a standard
project directory structure. Unfortunately, I work on a number of
different open source and commercial projects and can't depend on the
directory structure or the vc software being consistent, so I took the
liberty to make a couple of mods to your function:

;; Find in project source files
(defvar bc-project-dir nil "Start directory for FIND's")

(defun bc-find-at (path word)
  "Search source (ignore VC dirs, backups, docs)"
  (grep-find (concat "find " path (concat " -name '.svn' -prune -o \
                                            -name 'CVS' -prune -o \
                                            -name '_darcs' -prune -o \
                                            -name '*~' -prune -o \
                                            -name 'doc' -prune -o \
                                            -type f -print0 \
                                            | xargs -0 grep -n -e " word))))

(defun bc-find (word)
  (interactive "MFind: ")
  (bc-find-at
   (or bc-project-dir ".")
   word))

(global-set-key "\C-." 'next-error)
(global-set-key "\C-," 'previous-error)
(global-set-key "\C-cs" 'bc-find)

If working in a particular project tree, you can set the
'bc-project-dir' variable to the "root directory" for the project and
any searches will be done starting from there (find will ignore any
Subversion, Darcs, or CVS directories as well as any Emacs backup
files and "doc" directories). If no 'bc-project-dir' variable is
specified, searches will be done from the current directory.

Thanks for your tip!

- Bill



From raimo+erlang-questions@REDACTED  Tue May 29 20:53:51 2007
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Tue, 29 May 2007 20:53:51 +0200
Subject: [erlang-questions] Server maintainance 2007-05-31
Message-ID: <20070529185351.GA27815@erix.ericsson.se>

During Thursday evening (sometime during 18.00 .. 24.00 CET),
2007-05-31, we will upgrade our servers (handling www.erlang.org,
rsync and our mailing lists). There will be some downtime,
hopefully not much.

After the upgrade, we will have a subversion repository
for EEPs (according to Per Gustafsson's proposition from
Feb 2007 on erlang-questions@REDACTED All tools are
not ready so we will get back with details...

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From robert.virding@REDACTED  Wed May 30 02:57:37 2007
From: robert.virding@REDACTED (Robert Virding)
Date: Wed, 30 May 2007 02:57:37 +0200
Subject: [erlang-questions] regexp sux!
In-Reply-To: 
References: 
	<45F27E12.2000102@ericsson.com>	
	<45F47F3F.20009@telia.com>	
	<4650365F.5080500@telia.com>		<200705210602.l4L62hkT012941@shell.accesscom.com>		<200705211555.l4LFtCjV074597@shell.accesscom.com>
	
Message-ID: <465CCC01.4080904@telia.com>

Not really, the tokeniser does that. It means you would have to write 
regexp engine in such a way that it's state is explicit and not implicit 
in a call stack. Doing that now. The only real problem would be how you 
specify that there was no input left to be scanned.

Robert

Christian S wrote:
> Would it be easy to make regexps incremental, in such that i can
> feed a regexp a string, and then find out if the string contained enough
> for the regexp to match/halt, or if i need to continue feeding it with
> more data.
> 
> Imagine I am receiving data blocks with an active gen_tcp socket, and
> my potential regexp match is across the boundary of two received data
> blocks.
> 
> I'm imagining an interface somewhat similar to md5_init/md5_update but
> with an exit to let me know there was a match, at which point i would
> get the matched part and the remaining part returned to me so i can
> continue matching on the latter when i have processed the matched
> block.
> 
> On 5/21/07, Darius Bacon  wrote:
>> Luke Gorrie  wrote:
>>> Darius Bacon  writes:
>>>
>>>> Here's a lightly-tested hack -- I'm not familiar with the existing
>>>> libraries so this is from scratch.
>>> You bloody showoff. :-) Works great!
>> Guilty. :-)
>>
>>> I had to add . (dot) but nothing else really obvious is missing.
>>> Feel free to draw my attention to anything I'm overlooking though :-)
>> There's no attempt to conform to any standard, and the regex parser
>> ought to be replaced with a real one that understands char ranges,
>> inverted char classes, escaping, etc.
>>
>>> Can I steal this code and use it at work?
>> Sure, I guess an MIT license would be appropriate. I'd appreciate
>> getting back any improvements/tests -- don't know when I'll get around
>> to the quickcheck tests.
>>
>>> NB: I would still feel more comfortable if this were quickcheck'd a
>>> bit for divergence etc. I can't help but think that a free quickcheck
>>> clone is likely to surface soon. I hope that John & Thomas are happy
>>> with this idea or if not that they make their one accessible to us
>>> random hackers on the list somehow soon :-)
>> Their automatic error-case shrinking sounds really cool and useful.
>>
>> Darius
>> _______________________________________________
>> 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 darius@REDACTED  Wed May 30 08:22:37 2007
From: darius@REDACTED (Darius Bacon)
Date: Tue, 29 May 2007 23:22:37 -0700 (PDT)
Subject: [erlang-questions] regexp sux!
In-Reply-To: 
	(chsu79@gmail.com)
References:  <45F27E12.2000102@ericsson.com>
	 <45F47F3F.20009@telia.com>
	 <4650365F.5080500@telia.com>
	
	<200705210602.l4L62hkT012941@shell.accesscom.com>
	
	<200705211555.l4LFtCjV074597@shell.accesscom.com>
	
Message-ID: <200705300622.l4U6Mbj1074318@shell.accesscom.com>

"Christian S"  wrote:
> Would it be easy to make regexps incremental, in such that i can
> feed a regexp a string, and then find out if the string contained enough
> for the regexp to match/halt, or if i need to continue feeding it with
> more data.
> 
> Imagine I am receiving data blocks with an active gen_tcp socket, and
> my potential regexp match is across the boundary of two received data
> blocks.
> 
> I'm imagining an interface somewhat similar to md5_init/md5_update but
> with an exit to let me know there was a match, at which point i would
> get the matched part and the remaining part returned to me so i can
> continue matching on the latter when i have processed the matched
> block.

I don't think the tree-recursive matchers do that naturally, but what
you want does correspond directly to DFA states or regular-expression
derivatives. I just hacked up an implementation of derivatives and
bundled it with my earlier regexp code at
http://jungerl.sourceforge.net/ in the library named 'ergex'.

Darius


From sanjaya@REDACTED  Wed May 30 09:05:16 2007
From: sanjaya@REDACTED (Sanjaya Vitharana)
Date: Wed, 30 May 2007 12:35:16 +0530
Subject: [erlang-questions] inets - http:request with invalid host
References: 
	<465C177B.1060905@erix.ericsson.se>
Message-ID: <026001c7a288$f9db9dc0$9a0810ac@wavenet.lk>

Attached are the traces. But still I can't find why this happens.

Am I the only one who faced this ? :(

Sanjaya Vitharana

----- Original Message -----
From: "Ingela Anderton Andin" 
To: 
Sent: Tuesday, 29 May 2007 05:37 pm
Subject: Re: [erlang-questions] inets - http:request with invalid host


> Hi!
> > Also for the same url "links" gives the similler result. I mean it hangs
for
> > a long time & gives below output. Also I tried with traceroute, it also
> > takes a long time to compete the below output.
> >
> > Since all these tools takes long time, can't this be any related to any
> > network configuration (NAT or something ) ?
> >
> >
> It is of course  possible that you   have  some  more general network
> problem  not related
> to Erlang or inets.
> > Also where documented "etimedout" ??
> >
> >
> That value comes from the inet-driver.  inet(3)
>
> > If you need further infomation I can provide you with traces. Please
guide
> > me about the traces you need
> >
> If you want to know what the http inets client is doing you can use the
> function
> http:set_options([{verbose, VerboseMode}]).
>
> *|VerboseMode = false | verbose |debug | trace |*
> By default false. This option unless it is set to false switches on
> different levels of erlang trace on the client. It is a debug feature.
>
> Regards Ingela - OTP team
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: session_trace.log
Type: application/octet-stream
Size: 58175 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: session_debug.log
Type: application/octet-stream
Size: 17476 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: session_verbose.log
Type: application/octet-stream
Size: 1411 bytes
Desc: not available
URL: 

From ingela@REDACTED  Wed May 30 11:38:54 2007
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Wed, 30 May 2007 11:38:54 +0200
Subject: [erlang-questions] inets - http:request with invalid host
In-Reply-To: <026001c7a288$f9db9dc0$9a0810ac@wavenet.lk>
References: 
	<465C177B.1060905@erix.ericsson.se>
	<026001c7a288$f9db9dc0$9a0810ac@wavenet.lk>
Message-ID: <465D462E.5090900@erix.ericsson.se>


Sanjaya Vitharana wrote:
> Attached are the traces. But still I can't find why this happens.
>   
It seems as if the call to gen_tcp:connect fails with a lowlevel timeout 
(timeout in the inet driver not controlled by the inets application),  
this  would  explain why 
the asynchronous call takes longer time, as the result of the 
asynchronous calls
is returned first thing after spawning the  request handler process  
(unless  the request is pipelined)
and the request handling process connects to the server in its init 
function. There is nothing really wrong with that, but as spawn of a 
gen_server process will not return on till init
returns it will in this particular case delay the result returned to the 
client.  It is probably a good idea for us to use  gen_server:enter_loop 
function that was invented
just because of the fact that it is hard to always keep init trivial 
enough. I will put this on the todo list. If you are able to connect to 
a host with gen_tcp directly but not with the http-client you
can try disabling ipv6 in the http-client.

Regards - Ingela OTP team



From als@REDACTED  Wed May 30 12:17:04 2007
From: als@REDACTED (Anthony Shipman)
Date: Wed, 30 May 2007 20:17:04 +1000
Subject: [erlang-questions] xmerl suggestion
Message-ID: <200705302017.04125.als@iinet.net.au>

We have
   Element is any of:
    * {Tag, Attributes, Content}
   Attributes = [{Name, Value}]
   Value = IOString | atom() | integer()

How about adding float() to Value.

-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.


From rickard.s.green@REDACTED  Wed May 30 01:36:35 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Wed, 30 May 2007 01:36:35 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070529103441.GC25656@katolaz.homeunix.net>
References: <20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
Message-ID: <465CB903.90002@ericsson.com>


KatolaZ wrote:
> On Tue, May 29, 2007 at 12:11:38PM +0200, Ulf Wiger (TN/EAB) wrote:
>> So, for the purposes of discussion, how would you feel 
>> about a change as the one I suggested - do simply disallow
>> on-demand code loading for high priority processes?
>>
>> I would assume that it wouldn't hurt the existing code
>> base, since there are so few processes running on 
>> high priority, and the designers have thought carefully
>> about these aspects...
>>
>> ... or so I thought, until I implemented it.
>>
>> Below is a diff for the error_handler.erl. 
>> It simply checks if the process has priority
>> high or max, and if so doesn't call on the code
>> server.
>>
>> Interestingly, running with this patch causes 
>> global_group to crash at startup with an undef,
>> when calling net_kernel. :-D
>>
>> I fixed that temporarily by moving the call to 
>> process_flag(priority, max) to the end of the init/1
>> function in global_group.erl.
> 
> :-DDD
> 

This is a good example, I think.

The effect, regarding priority, of doing a gen_server:call to a server
on prio normal from an high prio process is more or less a temporary
decrease of prio to normal of the caller process during the call.

I don't know that much about global_group, but it is no problem that it
happens to have max prio when triggering code loading of the net_kernel
code during initialization, assuming that everything else is as it
should. The initialization begins with an increase of prio from normal
to max, then net_kernel:monitor_nodes is called, which apparently caused
the code of net_kernel to be loaded. We could switch those two lines of
code, i.e. making sure that the code of net_kernel is loaded before
increasing prio. The switch would not have much of an effect, though. If
it should have been important with max prio at this point, the process
should have been spawned with prio max (spawn_opt). The place where the
max prio is of interest comes later after the initialization. A
temporary decrease of prio after initialization may be okay too.

If it is important that a process effectively have high or max prio at
some certain point of execution, it should not trigger code loading at
that point. It is not automatically a problem if a high or max prio
processes causes code loading. It will become a problem if you have an
high or max prio process busy looping for long periods of time, but this
  is not how high prio is intended to be used. You will get other
problems too as Ulf pointed out.

> I perfectly understand what the point is :-) It seems too much easy to
> break existing code, in a way or another, and it is quite normal in a
> ten-years development. For this precise reason I thought that running 
> code server with high priority would somehow solve the problem, but I 
> agree with the fact that filesystem interaction could also be heavy and
> slow...
> 
> So, just for the purpose of discussion, why don't think at "virtual"
> synchronisation points for high priority procs ? I.e., if a high
> priority task has not been interrupted for X reductions (beeing X a
> relatively large integer), then goto do_schedule1 anyway, letting
> other high priority process to run....

If I understood you right, you want the scheduling to work as it is
implemented right now.

Regardless of priority, a process is unconditionally scheduled out when
it has consumed (currently) 2000 reductions (since it was last scheduled
in). I.e., a busy loop in a high priority process will not prevent other
high priority processes from running, but it will prevent normal and low
priority processes from running.

> In this way, code server could
> be put into high-prio queue, without problems for other high-prio
> procs...
> 

Increasing the prio of the code server to high wont be a problem for
other high prio processes.

We don't know *exactly* what the impact will be on the system. In order
to verify that it is safe, we have to thoroughly investigate it. As it
is now we don't see the need for that, since we do not consider the
behavior a bug. I don't say that the priority management cannot be
improved, it probably can, but currently it has low prio compared to
other things.

> I think I'm going to test this solution, and let you know if it
> works...
>

Please, do that.

A thumb-rule if you want us to include a new feature: If it is a small
amount of work for us (with implementation, verification, documentation,
etc) it is very much more likely to make it into OTP than if the amount
of work for us is large. Note, however, that there will always be work
for us in order to include a new feature, no matter how much work you
have done, and we *cannot* promise if/when a feature request make it
into OTP. A good motivation of why it is needed is, of course, also needed.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.

> HND
> 
> Enzo
> 




From ingela@REDACTED  Wed May 30 14:02:42 2007
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Wed, 30 May 2007 14:02:42 +0200
Subject: [erlang-questions] inets - http:request with invalid host
In-Reply-To: 
References: 
Message-ID: <465D67E2.6040300@erix.ericsson.se>


> It seems as if the call to gen_tcp:connect fails with a lowlevel timeout 
> (timeout in the inet driver not controlled by the inets application),  
>
>   
It was pointed out to me that this is something that might happen if you 
are blocked by a firewall,
so maybe you should check your firewall configuration if you are sitting 
behind a firewall.

Regards Ingela - OTP team




From tobbe@REDACTED  Wed May 30 14:10:08 2007
From: tobbe@REDACTED (Torbjorn Tornkvist)
Date: Wed, 30 May 2007 14:10:08 +0200
Subject: [erlang-questions] parameterized modules and OO
Message-ID: 

Hi all,

I just read the very cool paper about "parameterized modules"
and cooked up a little experimental OO framework. This makes
it possible to write code, such as:

  M = mstring:new("hello").
  M:len(). => 5
  M:append(" world"). => "hello world"
  M:len() => 11

This code is using an ETS table to store the state, i.e boring...
(code can be found here: http://www.tornkvist.org/gitweb
look for the mobject project)

So I was thinking, would it be possible for a parameterized module
to modify its own module attributes ?

For example:

...
-store([]).

append(Str) ->
    module_info(store, module_info(store) ++ Str).

This way, the ETS table could go away and we have a self-contained 
object. One should even be able to add a simple inheritance mechanism.

So would this be possible to add without too much hassle ?

Cheers, Tobbe
(NB: I'm not saying this is good or bad, I'm not even proposing
this, I'm just curious to hear if it would be easy/hard/impossible to 
add this functionality.)






From ulf.wiger@REDACTED  Wed May 30 14:16:33 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Wed, 30 May 2007 14:16:33 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465CB903.90002@ericsson.com>
References: <20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
	<465CB903.90002@ericsson.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FE9561@esealmw115.eemea.ericsson.se>

 
Rickard Green wrote
>
> for that, since we do not consider the behavior
> a bug. I don't say that the priority management
> cannot be improved, it probably can, but
> currently it has low prio compared to other things.

What would be interesting, though, would be to do
a deeper analysis of scheduling behaviour in 
SMP Erlang. As you pointed out before, high prio
processes don't necessarily starve normal prio
processes in SMP, even if they busy-loop.

One *could* also imagine extending the SMP 
scheduler to make use of more sophisticated 
priority schemes, e.g. on a real-time kernel.
(Not to foregoe the conclusion as to whether 
this would actually be useful - I don't know.)
If this is at least described now, it is unlikely
to break legacy code more than SNMP already does.

John Hughes previously pointed out that the single-
threaded scheduler is deterministic to the point 
of it being a slight problem for QuickCheck. With
SMP, the problem is the opposite: how to to 
deterministic simplification of concurrency-oriented
test cases...(*) just as an example of how scheduling 
in SMP is subtly different from that in old Erlang.


(*) Of course, the recommendation has always been to
regard the scheduler as preemptive, and expect your 
code to be preemptable whenever possible (that is,
between any two operations), so in that sense, SMP
merely makes good on this promise. (:

BR,
Ulf W



From rickard.s.green@REDACTED  Wed May 30 15:00:27 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Wed, 30 May 2007 15:00:27 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FE9561@esealmw115.eemea.ericsson.se>
References: <20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
	<465CB903.90002@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501FE9561@esealmw115.eemea.ericsson.se>
Message-ID: <465D756B.80208@ericsson.com>



Ulf Wiger (TN/EAB) wrote:
> 
> What would be interesting, though, would be to do
> a deeper analysis of scheduling behaviour in 
> SMP Erlang. As you pointed out before, high prio
> processes don't necessarily starve normal prio
> processes in SMP, even if they busy-loop.
> 

We actually have on the todo list to review the scheduling in the 
runtime system with SMP support.

> 
> (*) Of course, the recommendation has always been to
> regard the scheduler as preemptive, and expect your 
> code to be preemptable whenever possible (that is,
> between any two operations), so in that sense, SMP
> merely makes good on this promise. (:

Yes. We have also introduced the +M command-line flag, in order to try 
to make it easier to find bugs in Erlang code that doesn't follow those 
recommendations.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.


From rickard.s.green@REDACTED  Wed May 30 15:02:37 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Wed, 30 May 2007 15:02:37 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465D756B.80208@ericsson.com>
References: <20070528080036.GA11244@erix.ericsson.se>	<465AAFFB.6000705@ericsson.com>	<465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
	<465CB903.90002@ericsson.com>
	<6616D98C65DD514BA2E1DDC5F922315501FE9561@esealmw115.eemea.ericsson.se>
	<465D756B.80208@ericsson.com>
Message-ID: <465D75ED.5030608@ericsson.com>



Rickard Green wrote:
> 
> Ulf Wiger (TN/EAB) wrote:
>>
>> (*) Of course, the recommendation has always been to
>> regard the scheduler as preemptive, and expect your code to be 
>> preemptable whenever possible (that is,
>> between any two operations), so in that sense, SMP
>> merely makes good on this promise. (:
> 
> Yes. We have also introduced the +M command-line flag, in order to try 
> to make it easier to find bugs in Erlang code that doesn't follow those 
> recommendations.
> 

Sorry, it should be +T command-line flag.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.



From richardc@REDACTED  Wed May 30 15:20:54 2007
From: richardc@REDACTED (Richard Carlsson)
Date: Wed, 30 May 2007 15:20:54 +0200
Subject: [erlang-questions] parameterized modules and OO
In-Reply-To: 
References: 
Message-ID: <465D7A36.6070309@it.uu.se>

Torbjorn Tornkvist wrote:
> So I was thinking, would it be possible for a parameterized module
> to modify its own module attributes ?
> [...]
> So would this be possible to add without too much hassle ?
> 
> Cheers, Tobbe
> (NB: I'm not saying this is good or bad, I'm not even proposing
> this, I'm just curious to hear if it would be easy/hard/impossible to 
> add this functionality.)

- The current runtime system does not support runtime changes to the
attributes (the module_info stuff) of a module.

- The attributes are per-loaded-module ("class members" in OO
terminology), and what you probably want is a table of attributes per 
module instance. That table should thus be created when you call 'new'.
There are at least two possible ways of hiding the table creation:

   1: Specify the abstract module with N parameters, the last one being
      the per-instance table, and insert a hand-written function new/M
      where M=N-1, which calls the autogenerated new/N with a freshly
      created table.

   2: Separate the actual abstract module implementation and its
      interface: give the abstract module some other name, and let the
      interface module have a new/M function which calls the new/N
      function of the abstract module with the extra parameters.

   /Richard



From ulf.wiger@REDACTED  Wed May 30 15:43:40 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Wed, 30 May 2007 15:43:40 +0200
Subject: [erlang-questions] parameterized modules and OO
In-Reply-To: 
References: 
Message-ID: <6616D98C65DD514BA2E1DDC5F922315501FE9816@esealmw115.eemea.ericsson.se>


Erlhive makes extensive use of parameterized modules
in order to carry user context.

I modify the module variables sometimes, but do so
through a code rewrite, and then explicitly call
the function with new module parameters

...making use of the fact that the actual call
to a parameterized module looks like:

{Mod,Params|...}:F(...)

Example:

-module(pmod, [X, Y]).

-export([set_Y/1,
	 sum/0]).


sum() ->
    X + Y.

set_Y(NewY) ->
    {?MODULE, X,NewY}.

Eshell V5.5.4.3  (abort with ^G)
1> 
1> c(pmod).
{ok,pmod}
2> M = pmod:new(3,4).
{pmod,3,4}
3> M:sum().
7
4> M1 = M:set_Y(5).
{pmod,3,5}
5> M1:sum().
8


BR,
Ulf W

> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of 
> Torbjorn Tornkvist
> Sent: den 30 maj 2007 14:10
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] parameterized modules and OO
> 
> Hi all,
> 
> I just read the very cool paper about "parameterized modules"
> and cooked up a little experimental OO framework. This makes 
> it possible to write code, such as:
> 
>   M = mstring:new("hello").
>   M:len(). => 5
>   M:append(" world"). => "hello world"
>   M:len() => 11
> 
> This code is using an ETS table to store the state, i.e boring...
> (code can be found here: http://www.tornkvist.org/gitweb look 
> for the mobject project)
> 
> So I was thinking, would it be possible for a parameterized 
> module to modify its own module attributes ?
> 
> For example:
> 
> ...
> -store([]).
> 
> append(Str) ->
>     module_info(store, module_info(store) ++ Str).
> 
> This way, the ETS table could go away and we have a 
> self-contained object. One should even be able to add a 
> simple inheritance mechanism.
> 
> So would this be possible to add without too much hassle ?
> 
> Cheers, Tobbe
> (NB: I'm not saying this is good or bad, I'm not even 
> proposing this, I'm just curious to hear if it would be 
> easy/hard/impossible to add this functionality.)
> 
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From mats.cronqvist@REDACTED  Wed May 30 15:51:33 2007
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Wed, 30 May 2007 15:51:33 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
Message-ID: <465D8165.8060707@ericsson.com>

Joe Armstrong wrote:
> Now the book is done I've been thinking about some language changes.
> 
> Here's my list (no particular priority)

   i don't really have any major complaints as far as programming goes. however, 
i spend a lot of time reading other peoples code, and Erlang has some features 
that seems custom made to generate illegible code.
   so i think that if anything, the language should be simplified instead of 
added to, and in particular features that generate verbose and cryptic code 
should be removed or obsoleted. in particular these two;

* get rid of the preprocessor
   IMO, the preprocessor is THE worst feature of erlang. it's ugly, stupid, 
broken and makes it impossible to create programs that deal with source code 
(such as syntax hiliters and refactoring tools). problem is of course that shit 
like the below cannot be parsed until it is preprocessed.

-define(BLA, grump)).
go() -> (?BLA.

   i propose to throw away the existing preprocessor. instead, the source file 
is parsed (by epp_dodger or something derived from it), include files are parsed 
and included and macros substituted. conditional compilation should (i think) be 
disallowed (rarely used and utterly horrible). the resulting parse tree is 
passed to the compiler. this would be largely backward compatible; 99% of all 
macros would work fine (since almost all macros are parseable).
   in this scheme, it would be pretty easy to add a lispy hygienic macro 
facility, which in turn could perhaps replace parse transforms (another 
questionable feature).

* obsolete the type guards
   from rpc.erl:

multicall(Nodes, M, F, A, Timeout)
   when list(Nodes), atom(M), atom(F), list(A), integer(Timeout), Timeout >= 0 ->

   i think it's clear that this is more readable:

multicall(Nodes::list, M::atom, F::atom, A::list, Timeout::int)
   when  Timeout >= 0 ->

   there are of course other candidates for removal (e.g. 'if', 'and', 'or' and 
'catch' (outside of 'try')) but that would mean (seriously) breaking backwards 
compatibility.

     mats


From mogorman@REDACTED  Wed May 30 15:55:21 2007
From: mogorman@REDACTED (Matthew O'Gorman)
Date: Wed, 30 May 2007 08:55:21 -0500
Subject: [erlang-questions] some language changes
In-Reply-To: <465D8165.8060707@ericsson.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<465D8165.8060707@ericsson.com>
Message-ID: 

adding support for Var::type  I think would be a great benefit to the
language, I also wish one could do simple or in the argument list like
call(2||3, Var) as apposed to call(X, Var) when X==2; X==3 ->

mog

On 5/30/07, Mats Cronqvist  wrote:
> Joe Armstrong wrote:
> > Now the book is done I've been thinking about some language changes.
> >
> > Here's my list (no particular priority)
>
>    i don't really have any major complaints as far as programming goes. however,
> i spend a lot of time reading other peoples code, and Erlang has some features
> that seems custom made to generate illegible code.
>    so i think that if anything, the language should be simplified instead of
> added to, and in particular features that generate verbose and cryptic code
> should be removed or obsoleted. in particular these two;
>
> * get rid of the preprocessor
>    IMO, the preprocessor is THE worst feature of erlang. it's ugly, stupid,
> broken and makes it impossible to create programs that deal with source code
> (such as syntax hiliters and refactoring tools). problem is of course that shit
> like the below cannot be parsed until it is preprocessed.
>
> -define(BLA, grump)).
> go() -> (?BLA.
>
>    i propose to throw away the existing preprocessor. instead, the source file
> is parsed (by epp_dodger or something derived from it), include files are parsed
> and included and macros substituted. conditional compilation should (i think) be
> disallowed (rarely used and utterly horrible). the resulting parse tree is
> passed to the compiler. this would be largely backward compatible; 99% of all
> macros would work fine (since almost all macros are parseable).
>    in this scheme, it would be pretty easy to add a lispy hygienic macro
> facility, which in turn could perhaps replace parse transforms (another
> questionable feature).
>
> * obsolete the type guards
>    from rpc.erl:
>
> multicall(Nodes, M, F, A, Timeout)
>    when list(Nodes), atom(M), atom(F), list(A), integer(Timeout), Timeout >= 0 ->
>
>    i think it's clear that this is more readable:
>
> multicall(Nodes::list, M::atom, F::atom, A::list, Timeout::int)
>    when  Timeout >= 0 ->
>
>    there are of course other candidates for removal (e.g. 'if', 'and', 'or' and
> 'catch' (outside of 'try')) but that would mean (seriously) breaking backwards
> compatibility.
>
>      mats
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From richardc@REDACTED  Wed May 30 15:57:11 2007
From: richardc@REDACTED (Richard Carlsson)
Date: Wed, 30 May 2007 15:57:11 +0200
Subject: [erlang-questions] parameterized modules and OO
In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315501FE9816@esealmw115.eemea.ericsson.se>
References: 
	<6616D98C65DD514BA2E1DDC5F922315501FE9816@esealmw115.eemea.ericsson.se>
Message-ID: <465D82B7.8040109@it.uu.se>

Ulf Wiger (TN/EAB) wrote:
> ...making use of the fact that the actual call
> to a parameterized module looks like:
> 
> {Mod,Params|...}:F(...)

Please note that this implementation detail might change at some
point (if/when parameterized modules become an official part of
the language. Our aim was to eventually have a first-class opaque
'module' data type.

     /Richard



From tobbe@REDACTED  Wed May 30 16:01:17 2007
From: tobbe@REDACTED (Torbjorn Tornkvist)
Date: Wed, 30 May 2007 16:01:17 +0200
Subject: [erlang-questions] parameterized modules and OO
In-Reply-To: <465D7A36.6070309@it.uu.se>
References:  <465D7A36.6070309@it.uu.se>
Message-ID: 

Richard Carlsson wrote:
> Torbjorn Tornkvist wrote:
>> So I was thinking, would it be possible for a parameterized module
>> to modify its own module attributes ?
>> [...]
>> So would this be possible to add without too much hassle ?
>>
>> Cheers, Tobbe
>> (NB: I'm not saying this is good or bad, I'm not even proposing
>> this, I'm just curious to hear if it would be easy/hard/impossible to 
>> add this functionality.)
> 
> - The current runtime system does not support runtime changes to the
> attributes (the module_info stuff) of a module.

So how easy/hard/impossible would it be to add this functionality ?

> 
> - The attributes are per-loaded-module ("class members" in OO
> terminology), and what you probably want is a table of attributes per 
> module instance. That table should thus be created when you call 'new'.
> There are at least two possible ways of hiding the table creation:
> 
>    1: Specify the abstract module with N parameters, the last one being
>       the per-instance table, and insert a hand-written function new/M
>       where M=N-1, which calls the autogenerated new/N with a freshly
>       created table.
> 
>    2: Separate the actual abstract module implementation and its
>       interface: give the abstract module some other name, and let the
>       interface module have a new/M function which calls the new/N
>       function of the abstract module with the extra parameters.
> 
>    /Richard
> 

Yes, I did it like this:

%%---
-module(mstring).
-export([new/1]).
new(String) ->
     M = mstring__:new({node(),now()}, String),
     M:init_(),
     M.

%%---
-module(mstring__, [Id,InitString]).
-export([init_/0, len/0, append/1]).
-record(string, {obj = "", len = 0}).
init_()  ->
     Obj = #string{obj = InitString, len = length(InitString)},
     put_(Obj),
     THIS.
get_() ->
     mobject_store:lookup(THIS).
put_(NewObject) ->
     mobject_store:insert(THIS, NewObject).
len() ->
     #string{len = Len} = get_(),
     Len.
append(Str) ->
     #string{obj = Obj} = X = get_(),
     Res = Obj ++ Str,
     put_(X#string{obj = Res, len = length(Res)}),
     Res.

So, if modification of the module attribute was possible,
then I guess get_/0 and put_/0 could be implemented as:

-store([]).

get_() ->
     dict:fetch(THIS, module_info(store)).

put_(NewObj) ->
     module_info(store, dict:store(THIS, NewObj, module_info(store)).

init_() ->
     module_info(store, dict:new()),
     ...as before...


Cheers, Tobbe



From Erik.Stenman@REDACTED  Wed May 30 17:13:28 2007
From: Erik.Stenman@REDACTED (Erik Stenman)
Date: Wed, 30 May 2007 17:13:28 +0200
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
Message-ID: <465D9498.8050202@Kreditor.se>


Bill Clementson wrote:

My old version of kfind

> Yes, I can see how your find function would be useful with a standard
> project directory structure. Unfortunately, I work on a number of
> different open source and commercial projects and can't depend on the
> directory structure or the vc software being consistent, so I took the
> liberty to make a couple of mods to your function:
>
> ;; Find in project source files
> (defvar bc-project-dir nil "Start directory for FIND's")
>
> (defun bc-find-at (path word)
>   "Search source (ignore VC dirs, backups, docs)"
>   (grep-find (concat "find " path (concat " -name '.svn' -prune -o \
>                                             -name 'CVS' -prune -o \
>                                             -name '_darcs' -prune -o \
>                                             -name '*~' -prune -o \
>                                             -name 'doc' -prune -o \
>                                             -type f -print0 \
>                                             | xargs -0 grep -n -e "
> word))))
>
> (defun bc-find (word)
>   (interactive "MFind: ")
>   (bc-find-at
>    (or bc-project-dir ".")
>    word))
>
> (global-set-key "\C-." 'next-error)
> (global-set-key "\C-," 'previous-error)
> (global-set-key "\C-cs" 'bc-find)
>
> If working in a particular project tree, you can set the
> 'bc-project-dir' variable to the "root directory" for the project and
> any searches will be done starting from there (find will ignore any
> Subversion, Darcs, or CVS directories as well as any Emacs backup
> files and "doc" directories). If no 'bc-project-dir' variable is
> specified, searches will be done from the current directory.
>
> Thanks for your tip!

As I said, my version works for me (and the rest of the gang here
at Kreditor), but it is just a quick hack. (It was called kfind
since it was written to work with the directory structure of
Kreditor. But since it turned out to work for most OTP-like projects,
I thought I'd share it.)

I appreciate your version, much cleaner and more versatile,
and it even got documentation. :)

Thanks.

By the way, for some reason I can't get
  (global-set-key "\C-." 'next-error)
  (global-set-key "\C-," 'previous-error)
to work in all emacs versions* I'm using, so I have to resort to:
  (global-set-key (quote [67108910])  'next-error)     ;; C-.
  (global-set-key (quote [67108908]) 'previous-error)  ;; C-,

Any Emacs gurus out there with any ideas why this is so?

* I'm at my game(windows) computer right now and don't have access to
the emacs with problem but I think it was emacs 21.4. In emacs 22.x
"\C-." works fine.

/Happi


From billclem@REDACTED  Wed May 30 18:46:26 2007
From: billclem@REDACTED (Bill Clementson)
Date: Wed, 30 May 2007 09:46:26 -0700
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
References: <465D9498.8050202@Kreditor.se>
Message-ID: 

Erik Stenman  writes:
> By the way, for some reason I can't get
>   (global-set-key "\C-." 'next-error)
>   (global-set-key "\C-," 'previous-error)
> to work in all emacs versions* I'm using, so I have to resort to:
>   (global-set-key (quote [67108910])  'next-error)     ;; C-.
>   (global-set-key (quote [67108908]) 'previous-error)  ;; C-,
>
> Any Emacs gurus out there with any ideas why this is so?
>
> * I'm at my game(windows) computer right now and don't have access to
> the emacs with problem but I think it was emacs 21.4. In emacs 22.x
> "\C-." works fine.

Oops, sorry about that - try the following instead:
(global-set-key [(control .)] 'next-error)
(global-set-key [(control ,)] 'previous-error)

--
Bill Clementson



From billclem@REDACTED  Wed May 30 18:55:51 2007
From: billclem@REDACTED (Bill Clementson)
Date: Wed, 30 May 2007 09:55:51 -0700
Subject: [erlang-questions] Patch for erlang.el (optional debug_info on
	compile)
Message-ID: 

Hi all, 

At present, erlang-mode doesn't provide any way to compile an erlang
file for debug - you have to manually do the debug compile in an
Erlang shell. This bugs me (bad pun!), so I've created a patch for
erlang.el that does a debug compile if the standard compile function
is called with a prefix arg (e.g. - "C-c C-k" does a "normal" compile
and "C-u C-c C-k" does a compile with "debug_info").

Attached is the patch (for erlang-mode version 2.5.2)

-- 
Bill Clementson

--- /usr/local/lib/erlang/lib/tools-2.5.1/emacs/erlang.el	2006-05-03 01:26:49.000000000 -0700
+++ ./erlang.el	2007-05-30 09:24:39.000000000 -0700
@@ -5570,9 +5570,11 @@
 	    (replace-match "" t t))))))
 
 
-(defun inferior-erlang-compile ()
+(defun inferior-erlang-compile (arg)
   "Compile the file in the current buffer.
 
+With prefix arg, compiles for debug.
+
 Should Erlang return `{error, nofile}' it could not load the object
 module after completing the compilation.  This is due to a bug in the
 compile command `c' when using the option `outdir'.
@@ -5584,7 +5586,7 @@
   2) Set the Emacs variable `erlang-compile-use-outdir' to nil.
      To do so, place the following line in your `~/.emacs'-file:
         (setq erlang-compile-use-outdir nil)"
-  (interactive)
+  (interactive "P")
   (save-some-buffers)
   (or (inferior-erlang-running-p)
       (save-excursion
@@ -5592,7 +5594,7 @@
   (or (inferior-erlang-running-p)
       (error "Error starting inferior Erlang shell"))
   (let ((dir (file-name-directory (buffer-file-name)))
-	;;; (file (file-name-nondirectory (buffer-file-name)))
+;;; (file (file-name-nondirectory (buffer-file-name)))
 	(noext (substring (buffer-file-name) 0 -4))
 	;; Hopefully, noone else will ever use these...
 	(tmpvar "Tmp7236")
@@ -5602,12 +5604,16 @@
     (inferior-erlang-wait-prompt)
     (setq end (inferior-erlang-send-command
 	       (if erlang-compile-use-outdir
-		   (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir)
+		   (if current-prefix-arg 
+		       (format "c(\"%s\", [{outdir, \"%s\"}, debug_info])." noext dir)
+		     (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir))
 		 (format
 		  (concat
 		   "f(%s), {ok, %s} = file:get_cwd(), "
 		   "file:set_cwd(\"%s\"), "
-		   "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s.")
+		   (if current-prefix-arg 
+		       "%s = c(\"%s\", [debug_info]), file:set_cwd(%s), f(%s), %s."
+		     "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s."))
 		  tmpvar2 tmpvar
 		  dir
 		  tmpvar2 noext tmpvar tmpvar tmpvar2))



From billclem@REDACTED  Wed May 30 19:04:35 2007
From: billclem@REDACTED (Bill Clementson)
Date: Wed, 30 May 2007 10:04:35 -0700
Subject: [erlang-questions] Weblog post on Emacs/erlang-mode/Distel
References: <465D9498.8050202@Kreditor.se> 
Message-ID: 

Bill Clementson  writes:

> Erik Stenman  writes:
>> By the way, for some reason I can't get
>>   (global-set-key "\C-." 'next-error)
>>   (global-set-key "\C-," 'previous-error)
>> to work in all emacs versions* I'm using, so I have to resort to:
>>   (global-set-key (quote [67108910])  'next-error)     ;; C-.
>>   (global-set-key (quote [67108908]) 'previous-error)  ;; C-,
>>
>> Any Emacs gurus out there with any ideas why this is so?
>>
>> * I'm at my game(windows) computer right now and don't have access to
>> the emacs with problem but I think it was emacs 21.4. In emacs 22.x
>> "\C-." works fine.
>
> Oops, sorry about that - try the following instead:
> (global-set-key [(control .)] 'next-error)
> (global-set-key [(control ,)] 'previous-error)

or the following:
(global-set-key (kbd "C-.") 'next-error)
(global-set-key (kbd "C-,") 'previous-error)

Since I normally use CVS Emacs, I always forget which things didn't
work in earlier versions. From memory, I think the "kbd"-style
keybindings work in earlier versions of emacs; however, I'm not
positive.

--
Bill Clementson



From per@REDACTED  Wed May 30 23:31:37 2007
From: per@REDACTED (Per Hedeland)
Date: Wed, 30 May 2007 23:31:37 +0200 (CEST)
Subject: [erlang-questions] inets - http:request with invalid host
In-Reply-To: <026001c7a288$f9db9dc0$9a0810ac@wavenet.lk>
Message-ID: <200705302131.l4ULVbKn048386@pluto.hedeland.org>

"Sanjaya Vitharana"  wrote:
>
>Attached are the traces. But still I can't find why this happens.

Uh, why what happens, precisely? As far as I have understood (which
could of course be wrong), you are knowingly making a request to a
non-existent IP address? If so, you should of course expect it to fail.
The TCP/IP stack will give up - i.e. time out - the connect() operation
after a "pretty long time". Exactly how long depends on a lot factors,
too many to go into here - a bit over one minute is common, but it can
also be significantly more (or less).

Of course it could be argued that http:request/4 should pass the 8
second timeout that you give it onto gen_tcp:connect/4, instead of
calling gen_tcp:connect/3 which in your case (per above) proceeds to
hang for 3 minutes before it fails - and in the async case spawn the
gen_tcp:connect/4 instead of waiting for it to complete.

--Per Hedeland


From jsnx@REDACTED  Thu May 31 02:26:01 2007
From: jsnx@REDACTED (Jason Dusek)
Date: Wed, 30 May 2007 17:26:01 -0700
Subject: [erlang-questions] tail recursion
Message-ID: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>

Hi All,

I have a server like this:

server({X, Y}) ->
  receive
    {update, NewState} ->
      server(NewState);
    {x, Client} ->
      Client ! X,
      server({X, Y});
    {y, Client} ->
      Client ! Y,
      server({X, Y});
  end
  .

Its tail recursive but, unfortunately, a little redundant -- I'd like
to rewrite it like this:

server({X, Y}) ->
  receive
    {update, NewState} ->
      server(NewState);
    {x, Client} ->
      Client ! X;
    {y, Client} ->
      Client ! Y;
  end,
  server({X, Y})
  .

But I worry that the compiler and interpreter will fail to recognize
my server as tail recursive. Will my rewrite blow the stack?

-- 
_jsn


From ok@REDACTED  Thu May 31 03:09:02 2007
From: ok@REDACTED (ok)
Date: Thu, 31 May 2007 13:09:02 +1200
Subject: [erlang-questions] some language changes
In-Reply-To: <465D8165.8060707@ericsson.com>
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<465D8165.8060707@ericsson.com>
Message-ID: 

On 31 May 2007, at 1:51 am, Mats Cronqvist wrote:
[1. simplify the language]
[2. replace the preprocessor]

>  conditional compilation should (i think) be
> disallowed (rarely used and utterly horrible).

I have been saying "Delenda est preprocessor!" since it came out.
I note, however, that there are 518 "-if[n]def(...)." occurrences
in the R11B sources.

Quite a lot of those are protection against multiple includes:
	%% thingy_whatsit_gubbins.hrl
	-ifndef(THINGY_WHATSIT_GUBBINS_HRL).
	-define(THINGY_WHATSIT_GUBBINS_HRL, true).
	...
	-endif.
To my astonishment, some of the files that do this contain nothing else!
The answer is simple:  they are produced by some kind of tool that
emits -record declarations, and for these files there happened to be
none.  Some use a _HRL suffix; some use a -MIB suffix.

This usage accounts for 165 (32%) of the -ifs.  Either of two changes
would eliminate them entirely.

(a) -require(File_Name).
     would resolve the File_Name just like -include(File_Name),
     then check a list of included files.  If the file was in that
     last, -require would do nothing, otherwise it would act just
     like -include.  -include (and thus -require) would add the
     resolved file name to the list.

(b) Allow -define and -record declarations to be repeated, as long as
     the repetitions are identical as token sequences.  (This is what
     C does about #define.  6.10.3 "An identifier currently defined as
     a macro ... shall not be redefined by another ... directive unless
     the second definition is [the same kind, with the same arguments
     if any] and the two replacement lists are identical.)

There's a bunch of
	-include("snmp_verbosity.hrl").
	-ifndef(default_verbosity).
	-define(default_verbosity, silence).
	-endif.
in lib/snmp/src/... , many of which never visibly mention
default_verbosity again.  One wonders why this stuff isn't in
snmp_verbosity.hrl itself.  2.5% of the -ifs have to do with
SNMP verbosity; there has to be a better way to do this.

Another 121 have "debug" in their name.

Then there are at least 122 (24%) which are clearly Hipe-related.
The use of -if to select data structures isn't really necessary.
Instead of

	%define(USE_TUPLES, true).
	-define(USE_GBTREES, true).
	-ifdef(USE_TUPLES).
	new(N, V) ->
	    erlang:make_tuple(N, V).
	...
	-endif.
	-ifdef(USE_GBTREES).
	new(N, V) ->
	    gb_trees:from_orddict(mklist(N, V)).
	...
	-endif.

one could write

	Use = gb_trees.  % or tuples.

	new(N, V) when Use =:= tuples ->
	    erlang:make_tuple(N, V);
	new(N, V) when Use =:= gb_trees ->
	    gb_trees:from_orddict(mklist(N, V)).
	...

This plus constant propagation, dead code elimination. and inlining
does the trick.  Just allowing

	 = .

at top level would go a long way towards eliminating -define.
What this replacement cannot do, and what Hipe sometimes does,
is
	-ifdef(FOO).
	-export([ick/1,ack/2,ugh/3]).
	-endif.

(not an actual example).

Wait a bit.  Make that 141 (27%) in Hipe.  All the
	-ifdef(notdef).
	stuff
	-endif.
occurrences (19 of them) seem to be in there.  This amounts to  
commenting
out code which is not currently in use but you're not quite ready to get
rid of.  One problem with this is that code that is not compiled  
tends to
suffer bit rot.  Other aspects of the code around it change so that when
you decide that after all you DO want it back, it tends to have become
unusable.  One could imagine a -moribund directive which would cause
the following declaration to be syntax checked but discarded from the
AST output.

Prolog has a rather nice feature.  When you are reading terms from a
file, the end of the file is indicated by returning the term
'end_of_file'.  So you can cause the compiler to stop early in a file
by explicitly writing
	end_of_file.
So I tended to put test code and moribund code and big explanatory
comments after an end_of_file, making it trivial to move them back
where the compiler would see them if I wanted it to.  If you want to
allow module definitions in the shell, you are going to want an -end
directive there.  An -end directive is particularly nice for letting
you put lots of commentary and examples and stuff in a file where
people can see it, but where the compiler won't spend ANY time looking,
unlike ordinary comments.

That leaves about 76 (15%) of -ifs unexamined, and it's time I stopped.

[3. Replace type guards by ::constraints on variables in patterns]

Some IBM mainframe Prolog (was it VM Prolog?) did this, using infix
$ rather than infix ::.  I've seen it in another language whose name
I unfortunately forget.  However,

  (a) This proposal makes the language more complicated.
  (b) It makes some code more readable, but it makes other code
      less readable.
  (c) You STILL need type guards when there is a call to element,
      hd, or tl in a guard, e.g.,
	f(N, T) when is_pid(element(N, T)) -> ...
  (d) You STILL need type guards when a guard is disjunctive, e.g.,
	f(X) when is_record(X, update) ; is_record(X, delete) -> ...

The Variable::type feature could be handled by source-to-source
translation; the one case where this wouldn't be trivial is
Pattern = Expression.




From ulf@REDACTED  Thu May 31 08:32:10 2007
From: ulf@REDACTED (Ulf Wiger)
Date: Thu, 31 May 2007 08:32:10 +0200
Subject: [erlang-questions] tail recursion
In-Reply-To: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
References: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
Message-ID: <8209f740705302332y20f6c051p608051b43873433@mail.gmail.com>

2007/5/31, Jason Dusek :
>
>
> Its tail recursive but, unfortunately, a little redundant -- I'd like
> to rewrite it like this:
>
> server({X, Y}) ->
>   receive
>     {update, NewState} ->
>       server(NewState);
>     {x, Client} ->
>       Client ! X;
>     {y, Client} ->
>       Client ! Y;
>   end,
>   server({X, Y})
>   .
>
> But I worry that the compiler and interpreter will fail to recognize
> my server as tail recursive. Will my rewrite blow the stack?
>

Yup, since the call to server/1 from within the receive clause is not in
fact a tail call.

A common way to solve this dilemma is to do this:

server({X, Y} = State) ->
    S1 =
        receive
            {update, NewState} ->
                NewState;
            {x, Client} ->
                Client ! X,
                State;
            {y, Client} ->
                Client ! Y,
                S
        end,
    server(S1).

I added the "= State" in the function head so I wouldn't have to rebuild the
tuple when nothing has changed.

BR,
Ulf W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From qrilka@REDACTED  Thu May 31 10:32:54 2007
From: qrilka@REDACTED (Kirill Zaborski)
Date: Thu, 31 May 2007 11:32:54 +0300
Subject: [erlang-questions] Erlang emacs mode bug?
Message-ID: <337538cb0705310132y6cbef882pbb08d26843639303@mail.gmail.com>

I'm playing around with distel (thanx Bill Clementson for a wonderful
post about it) and do compilation with debug_info manually ( with
c(test, [debug_info]). ).
And I have found that something strange happens: when I start shell
and run the command 1st time I receive no result until I press ENTER,
later everything work OK.
I use Emacs 22 from http://www.emacs.uniyar.ac.ru/programs/windows/ on
Windows 2003.
Does anybody have any idea what may be the reason on such behavior?

And also I have a couple of questions about distel - is it OK to ask it here?

Regards,
Kirill.


From erlang@REDACTED  Thu May 31 11:14:51 2007
From: erlang@REDACTED (Joe Armstrong)
Date: Thu, 31 May 2007 11:14:51 +0200
Subject: [erlang-questions] Parsing Objective C type encodings
Message-ID: <9b08084c0705310214p5dfcd476k20d592dbfc5b5f97@mail.gmail.com>

Hi,

It would be nice to build something like F-Script or RubyCocoa only in Erlang

Is there any Erlang code for obtaining and parsing Objective C type encodings?

Any progress since

http://www.erlang.org/pipermail/erlang-questions/2006-August/021926.html

Is it actually necessary to parse the objective C header files? -
won't run-time introspection
be sufficient.


/Joe


From me@REDACTED  Thu May 31 11:24:44 2007
From: me@REDACTED (KatolaZ)
Date: Thu, 31 May 2007 11:24:44 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
Message-ID: <20070531092444.GN25656@katolaz.homeunix.net>

On Wed, May 30, 2007 at 01:36:35AM +0200, Rickard Green wrote:

For the sake of clarity:

- I'm just trying to understand if is there any chance of having a
better behaviour of erlang scheduler for high prio processes. This
because I want to try to include (somehow) hard real-time process
support in Erlang (at least for OSes which support them!) :-)

- I'm not trying to miscreditate the work of OTP group, or of other
developers which have been working on Erlang in the last years. Their
work is fundamental for the community and real appreciable :-)

...but...

> >So, just for the purpose of discussion, why don't think at "virtual"
> >synchronisation points for high priority procs ? I.e., if a high
> >priority task has not been interrupted for X reductions (beeing X a
> >relatively large integer), then goto do_schedule1 anyway, letting
> >other high priority process to run....
> 
> If I understood you right, you want the scheduling to work as it is
> implemented right now.
> 
> Regardless of priority, a process is unconditionally scheduled out when
> it has consumed (currently) 2000 reductions (since it was last scheduled
> in). I.e., a busy loop in a high priority process will not prevent other
> high priority processes from running, but it will prevent normal and low
> priority processes from running.
> 

Unfortunately, it seems to be false, or I'm missing something!  Here
is a simple example where all code for high prio processes is loaded
(it is indeed a self-contained module!), and proc_high2 is starved by
proc_high:

-------------
-module(new_test).

-compile(export_all).

test(Max, Prio, Prio2) ->
    process_flag(priority, high),
    register(proc_high, spawn(fun() -> cpu_proc(Max, true, Prio) end)),
    register(proc_high2, spawn(fun() -> high_proc(Prio2) end)).

high_proc(Prio) ->
    process_flag (priority, Prio),
    count(0).

cpu_func(X, Limit) ->
    if 
        (X == Limit) ->
            X;
        true ->
            cpu_func(X+1, Limit)
    end.


cpu_proc(Limit, Send, Prio) ->
    process_flag (priority, Prio),
    Value = cpu_func(0, Limit),
    case Send of 
        true ->
            proc_high2 ! x,
            io:format("OK! Proc ~p exiting at ~p~n", [self(), Value]),
            ok;
        _ ->
            ok
    end.

count (X) ->
    receive
        _ -> io:format ("Process ~p exiting after ~p cycles~n", [process_info (self(), registered_name), X])
    after 0 ->
            count (X + 1)
    end.
-------

then, executing that code I obtain:

Eshell V5.5.2  (abort with ^G)
1> c(new_test).
{ok,new_test}
2> new_test:test(10000000, normal, normal).
true
OK! Proc <0.37.0> exiting at 10000000
Process {registered_name,proc_high2} exiting after 9998992 cycles
3> new_test:test(10000000, high, high).    
OK! Proc <0.40.0> exiting at 10000000
Process {registered_name,proc_high2} exiting after 0 cycles
true
4> 

-------

I.e, if both processes are executed with normal prio, all works, even
if proc_high does not have explicit synchronisation points. When both
processes are executed with prio high, the second process is starved
(it executes for 0 cycles....).  Additionally, if you swap the two
calls to "register", i.e. launching proc_high2 *before* proc_high,
also the shell is starved, and the system *blocks* (you've to CTRL+C
the shell...)

So, I'm probably missing something, but high prio processes without
explicit synchronisation point seem to be *non-preemptible* at
all......

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From rickard.s.green@REDACTED  Thu May 31 11:49:10 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Thu, 31 May 2007 11:49:10 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070531092118.GM25656@katolaz.homeunix.net>
References: <465AF468.6080805@industrial-designers.co.uk>
	
	<465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
	<20070529092629.GA25656@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
	<465CB903.90002@ericsson.com>
	<20070531092118.GM25656@katolaz.homeunix.net>
Message-ID: <465E9A16.2060305@ericsson.com>



KatolaZ wrote:

>>> So, just for the purpose of discussion, why don't think at "virtual"
>>> synchronisation points for high priority procs ? I.e., if a high
>>> priority task has not been interrupted for X reductions (beeing X a
>>> relatively large integer), then goto do_schedule1 anyway, letting
>>> other high priority process to run....
>> If I understood you right, you want the scheduling to work as it is
>> implemented right now.
>>
>> Regardless of priority, a process is unconditionally scheduled out when
>> it has consumed (currently) 2000 reductions (since it was last scheduled
>> in). I.e., a busy loop in a high priority process will not prevent other
>> high priority processes from running, but it will prevent normal and low
>> priority processes from running.
>>
> 
> Unfortunately, it seems to be false, or I'm missing something!  Here
> is a simple example where all code for high prio processes is loaded
> (it is indeed a self-contained module!), and proc_high2 is starved by
> proc_high:
> 

No, it is not false. The problem is that proc_high2 never gets the 
chance the set prio high. It is still on prio normal. You have to spawn 
it with prio high (see spawn_opt) in order for this example to work as 
expected (and it will; i've tried it).

BR,
Rickard Green, Erlang/OTP, Ericsson AB.


From me@REDACTED  Thu May 31 11:59:32 2007
From: me@REDACTED (KatolaZ)
Date: Thu, 31 May 2007 11:59:32 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465E9A16.2060305@ericsson.com>
References: <465B2A64.90005@diit.unict.it>
	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>
	<20070529080444.GC4649@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>
	<20070529092629.GA25656@katolaz.homeunix.net>
	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>
	<20070529103441.GC25656@katolaz.homeunix.net>
	<465CB903.90002@ericsson.com>
	<20070531092118.GM25656@katolaz.homeunix.net>
	<465E9A16.2060305@ericsson.com>
Message-ID: <20070531095932.GO25656@katolaz.homeunix.net>

On Thu, May 31, 2007 at 11:49:10AM +0200, Rickard Green wrote:
> > 
> > Unfortunately, it seems to be false, or I'm missing something!  Here
> > is a simple example where all code for high prio processes is loaded
> > (it is indeed a self-contained module!), and proc_high2 is starved by
> > proc_high:
> > 
> 
> No, it is not false. The problem is that proc_high2 never gets the 
> chance the set prio high. It is still on prio normal. You have to spawn 
> it with prio high (see spawn_opt) in order for this example to work as 
> expected (and it will; i've tried it).
> 

OK, thank you :-)

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]


From Erik.Stenman@REDACTED  Thu May 31 12:11:50 2007
From: Erik.Stenman@REDACTED (Erik Stenman)
Date: Thu, 31 May 2007 12:11:50 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465E9A16.2060305@ericsson.com>
References: <465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>	<20070529103441.GC25656@katolaz.homeunix.net>	<465CB903.90002@ericsson.com>	<20070531092118.GM25656@katolaz.homeunix.net>
	<465E9A16.2060305@ericsson.com>
Message-ID: <465E9F66.30700@kreditor.se>

Rickard Green wrote:
> KatolaZ wrote:
>
>   
>>>> So, just for the purpose of discussion, why don't think at "virtual"
>>>> synchronisation points for high priority procs ? I.e., if a high
>>>> priority task has not been interrupted for X reductions (beeing X a
>>>> relatively large integer), then goto do_schedule1 anyway, letting
>>>> other high priority process to run....
>>>>         
>>> If I understood you right, you want the scheduling to work as it is
>>> implemented right now.
>>>
>>> Regardless of priority, a process is unconditionally scheduled out when
>>> it has consumed (currently) 2000 reductions (since it was last scheduled
>>> in). I.e., a busy loop in a high priority process will not prevent other
>>> high priority processes from running, but it will prevent normal and low
>>> priority processes from running.
>>>
>>>       
>> Unfortunately, it seems to be false, or I'm missing something!  Here
>> is a simple example where all code for high prio processes is loaded
>> (it is indeed a self-contained module!), and proc_high2 is starved by
>> proc_high:
>>
>>     
>
> No, it is not false. The problem is that proc_high2 never gets the 
> chance the set prio high. It is still on prio normal. You have to spawn 
> it with prio high (see spawn_opt) in order for this example to work as 
> expected (and it will; i've tried it).
>   
I guess spawning with prio high also is a bit dangerous unless the 
process you
are spawing from (p1) also has prio high, otherwise the first spawned 
high prio
process (p2) might starve the spawner. (If p1 is suspended before it 
spawns p3.)

Am I right?

/Happi


From erlang@REDACTED  Thu May 31 12:19:23 2007
From: erlang@REDACTED (Joe Armstrong)
Date: Thu, 31 May 2007 12:19:23 +0200
Subject: [erlang-questions] tail recursion
In-Reply-To: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
References: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
Message-ID: <9b08084c0705310319r405ea938v2dcb136730d9314c@mail.gmail.com>

On 5/31/07, Jason Dusek  wrote:
> Hi All,
>
> I have a server like this:
>
> server({X, Y}) ->
>   receive
>     {update, NewState} ->
>       server(NewState);
>     {x, Client} ->
>       Client ! X,
>       server({X, Y});
>     {y, Client} ->
>       Client ! Y,
>       server({X, Y});
>   end
>   .
>
> Its tail recursive but, unfortunately, a little redundant -- I'd like
> to rewrite it like this:
>
> server({X, Y}) ->
>   receive
>     {update, NewState} ->
>       server(NewState);
>     {x, Client} ->
>       Client ! X;
>     {y, Client} ->
>       Client ! Y;
>   end,
>   server({X, Y})
>   .
>
> But I worry that the compiler and interpreter will fail to recognize
> my server as tail recursive. Will my rewrite blow the stack?

Yes you will blow the stack  - this is not tail recursive.
I'll explain why, I'll rewrite your code a bit.
suppose we have this:

> server({X, Y}) ->
>   receive
>     {update, NewState} ->
>       foo(NewState);         <--- X (I call foo here instead of server)
>     {x, Client} ->
>       Client ! X;
>     {y, Client} ->
>       Client ! Y;
>   end,
>   server({X, Y})   <--- Y

When foo returns (at point X) we call server (at Y)
So the compiler creates a new stack frame every time foo is called

Now this code *is* tail recursive if foo returns. But in your case
you called server(NewState) *which never returns*

So each pass through the code at point X builds an additional call frame
on the stack - bad news - after a while you'll run out of memory

/Joe


From rickard.s.green@REDACTED  Thu May 31 12:20:22 2007
From: rickard.s.green@REDACTED (Rickard Green)
Date: Thu, 31 May 2007 12:20:22 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <465E9F66.30700@kreditor.se>
References: <465AF468.6080805@industrial-designers.co.uk>		<465B2A64.90005@diit.unict.it>	<6616D98C65DD514BA2E1DDC5F922315501FB06C7@esealmw115.eemea.ericsson.se>	<20070529080444.GC4649@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0C5E@esealmw115.eemea.ericsson.se>	<20070529092629.GA25656@katolaz.homeunix.net>	<6616D98C65DD514BA2E1DDC5F922315501FB0D61@esealmw115.eemea.ericsson.se>	<20070529103441.GC25656@katolaz.homeunix.net>	<465CB903.90002@ericsson.com>	<20070531092118.GM25656@katolaz.homeunix.net>	<465E9A16.2060305@ericsson.com>
	<465E9F66.30700@kreditor.se>
Message-ID: <465EA166.9000401@ericsson.com>



Erik Stenman wrote:
> Rickard Green wrote:
>> KatolaZ wrote:
>>
>>   
>>>>> So, just for the purpose of discussion, why don't think at "virtual"
>>>>> synchronisation points for high priority procs ? I.e., if a high
>>>>> priority task has not been interrupted for X reductions (beeing X a
>>>>> relatively large integer), then goto do_schedule1 anyway, letting
>>>>> other high priority process to run....
>>>>>         
>>>> If I understood you right, you want the scheduling to work as it is
>>>> implemented right now.
>>>>
>>>> Regardless of priority, a process is unconditionally scheduled out when
>>>> it has consumed (currently) 2000 reductions (since it was last scheduled
>>>> in). I.e., a busy loop in a high priority process will not prevent other
>>>> high priority processes from running, but it will prevent normal and low
>>>> priority processes from running.
>>>>
>>>>       
>>> Unfortunately, it seems to be false, or I'm missing something!  Here
>>> is a simple example where all code for high prio processes is loaded
>>> (it is indeed a self-contained module!), and proc_high2 is starved by
>>> proc_high:
>>>
>>>     
>> No, it is not false. The problem is that proc_high2 never gets the 
>> chance the set prio high. It is still on prio normal. You have to spawn 
>> it with prio high (see spawn_opt) in order for this example to work as 
>> expected (and it will; i've tried it).
>>   
> I guess spawning with prio high also is a bit dangerous unless the 
> process you
> are spawing from (p1) also has prio high, otherwise the first spawned 
> high prio
> process (p2) might starve the spawner. (If p1 is suspended before it 
> spawns p3.)
> 
> Am I right?
> 

Yes, if you removed prio high from p1 in this example you could 
potentially get that problem.

BR,
Rickard Green, Erlang/OTP, Ericsson AB.

> /Happi
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 


From erlang@REDACTED  Thu May 31 12:23:31 2007
From: erlang@REDACTED (Joe Armstrong)
Date: Thu, 31 May 2007 12:23:31 +0200
Subject: [erlang-questions] tail recursion
In-Reply-To: <8209f740705302332y20f6c051p608051b43873433@mail.gmail.com>
References: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
	<8209f740705302332y20f6c051p608051b43873433@mail.gmail.com>
Message-ID: <9b08084c0705310323h663f2b1aldf0312d903466768@mail.gmail.com>

On 5/31/07, Ulf Wiger  wrote:
>
>
> 2007/5/31, Jason Dusek :
> >
> > Its tail recursive but, unfortunately, a little redundant -- I'd like
> > to rewrite it like this:
> >
> > server({X, Y}) ->
> >   receive
> >     {update, NewState} ->
> >       server(NewState);
> >     {x, Client} ->
> >       Client ! X;
> >     {y, Client} ->
> >       Client ! Y;
> >   end,
> >   server({X, Y})
> >   .
> >
> > But I worry that the compiler and interpreter will fail to recognize
> > my server as tail recursive. Will my rewrite blow the stack?
> >
>
> Yup, since the call to server/1 from within the receive clause is not in
> fact a tail call.
>
> A common way to solve this dilemma is to do this:
>
> server({X, Y} = State) ->
>     S1 =
>         receive
>             {update, NewState} ->
>                 NewState;
>             {x, Client} ->
>                 Client ! X,
>                 State;
>             {y, Client} ->
>                 Client ! Y,
>                 S
>         end,
>     server(S1).
>
> I added the "= State" in the function head so I wouldn't have to rebuild the
> tuple when nothing has changed.
>

Why not just

  server({X, Y} = State) ->
     receive
             {update, NewState} ->
                 NewState;
             {x, Client} ->
                 Client ! X,
                 server(State);
             {y, Client} ->
                 Client ! Y,
                 sever(State)
    end.

/Joe

> BR,
> Ulf W
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>


From ulf.wiger@REDACTED  Thu May 31 13:32:28 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 31 May 2007 13:32:28 +0200
Subject: [erlang-questions] tail recursion
In-Reply-To: <9b08084c0705310323h663f2b1aldf0312d903466768@mail.gmail.com>
References: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com><8209f740705302332y20f6c051p608051b43873433@mail.gmail.com>
	<9b08084c0705310323h663f2b1aldf0312d903466768@mail.gmail.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F92231550201B978@esealmw115.eemea.ericsson.se>

 
Joe Armstrong wrote:
> 
> Why not just
> 
>   server({X, Y} = State) ->
>      receive
>              {update, NewState} ->
>                  NewState;
>              {x, Client} ->
>                  Client ! X,
>                  server(State);
>              {y, Client} ->
>                  Client ! Y,
>                  sever(State)
>     end.

Besides the fact that there are two bugs in your
program? (*) (:

Oh, I don't know. A logical next step might be to
break out the logic into a separate function, 
similar to handle_call(Request, From, State) in 
gen_server. This is easier with my version.
But either version is fine.

BR,
Ulf W


(*) (1) no recursive call in the first clause
    (2) typo in the server/1 call in the third.
    The compiler would of course catch (2).



From kenneth.lundin@REDACTED  Thu May 31 13:56:23 2007
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Thu, 31 May 2007 13:56:23 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: 
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>
	<465D8165.8060707@ericsson.com>
	
Message-ID: 

Hi,

Just for information I can say that we in the OTP team have a clear stategy
not to use conditional compilation at all for Erlang code. At least
not for release builds. We tried that in the beginning but found that
it was a bad idea.
So, all Erlang code is unconditionally compiled for the release.
If that is not true it is a bug to be corrected.
For example different behaviour on different plattforms is always handled in
runtime with a call to os:type().
There might be complete modules which only are used on a specific platform.
This result in that all .beam files are the same for all plattforms
and this will
also be evident in the next open source release which will contain pre-built
.beam files.

/Kenneth

On 5/31/07, ok  wrote:
> On 31 May 2007, at 1:51 am, Mats Cronqvist wrote:
> [1. simplify the language]
> [2. replace the preprocessor]
>
> >  conditional compilation should (i think) be
> > disallowed (rarely used and utterly horrible).
>
> I have been saying "Delenda est preprocessor!" since it came out.
> I note, however, that there are 518 "-if[n]def(...)." occurrences
> in the R11B sources.
>
> Quite a lot of those are protection against multiple includes:
>         %% thingy_whatsit_gubbins.hrl
>         -ifndef(THINGY_WHATSIT_GUBBINS_HRL).
>         -define(THINGY_WHATSIT_GUBBINS_HRL, true).
>         ...
>         -endif.
> To my astonishment, some of the files that do this contain nothing else!
> The answer is simple:  they are produced by some kind of tool that
> emits -record declarations, and for these files there happened to be
> none.  Some use a _HRL suffix; some use a -MIB suffix.
>
> This usage accounts for 165 (32%) of the -ifs.  Either of two changes
> would eliminate them entirely.
>
> (a) -require(File_Name).
>      would resolve the File_Name just like -include(File_Name),
>      then check a list of included files.  If the file was in that
>      last, -require would do nothing, otherwise it would act just
>      like -include.  -include (and thus -require) would add the
>      resolved file name to the list.
>
> (b) Allow -define and -record declarations to be repeated, as long as
>      the repetitions are identical as token sequences.  (This is what
>      C does about #define.  6.10.3 "An identifier currently defined as
>      a macro ... shall not be redefined by another ... directive unless
>      the second definition is [the same kind, with the same arguments
>      if any] and the two replacement lists are identical.)
>
> There's a bunch of
>         -include("snmp_verbosity.hrl").
>         -ifndef(default_verbosity).
>         -define(default_verbosity, silence).
>         -endif.
> in lib/snmp/src/... , many of which never visibly mention
> default_verbosity again.  One wonders why this stuff isn't in
> snmp_verbosity.hrl itself.  2.5% of the -ifs have to do with
> SNMP verbosity; there has to be a better way to do this.
>
> Another 121 have "debug" in their name.
>
> Then there are at least 122 (24%) which are clearly Hipe-related.
> The use of -if to select data structures isn't really necessary.
> Instead of
>
>         %define(USE_TUPLES, true).
>         -define(USE_GBTREES, true).
>         -ifdef(USE_TUPLES).
>         new(N, V) ->
>             erlang:make_tuple(N, V).
>         ...
>         -endif.
>         -ifdef(USE_GBTREES).
>         new(N, V) ->
>             gb_trees:from_orddict(mklist(N, V)).
>         ...
>         -endif.
>
> one could write
>
>         Use = gb_trees.  % or tuples.
>
>         new(N, V) when Use =:= tuples ->
>             erlang:make_tuple(N, V);
>         new(N, V) when Use =:= gb_trees ->
>             gb_trees:from_orddict(mklist(N, V)).
>         ...
>
> This plus constant propagation, dead code elimination. and inlining
> does the trick.  Just allowing
>
>          = .
>
> at top level would go a long way towards eliminating -define.
> What this replacement cannot do, and what Hipe sometimes does,
> is
>         -ifdef(FOO).
>         -export([ick/1,ack/2,ugh/3]).
>         -endif.
>
> (not an actual example).
>
> Wait a bit.  Make that 141 (27%) in Hipe.  All the
>         -ifdef(notdef).
>         stuff
>         -endif.
> occurrences (19 of them) seem to be in there.  This amounts to
> commenting
> out code which is not currently in use but you're not quite ready to get
> rid of.  One problem with this is that code that is not compiled
> tends to
> suffer bit rot.  Other aspects of the code around it change so that when
> you decide that after all you DO want it back, it tends to have become
> unusable.  One could imagine a -moribund directive which would cause
> the following declaration to be syntax checked but discarded from the
> AST output.
>
> Prolog has a rather nice feature.  When you are reading terms from a
> file, the end of the file is indicated by returning the term
> 'end_of_file'.  So you can cause the compiler to stop early in a file
> by explicitly writing
>         end_of_file.
> So I tended to put test code and moribund code and big explanatory
> comments after an end_of_file, making it trivial to move them back
> where the compiler would see them if I wanted it to.  If you want to
> allow module definitions in the shell, you are going to want an -end
> directive there.  An -end directive is particularly nice for letting
> you put lots of commentary and examples and stuff in a file where
> people can see it, but where the compiler won't spend ANY time looking,
> unlike ordinary comments.
>
> That leaves about 76 (15%) of -ifs unexamined, and it's time I stopped.
>
> [3. Replace type guards by ::constraints on variables in patterns]
>
> Some IBM mainframe Prolog (was it VM Prolog?) did this, using infix
> $ rather than infix ::.  I've seen it in another language whose name
> I unfortunately forget.  However,
>
>   (a) This proposal makes the language more complicated.
>   (b) It makes some code more readable, but it makes other code
>       less readable.
>   (c) You STILL need type guards when there is a call to element,
>       hd, or tl in a guard, e.g.,
>         f(N, T) when is_pid(element(N, T)) -> ...
>   (d) You STILL need type guards when a guard is disjunctive, e.g.,
>         f(X) when is_record(X, update) ; is_record(X, delete) -> ...
>
> The Variable::type feature could be handled by source-to-source
> translation; the one case where this wouldn't be trivial is
> Pattern = Expression.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From bjorn@REDACTED  Thu May 31 14:15:56 2007
From: bjorn@REDACTED (Bjorn Gustavsson)
Date: 31 May 2007 14:15:56 +0200
Subject: [erlang-questions] is there something like #line
In-Reply-To: <46598E76.6080008@fiit.stuba.sk>
References: <46598E76.6080008@fiit.stuba.sk>
Message-ID: 

Use

-file(Filename, Line).

Example from erl_parse.erl:

-file("erl_parse.yrl", 418).

/Bjorn

Matej Kosik  writes:

> * PGP Signed: 05/27/2007 at 03:58:14 PM
> Hello,
> 
> Some languages provide mechanisms for "redefining" the current filename and line number. This is done via #line directive. It is not very useful if one writes the code in Erlang, but it is useful when the Erlang code is generated from some other file. For example from a noweb file. I can tangle the actual code so that before each code chunk will be placed correct
> 
> 	# line  
> 
> command. This way it is possible to influence the compiler error messages and warnings so that they refer to the original file (and line number) rather than to the line number in the generated file.
> 
> Is there a similar directive in Erlang? I have tried to google it out, but with little luck. In `Erlang Reference Manual', section 7.2 there I see two interesting macros:
> 
> 	?FILE.
> 	    The file name of the current module. 
> 	?LINE.
> 	    The current line number.
> 
> Unfortunatelly, when I tried to redefine it, the compiler rejected such redefinitions. Any hint is appreciated.
> 
> PS: I am still not 100% sure that using noweb with Erlang is a good idea. But I have used noweb elsewhere (with C and with Pict) so in my current interesting Erlang-task I decided to try it too.
> 
> Regards
> -- 
> Matej Kosik
> 
> * Matej Kosik 
> * 0xF248FE18 (L)
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB



From mogorman@REDACTED  Thu May 31 15:07:41 2007
From: mogorman@REDACTED (Matthew O'Gorman)
Date: Thu, 31 May 2007 08:07:41 -0500
Subject: [erlang-questions] erlang-mode emacs tabs vs spaces
Message-ID: 

Recently on the erlyaws list it has been brought up that erlang-mode
for emacs uses a combination of tabs and spaces for its indentation.
for example

-record(local, {index,
		location}).
the above uses 2 tabs to line up in emacs where as
add_location(Location) ->
    Fun = fun() ->
		   mnesia:write(#location{index = ,
					  location = Location}),
		   end,
    mnesia:transaction(Fun).

actually uses a combination of tabs and spaces for the whitespace. the
mnesia line has 2 tabs and 3 spaces and the line after that has 5 tabs
and 1 space.  seems like when anything is tabbed more than 4 spaces
emacs uses a tab to help fill the space at least in my environment.

I never even realized any of this as all of this is handled
beautifully in emacs, however for the unfortunate using vim, or other
editors ^_^ This could be a problem I imagine, especially if working
together on a large project where formatting needs to be the same.   I
imagine it would be easiest to convert all to spaces, or to just use
tabs.  I think it would probably be best to just use spaces, what do
yall think?

Mog


From bengt.kleberg@REDACTED  Thu May 31 15:16:16 2007
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Thu, 31 May 2007 15:16:16 +0200
Subject: [erlang-questions] erlang-mode emacs tabs vs spaces
In-Reply-To: 
References: 
Message-ID: <465ECAA0.9090405@ericsson.com>

On 2007-05-31 15:07, Matthew O'Gorman wrote:
...deleted
> imagine it would be easiest to convert all to spaces, or to just use
> tabs.  I think it would probably be best to just use spaces, what do
> yall think?

you could use an erlang pretty printer (i use erl_prettypr in 
syntax_tools) before checking in the code in your .


bengt
-- 
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


From mogorman@REDACTED  Thu May 31 15:20:57 2007
From: mogorman@REDACTED (Matthew O'Gorman)
Date: Thu, 31 May 2007 08:20:57 -0500
Subject: [erlang-questions] erlang-mode emacs tabs vs spaces
In-Reply-To: <465ECAA0.9090405@ericsson.com>
References: 
	<465ECAA0.9090405@ericsson.com>
Message-ID: 

There are probably lots of fairly easy ways one could work around
this, I am just suggesting that a mix of tabs and spaces seems silly
at best unless there is some reason I'm unaware of it would be better
to go to the python route and just have it consistent.

mog

On 5/31/07, Bengt Kleberg  wrote:
> On 2007-05-31 15:07, Matthew O'Gorman wrote:
> ...deleted
> > imagine it would be easiest to convert all to spaces, or to just use
> > tabs.  I think it would probably be best to just use spaces, what do
> > yall think?
>
> you could use an erlang pretty printer (i use erl_prettypr in
> syntax_tools) before checking in the code in your .
>
>
> bengt
> --
> Those were the days...
>     EPO guidelines 1978: "If the contribution to the known art resides
>     solely in a computer program then the subject matter is not
>     patentable in whatever manner it may be presented in the claims."
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From qrilka@REDACTED  Thu May 31 16:11:47 2007
From: qrilka@REDACTED (Qrilka)
Date: Thu, 31 May 2007 15:11:47 +0100
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
References: 
Message-ID: <20070531141147.8C8825A1F7@mail.erlangsystems.com>



uwiger wrote:

It _is_ used in telecommunication platforms, web apps,
massively concurrent systems to distributed high 
performance platforms. It is also used in banking and
invoicing systems.

(end of quote)

Ulf, is this a public info about Erlang in banking/invoicing systems? Can we read something somewhere about it?

Regards,
Kirill.
_________________________________________________________
Post sent from http://www.trapexit.org


From david.hopwood@REDACTED  Thu May 31 16:21:40 2007
From: david.hopwood@REDACTED (David Hopwood)
Date: Thu, 31 May 2007 15:21:40 +0100
Subject: [erlang-questions] some language changes
In-Reply-To: 
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>	<465D8165.8060707@ericsson.com>
	
Message-ID: <465ED9F4.1090409@industrial-designers.co.uk>

ok wrote:
> On 31 May 2007, at 1:51 am, Mats Cronqvist wrote:
> [1. simplify the language]
> [2. replace the preprocessor]
> 
>> conditional compilation should (i think) be
>>disallowed (rarely used and utterly horrible).
> 
> I have been saying "Delenda est preprocessor!" since it came out.
> I note, however, that there are 518 "-if[n]def(...)." occurrences
> in the R11B sources.
> 
> Quite a lot of those are protection against multiple includes:
> 	%% thingy_whatsit_gubbins.hrl
> 	-ifndef(THINGY_WHATSIT_GUBBINS_HRL).
> 	-define(THINGY_WHATSIT_GUBBINS_HRL, true).
> 	...
> 	-endif.
> To my astonishment, some of the files that do this contain nothing else!
> The answer is simple:  they are produced by some kind of tool that
> emits -record declarations, and for these files there happened to be
> none.  Some use a _HRL suffix; some use a -MIB suffix.
> 
> This usage accounts for 165 (32%) of the -ifs.  Either of two changes
> would eliminate them entirely.
> 
> (a) -require(File_Name).
>      would resolve the File_Name just like -include(File_Name),
>      then check a list of included files.  If the file was in that
>      last, -require would do nothing, otherwise it would act just
>      like -include.  -include (and thus -require) would add the
>      resolved file name to the list.

I bet that for essentially all current uses of -include, it is the semantics
of -require that is wanted. Including a file twice is only useful if
you're relying on macros being defined differently between the two includes,
which is precisely the sort of abuse of the preprocessor that we would like
to get rid of.

So my suggestion would be to change -include to work as -require is described
above. Although this is technically an incompatible change, it's very unlikely
that any code that was relying on multiple includes of the same file would
still compile -- so it is not a silent incompatibility.

-- 
David Hopwood 



From ulf.wiger@REDACTED  Thu May 31 16:31:48 2007
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 31 May 2007 16:31:48 +0200
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070531141147.8C8825A1F7@mail.erlangsystems.com>
References:  <20070531141147.8C8825A1F7@mail.erlangsystems.com>
Message-ID: <6616D98C65DD514BA2E1DDC5F92231550201BDA1@esealmw115.eemea.ericsson.se>


The freshest and nicest info right now is:

"Betting on FP (and Winning?)" Erik Stenman, Kreditor
http://www.erlang.se/euc/06/proceedings/0900Stenman.pdf

There is also:

"Erlang in Banking and Financial Switching" (Danie Shutte)
http://www.erlang.se/euc/03/proceedings/1100Danie.ppt

BR,
Ulf W 

> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Qrilka
> Sent: den 31 maj 2007 16:12
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
> 
> 
> 
> uwiger wrote:
> 
> It _is_ used in telecommunication platforms, web apps, 
> massively concurrent systems to distributed high performance 
> platforms. It is also used in banking and invoicing systems.
> 
> (end of quote)
> 
> Ulf, is this a public info about Erlang in banking/invoicing 
> systems? Can we read something somewhere about it?
> 
> Regards,
> Kirill.
> _________________________________________________________
> Post sent from http://www.trapexit.org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From mats.cronqvist@REDACTED  Thu May 31 16:51:06 2007
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Thu, 31 May 2007 16:51:06 +0200
Subject: [erlang-questions] some language changes
In-Reply-To: 
References: <9b08084c0705210110o7c24d1f6v966b1c8a57a9b0d3@mail.gmail.com>	<465D8165.8060707@ericsson.com>
	
Message-ID: <465EE0DA.6070701@ericsson.com>

ok wrote:
> On 31 May 2007, at 1:51 am, Mats Cronqvist wrote:
> [1. simplify the language]
> [2. replace the preprocessor]

[discussion about ifdefs]

   i would be satisfied it the conditionals were left in, as long as the parser 
runs before the preprocessor.

> [3. Replace type guards by ::constraints on variables in patterns]
>   (a) This proposal makes the language more complicated.

   ???

>   (b) It makes some code more readable, but it makes other code
>       less readable.

   example?

>   (c) You STILL need type guards when there is a call to element,
>       hd, or tl in a guard, e.g.,
> 	f(N, T) when is_pid(element(N, T)) -> ...

   yes, that would have to go. i find it hard to believe there's a lot of code 
like that out there though.

>   (d) You STILL need type guards when a guard is disjunctive, e.g.,
> 	f(X) when is_record(X, update) ; is_record(X, delete) -> ...

   i guess you'd have to do this instead;

   f(X::record(update)) -> real_f(X);
   f(X::record(delete)) -> real_f(X).
   real_f(X)->...

   longer, but not (much) harder on the eyes. probably not a very common pattern 
either.

   mats


From thomasl_erlang@REDACTED  Thu May 31 17:23:35 2007
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Thu, 31 May 2007 08:23:35 -0700 (PDT)
Subject: [erlang-questions] : Subtle behaviour of Erlang scheduler
In-Reply-To: <20070531141147.8C8825A1F7@mail.erlangsystems.com>
Message-ID: <596989.69564.qm@web38807.mail.mud.yahoo.com>


--- Qrilka  wrote:

> Ulf, is this a public info about Erlang in
> banking/invoicing systems? Can we read something
> somewhere about it?

Banking: Daniel Schutte, Teba Bank, ppt at: 
http://www.erlang.se/euc/03/proceedings/1100Danie.ppt
That sounded quite successful last I heard of it.

Invoicing: this might be Kreditor? As I understand it,
they do short-term consumer credit and invoicing for
e-commerce sites. 
http://www.erlang.se/euc/06/proceedings/0900Stenman.pdf
Since there are scores of people on this list who
either implemented that system, or are working on it,
or own it, or run it, I'll leave it at that :-)

Best,
Thomas



      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 




From diginux@REDACTED  Thu May 31 19:37:14 2007
From: diginux@REDACTED (Jordan Wilberding)
Date: Thu, 31 May 2007 12:37:14 -0500
Subject: [erlang-questions] Why can't you have a variable before a string
	with pattern matching?
Message-ID: <465F07CA.2060806@diginux.net>

Hello,

I was just wondering why having

fcn("text" ++ String) -> ..

is legal, but doing

fcn(String ++ "text")

is not legal. Is this for performance reasons, or something else?

Thanks!
Jordan Wilberding


From raimo+erlang-questions@REDACTED  Thu May 31 20:21:24 2007
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Thu, 31 May 2007 20:21:24 +0200
Subject: [erlang-questions] Server maintainance 2007-05-31
In-Reply-To: <20070529185351.GA27815@erix.ericsson.se>
References: <20070529185351.GA27815@erix.ericsson.se>
Message-ID: <20070531182124.GA19260@erix.ericsson.se>

Well then... It is done!

Report any problems (not that I doubt you would hesitate).



On Tue, May 29, 2007 at 08:53:51PM +0200, Raimo Niskanen wrote:
> During Thursday evening (sometime during 18.00 .. 24.00 CET),
> 2007-05-31, we will upgrade our servers (handling www.erlang.org,
> rsync and our mailing lists). There will be some downtime,
> hopefully not much.
> 
> After the upgrade, we will have a subversion repository
> for EEPs (according to Per Gustafsson's proposition from
> Feb 2007 on erlang-questions@REDACTED All tools are
> not ready so we will get back with details...
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From javierparis@REDACTED  Thu May 31 21:18:37 2007
From: javierparis@REDACTED (Javier =?iso-8859-1?q?Par=EDs?=)
Date: Thu, 31 May 2007 21:18:37 +0200
Subject: [erlang-questions] Why can't you have a variable before a
	string with pattern matching?
In-Reply-To: <465F07CA.2060806@diginux.net>
References: <465F07CA.2060806@diginux.net>
Message-ID: <200705312118.37610.javierparis@udc.es>

El Thursday 31 May 2007 19:37:14 Jordan Wilberding escribi?:
> Hello,
>
> I was just wondering why having
>
> fcn("text" ++ String) -> ..
>
> is legal, but doing
>
> fcn(String ++ "text")
>
> is not legal. Is this for performance reasons, or something else?

This is an speculation, but it's probably because it's easy for the compiler 
to see that the first pattern is time-bounded, while the second is not 
(because it depends on the lenght of the string).

Regards.

-- 
Javier Par?s


From raimo+erlang-questions@REDACTED  Thu May 31 21:20:18 2007
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Thu, 31 May 2007 21:20:18 +0200
Subject: [erlang-questions] Server maintainance 2007-05-31
In-Reply-To: <20070529185351.GA27815@erix.ericsson.se>
References: <20070529185351.GA27815@erix.ericsson.se>
Message-ID: <20070531192018.GA19987@erix.ericsson.se>

There, it is done!...

I temporarily messed up the sendmail configuration,
so one mail from javierparis@REDACTED probably bounced off.

If you read this, please resend it.

On Tue, May 29, 2007 at 08:53:51PM +0200, Raimo Niskanen wrote:
> During Thursday evening (sometime during 18.00 .. 24.00 CET),
> 2007-05-31, we will upgrade our servers (handling www.erlang.org,
> rsync and our mailing lists). There will be some downtime,
> hopefully not much.
> 
> After the upgrade, we will have a subversion repository
> for EEPs (according to Per Gustafsson's proposition from
> Feb 2007 on erlang-questions@REDACTED All tools are
> not ready so we will get back with details...
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From darius@REDACTED  Thu May 31 22:22:10 2007
From: darius@REDACTED (Darius Bacon)
Date: Thu, 31 May 2007 13:22:10 -0700 (PDT)
Subject: [erlang-questions] Why can't you have a variable before
	a	string with pattern matching?
In-Reply-To: <200705312118.37610.javierparis@udc.es> (message from Javier
	=?iso-8859-1?q?Par=EDs?= on Thu, 31 May 2007 21:18:37 +0200)
References: <465F07CA.2060806@diginux.net>
	<200705312118.37610.javierparis@udc.es>
Message-ID: <200705312022.l4VKMAsl057063@shell.accesscom.com>

P.S. Another way to think of it is, "x"++Tail is syntactic sugar for
[$x|Tail]. But Head++"y" is not expressible with the [ | ] syntax;
we'd need to add ++ as new semantics.

Darius


From darius@REDACTED  Thu May 31 22:11:24 2007
From: darius@REDACTED (Darius Bacon)
Date: Thu, 31 May 2007 13:11:24 -0700 (PDT)
Subject: [erlang-questions] Why can't you have a variable before
	a	string with pattern matching?
In-Reply-To: <200705312118.37610.javierparis@udc.es> (message from Javier
	=?iso-8859-1?q?Par=EDs?= on Thu, 31 May 2007 21:18:37 +0200)
References: <465F07CA.2060806@diginux.net>
	<200705312118.37610.javierparis@udc.es>
Message-ID: <200705312011.l4VKBORq055425@shell.accesscom.com>

Javier =?iso-8859-1?q?Par=EDs?=  wrote:
> El Thursday 31 May 2007 19:37:14 Jordan Wilberding escribi?:
> > Hello,
> >
> > I was just wondering why having
> >
> > fcn("text" ++ String) -> ..
> >
> > is legal, but doing
> >
> > fcn(String ++ "text")
> >
> > is not legal. Is this for performance reasons, or something else?
> 
> This is an speculation, but it's probably because it's easy for the compiler 
> to see that the first pattern is time-bounded, while the second is not 
> (because it depends on the lenght of the string).

Matching already can take that much time, e.g. 
  fcn(A, A) -> ...

However, the second pattern above requires allocating new structures
on the heap, while the first one shares structure with the argument. I
don't know if that's the actual rationale. Anyway, trying to make ++
fully general in patterns would open up possibilities like
fcn(A ++ "x" ++ B).

Darius


From nem@REDACTED  Thu May 31 23:47:03 2007
From: nem@REDACTED (Geoff Cant)
Date: Fri, 01 Jun 2007 09:47:03 +1200
Subject: [erlang-questions] Parsing Objective C type encodings
In-Reply-To: <9b08084c0705310214p5dfcd476k20d592dbfc5b5f97@mail.gmail.com>
	(Joe Armstrong's message of "Thu\, 31 May 2007 11\:14\:51 +0200")
References: <9b08084c0705310214p5dfcd476k20d592dbfc5b5f97@mail.gmail.com>
Message-ID: 

"Joe Armstrong"  writes:

> Hi,
>
> It would be nice to build something like F-Script or RubyCocoa only in Erlang
>
> Is there any Erlang code for obtaining and parsing Objective C type encodings?
>
> Any progress since
>
> http://www.erlang.org/pipermail/erlang-questions/2006-August/021926.html
>
> Is it actually necessary to parse the objective C header files? -
> won't run-time introspection
> be sufficient.

I've written an objc runtime type signature parser in common lisp
(http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=cl-objc-cl-objc;a=headblob;f=/objc-types.lisp)
which I could port to yecc if you'd like.

It will give you enough information to safely call objc_msg_send (you
can tell which arguments should be objects, classes, c-strings, ...),
but not enough to catch errors that might occur if you pass the wrong
type of object (that information is only available in the header
files).

Has someone written erlang bindings for the objective-c runtime
library?
(http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/index.html#//apple_ref/doc/uid/TP40001418)
Bindings to these methods allow you to inspect all the loaded
classes/methods, create instances, new classes, new methods, call methods etc.

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/index.html
has some information on the type signatures the objc runtime uses.

Cheers,
-- 
Geoff



From jsnx@REDACTED  Thu May 31 20:28:04 2007
From: jsnx@REDACTED (Jason Dusek)
Date: Thu, 31 May 2007 11:28:04 -0700
Subject: [erlang-questions] tail recursion
In-Reply-To: <20070531115945.GB25668@works.com>
References: <42784f260705301726q7fdee581m38b5a5e2e7e12b3f@mail.gmail.com>
	<20070531115945.GB25668@works.com>
Message-ID: <42784f260705311128t5466a6b4pb010166281155a0b@mail.gmail.com>

On 5/31/07, Mike McNally  wrote:
> Why not rewrite it:
>
>   server({X, Y} = State) ->
>     server(receive
>       {update, NewState} -> NewState;
>       {x, Client} -> Client ! X, State;
>       {y, Client} -> Client ! Y, State
>     end).

Wow. You have revealed receive to me.

-- 
_jsn