From roger@REDACTED Sun Dec 1 11:41:49 2013 From: roger@REDACTED (Roger Lipscombe) Date: Sun, 1 Dec 2013 10:41:49 +0000 Subject: [erlang-questions] rebar, ct, coverage: "No modules to cover compile" Message-ID: I'm trying to get code coverage working for my ct test run. However, when I run "rebar ct -vvv skip_deps=true", I get the following in the output: WARNING: No modules to cover compile! My project is organised something like the following: ./rebar.config -- sub_dirs and lib_dirs ./deps ./apps/foo ./apps/foo/rebar.config -- deps, ct_dir, cover_enabled... ./apps/foo/cover.spec ./apps/foo/test -- eunit tests (for which coverage is working when run with rebar eunit) ./apps/foo/suites -- ct tests I've got a cover.spec file that looks like this: {incl_app, foo, details}. {incl_dirs_r, ["src", "suites"]}. {src_dirs, foo, ["src", "suites"]}. {export, "foo.coverdata"}. What am I doing wrong? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tyron.zerafa@REDACTED Sun Dec 1 17:19:25 2013 From: tyron.zerafa@REDACTED (Tyron Zerafa) Date: Sun, 1 Dec 2013 17:19:25 +0100 Subject: [erlang-questions] Takeover failure Message-ID: Hi all, I am trying to understand how to implement takeover in Erlang by following the example presented here. Basically, I am creating the application's supervisor as follows; start(normal, []) -> m8ball_sup:start_link(); start({takeover, _OtherNode}, []) -> m8ball_sup:start_link(). *Supervisor init code:* start_link() -> supervisor:start_link({global,?MODULE}, ?MODULE, []). *Supervisor child Specification:* { {one_for_one, 1, 10}, [ {m8ball, {m8ball_server, start_link, []}, permanent, 5000, worker, [m8ball_server] }] } *Child (m8ball_server) Initialization* start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). Consider the following scenario; an Erlang cluster is composed of two nodes A and B with application m8ball running on A. Failover works perfect, I'm managing to kill node A and see the application running on the next node, B. However, when I try to put back up node A (which have a higher priority then B) and init the app, I am getting the following error. I'm assuming that this occurs because node B already contains a supervisor globally registered with that name. *Log on Node A * {error,{{already_started,<2832.61.0>}, {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} =INFO REPORT==== 1-Dec-2013::16:17:32 === application: m8ball exited: {{already_started,<2832.61.0>}, {m8ball,start,[{takeover,'b@REDACTED'},[]]}} *Log on Node B* =INFO REPORT==== 1-Dec-2013::16:24:55 === application: m8ball exited: stopped type: temporary When I tried registering the supervisor locally, I got a similar exception failing to initializing the worker process. However, if I also register this as local, I would not be able to call it from any node using the app name (since it would not be globally registered). *Log on Node A **(Supervisor Registered Locally)* {error, {{shutdown, {failed_to_start_child,m8ball, {already_started,<2832.67.0>}}}, {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} Any pointers? -- Best Regards, Tyron Zerafa -------------- next part -------------- An HTML attachment was scrubbed... URL: From dszoboszlay@REDACTED Sun Dec 1 22:41:42 2013 From: dszoboszlay@REDACTED (=?utf-8?Q?Szoboszlay_D=C3=A1niel?=) Date: Sun, 01 Dec 2013 21:41:42 -0000 Subject: [erlang-questions] Takeover failure In-Reply-To: References: Message-ID: Hi, During a takeover your application is first started on the new node, then stopped on the old one. In between, it runs simultaneously on both of them. The idea is that you can take over the runtime state from the old instance this way. The downside is that you need to be more careful with global name registrations and use e.g. start phases. See this post for a much better, detailed explanation: Re: Distributed application takeover BR, Daniel PS: I would avoid using distributed applications in production. The dist_ac module in the kernel application that takes care of deciding where to run which distributed application is a terrible spaghetti of gen_server callbacks and ad-hoc message passing with tons of race conditions that can block your entire cluster from starting up any distributed apps. I run into about 3-4 different bugs of this kind before abandoning the idea of using this feature. On Sun, 01 Dec 2013 16:19:25 -0000, Tyron Zerafa wrote: > Hi all, > I am trying to understand how to implement takeover in Erlang by > following the example presented here. Basically, I am creating the > application's supervisor as follows; >start(normal, []) -> > m8ball_sup:start_link(); > start({takeover, _OtherNode}, []) -> > m8ball_sup:start_link(). > > > Supervisor init code: > start_link() -> > supervisor:start_link({global,?MODULE}, ?MODULE, []). > > Supervisor child Specification: > { > {one_for_one, 1, 10}, > [ > {m8ball, > {m8ball_server, start_link, []}, > permanent, > 5000, > worker, > [m8ball_server] > }] > } > > Child (m8ball_server) Initialization > start_link() -> > gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). > > > Consider the following scenario; an Erlang cluster is composed of two > nodes A and B with application m8ball running on A.Failover works > perfect, I'm managing to kill node A and see the application running on > the next node, B.However, when I try to put back up node A (which have a > higher priority then B) and init the app, I am getting the following > error. I'm assuming that this occurs because node B already contains a > >supervisor globally registered with that name. Log on Node A > {error,{{already_started,<2832.61.0>}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} > > =INFO REPORT==== 1-Dec-2013::16:17:32 === > application: m8ball > exited: {{already_started,<2832.61.0>}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}} > > > Log on Node B > =INFO REPORT==== 1-Dec-2013::16:24:55 === > application: m8ball > exited: stopped > type: temporary > > When I tried registering the supervisor locally, I got a similar > exception failing to initializing the worker process. However, if I also > register this as local, I would not be able to call it from any node > >using the app name (since it would not be globally registered). > > Log on Node A (Supervisor Registered Locally) > {error, > {{shutdown, > {failed_to_start_child,m8ball, > {already_started,<2832.67.0>}}}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} > >Any pointers? > > --Best Regards, > Tyron Zerafa -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Sun Dec 1 23:45:31 2013 From: tony@REDACTED (Tony Rogvall) Date: Sun, 1 Dec 2013 23:45:31 +0100 Subject: [erlang-questions] Takeover failure In-Reply-To: References: Message-ID: ... > > PS: I would avoid using distributed applications in production. The dist_ac module in the kernel application that takes care of deciding where to run which distributed application is a terrible spaghetti of gen_server callbacks and ad-hoc message passing with tons of race conditions that can block your entire cluster from starting up any distributed apps. I run into about 3-4 different bugs of this kind before abandoning the idea of using this feature. > Is this really true? tons of race conditions, meaning over 1000 ? 3-4 different bugs ? This raises some serious questions, like: Did you try to correct this and send a patch, or why not? If distributed application is not usable, do OTP team know about this? if so why is this feature still there and could fool people into try to use it? /Tony > On Sun, 01 Dec 2013 16:19:25 -0000, Tyron Zerafa wrote: > > Hi all, > > I am trying to understand how to implement takeover in Erlang by following the example presentedhere. Basically, I am creating the application's supervisor as follows; > > start(normal, []) -> > m8ball_sup:start_link(); > start({takeover, _OtherNode}, []) -> > m8ball_sup:start_link(). > > > Supervisor init code: > start_link() -> > supervisor:start_link({global,?MODULE}, ?MODULE, []). > > Supervisor child Specification: > { > {one_for_one, 1, 10}, > [ > {m8ball, > {m8ball_server, start_link, []}, > permanent, > 5000, > worker, > [m8ball_server] > }] > } > > Child (m8ball_server) Initialization > start_link() -> > gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). > > > Consider the following scenario; an Erlang cluster is composed of two nodes A and B with application m8ball running on A. > Failover works perfect, I'm managing to kill node A and see the application running on the next node, B. > However, when I try to put back up node A (which have a higher priority then B) and init the app, I am getting the following error. I'm assuming that this occurs because node B already contains a supervisor globally registered with that name. > Log on Node A > {error,{{already_started,<2832.61.0>}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} > > =INFO REPORT==== 1-Dec-2013::16:17:32 === > application: m8ball > exited: {{already_started,<2832.61.0>}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}} > > > Log on Node B > =INFO REPORT==== 1-Dec-2013::16:24:55 === > application: m8ball > exited: stopped > type: temporary > > When I tried registering the supervisor locally, I got a similar exception failing to initializing the worker process. However, if I also register this as local, I would not be able to call it from any node using the app name (since it would not be globally registered). > > Log on Node A (Supervisor Registered Locally) > {error, > {{shutdown, > {failed_to_start_child,m8ball, > {already_started,<2832.67.0>}}}, > {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} > > > Any pointers? > > -- > Best Regards, > Tyron Zerafa > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix" -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Dec 2 01:20:22 2013 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Dec 2013 13:20:22 +1300 Subject: [erlang-questions] Maths Problem -> 2452.45*100. = 245244.99999999997 In-Reply-To: References: <05DE93E5-2C54-454C-B915-55E543D770D5@cs.otago.ac.nz> Message-ID: <859ADDA2-3D2C-412A-B777-0F3010B4EC55@cs.otago.ac.nz> On 1/12/2013, at 5:51 AM, Hynek Vychodil wrote: > But dc computes precise > > $ dc <<<"20k2452.45 100*245245-p" > 0 > > $ dc <<<"20k28 85*312*5*0.85/p" > 4368000.00000000000000000000 That's hardly surprising. dc(1) implements *decimal* floating point, though not IEEE decimal floating point. From dszoboszlay@REDACTED Mon Dec 2 09:15:09 2013 From: dszoboszlay@REDACTED (=?utf-8?Q?Szoboszlay_D=C3=A1niel?=) Date: Mon, 02 Dec 2013 08:15:09 -0000 Subject: [erlang-questions] Takeover failure In-Reply-To: References: Message-ID: Hi, OK, "tons" might be a bit dramatic. There are 3 or 4 receive statements in the dist_ac gen_server code without a timeout. These are the potential hang up points. The root cause of all the problems is that dist_ac assumes all applications are started on all nodes in the same sequence. Now imagine a typical setup: the boot script starts app A then B, but unfortunately A has a restart timeout of 5000 and B has 3000. If the node running these apps crashes, the rest of the cluster will attempt to start B then A. But if the crashed node is restarted by heart within 3 seconds, it will rejoin the cluster before the takeover and attempt to start A then B. Result: neither of the apps fails over to anywhere and the restarted node won't even finish it's init sequence. Regarding a patch: I wrote a fix for the first couple of bugs I discovered. The problem is that I did it in my work time at a big company, where an entire security and legal department is thinking hard since then whether it is OK to release code to the public... To be honest, I don't push them hard right now either, because my fixes are not good for the above described scenario. That would need a complete rewrite of the dist_ac code to allow multiple apps to start concurrently. I have some ideas how to do it, but I won't have time to write a fix until January, I'm afraid (this time I'd do it from home). And I don't think this feature would be widely used btw. The dist_ac module hasn't been modified since the erlang/otp git repo exists. Furthermore I believe you are also safe to use it as long as you have only one distributed application. So I guess I'm the first one to run into this problems using 5-6 distributed apps and 5 nodes with equal priorities. BR, Daniel On Sun, 01 Dec 2013 22:45:31 -0000, Tony Rogvall wrote: > ... >> >> PS: I would avoid using distributed applications in production. The >> dist_ac module in the kernel application that takes care of deciding >> >>where to run which distributed application is a terrible spaghetti of >> gen_server callbacks and ad-hoc message passing with tons of race >> >>conditions that can block your entire cluster from starting up any >> distributed apps. I run into about 3-4 different bugs of this kind >> before >>abandoning the idea of using this feature. >> > > Is this really true? tons of race conditions, meaning over 1000 ? 3-4 > different bugs ? > This raises some serious questions, like: Did you try to correct this > and send a patch, or why not? > If distributed application is not usable, do OTP team know about this? > if so why is this feature still there and could fool people into try to > use it? > > /Tony > > >> On Sun, 01 Dec 2013 16:19:25 -0000, Tyron Zerafa >> wrote: >> >>> Hi all, >>> I am trying to understand how to implement takeover in Erlang by >>> following the example presentedhere. Basically, I am creating the >>> >>>application's supervisor as follows; >>>start(normal, []) -> >>> m8ball_sup:start_link(); >>> start({takeover, _OtherNode}, []) -> >>> m8ball_sup:start_link(). >>> >>> >>> Supervisor init code: >>> start_link() -> >>> supervisor:start_link({global,?MODULE}, ?MODULE, []). >>> >>> Supervisor child Specification: >>> { >>> {one_for_one, 1, 10}, >>> [ >>> {m8ball, >>> {m8ball_server, start_link, []}, >>> permanent, >>> 5000, >>> worker, >>> [m8ball_server] >>> }] >>> } >>> >>> Child (m8ball_server) Initialization >>> start_link() -> >>> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). >>> >>> >>> Consider the following scenario; an Erlang cluster is composed of two >>> nodes A and B with application m8ball running on A.Failover works >>> perfect, I'm managing to kill node A and see the application running >>> on the next node, B.However, when I try to put back up node A (which >>> have a higher priority then B) and init the app, I am getting the >>> following error. I'm >>>assuming that this occurs because node B >>> already contains a supervisor globally registered with that name. Log >>> on Node A{error,{{already_started,<2832.61.0>}, >>> {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} >>> >>> =INFO REPORT==== 1-Dec-2013::16:17:32 === >>> application: m8ball >>> exited: {{already_started,<2832.61.0>}, >>> {m8ball,start,[{takeover,'b@REDACTED'},[]]}} >>> >>> >>> Log on Node B >>> =INFO REPORT==== 1-Dec-2013::16:24:55 === >>> application: m8ball >>> exited: stopped >>> type: temporary >>> >>> When I tried registering the supervisor locally, I got a similar >>> exception failing to initializing the worker process. However, if I >>> also >>>register this as local, I would not be able to call it from >>> any node using the app name (since it would not be globally >>> registered). >>> >>> Log on Node A (Supervisor Registered Locally) >>> {error, >>> {{shutdown, >>> {failed_to_start_child,m8ball, >>> {already_started,<2832.67.0>}}}, >>> {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} >>> >>>Any pointers? >>> >>> --Best Regards, >>> Tyron Zerafa >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > >> "Installing applications can lead to corruption over time. Applications >> gradually write over each other's libraries, partial upgrades occur, >> user and system errors happen, and >minute changes may be unnoticeable >> and difficult to fix" -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Mon Dec 2 09:32:04 2013 From: tony@REDACTED (Tony Rogvall) Date: Mon, 2 Dec 2013 09:32:04 +0100 Subject: [erlang-questions] Takeover failure In-Reply-To: References: Message-ID: <4F5F0976-D5A2-4885-9119-E35E17FB2DF9@rogvall.se> This sounds fair enough :-) Regards /Tony On 2 dec 2013, at 09:15, Szoboszlay D?niel wrote: > Hi, > > OK, "tons" might be a bit dramatic. There are 3 or 4 receive statements in the dist_ac gen_server code without a timeout. These are the potential hang up points. The root cause of all the problems is that dist_ac assumes all applications are started on all nodes in the same sequence. Now imagine a typical setup: the boot script starts app A then B, but unfortunately A has a restart timeout of 5000 and B has 3000. If the node running these apps crashes, the rest of the cluster will attempt to start B then A. But if the crashed node is restarted by heart within 3 seconds, it will rejoin the cluster before the takeover and attempt to start A then B. Result: neither of the apps fails over to anywhere and the restarted node won't even finish it's init sequence. > > Regarding a patch: I wrote a fix for the first couple of bugs I discovered. The problem is that I did it in my work time at a big company, where an entire security and legal department is thinking hard since then whether it is OK to release code to the public... > To be honest, I don't push them hard right now either, because my fixes are not good for the above described scenario. That would need a complete rewrite of the dist_ac code to allow multiple apps to start concurrently. I have some ideas how to do it, but I won't have time to write a fix until January, I'm afraid (this time I'd do it from home). > And I don't think this feature would be widely used btw. The dist_ac module hasn't been modified since the erlang/otp git repo exists. Furthermore I believe you are also safe to use it as long as you have only one distributed application. So I guess I'm the first one to run into this problems using 5-6 distributed apps and 5 nodes with equal priorities. > > BR, > Daniel > > On Sun, 01 Dec 2013 22:45:31 -0000, Tony Rogvall wrote: > > ... >> >> PS: I would avoid using distributed applications in production. The dist_ac module in the kernel application that takes care of deciding where to run which distributed application is a terrible spaghetti of gen_server callbacks and ad-hoc message passing with tons of race conditions that can block your entire cluster from starting up any distributed apps. I run into about 3-4 different bugs of this kind before abandoning the idea of using this feature. >> > > Is this really true? tons of race conditions, meaning over 1000 ? 3-4 different bugs ? > This raises some serious questions, like: Did you try to correct this and send a patch, or why not? > If distributed application is not usable, do OTP team know about this? > if so why is this feature still there and could fool people into try to use it? > > /Tony > > >> On Sun, 01 Dec 2013 16:19:25 -0000, Tyron Zerafa wrote: >> >> Hi all, >> >> I am trying to understand how to implement takeover in Erlang by following the example presentedhere. Basically, I am creating the application's supervisor as follows; >> >> start(normal, []) -> >> m8ball_sup:start_link(); >> start({takeover, _OtherNode}, []) -> >> m8ball_sup:start_link(). >> >> >> Supervisor init code: >> start_link() -> >> supervisor:start_link({global,?MODULE}, ?MODULE, []). >> >> Supervisor child Specification: >> { >> {one_for_one, 1, 10}, >> [ >> {m8ball, >> {m8ball_server, start_link, []}, >> permanent, >> 5000, >> worker, >> [m8ball_server] >> }] >> } >> >> Child (m8ball_server) Initialization >> start_link() -> >> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). >> >> >> Consider the following scenario; an Erlang cluster is composed of two nodes A and B with application m8ball running on A. >> Failover works perfect, I'm managing to kill node A and see the application running on the next node, B. >> However, when I try to put back up node A (which have a higher priority then B) and init the app, I am getting the following error. I'm assuming that this occurs because node B already contains a supervisor globally registered with that name. >> Log on Node A >> {error,{{already_started,<2832.61.0>}, >> {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} >> >> =INFO REPORT==== 1-Dec-2013::16:17:32 === >> application: m8ball >> exited: {{already_started,<2832.61.0>}, >> {m8ball,start,[{takeover,'b@REDACTED'},[]]}} >> >> >> Log on Node B >> =INFO REPORT==== 1-Dec-2013::16:24:55 === >> application: m8ball >> exited: stopped >> type: temporary >> >> When I tried registering the supervisor locally, I got a similar exception failing to initializing the worker process. However, if I also register this as local, I would not be able to call it from any node using the app name (since it would not be globally registered). >> >> Log on Node A (Supervisor Registered Locally) >> {error, >> {{shutdown, >> {failed_to_start_child,m8ball, >> {already_started,<2832.67.0>}}}, >> {m8ball,start,[{takeover,'b@REDACTED'},[]]}}} >> >> >> Any pointers? >> >> -- >> Best Regards, >> Tyron Zerafa >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix" > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix" -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Mon Dec 2 13:58:10 2013 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 2 Dec 2013 13:58:10 +0100 Subject: [erlang-questions] Maths Problem -> 2452.45*100. = 245244.99999999997 In-Reply-To: <859ADDA2-3D2C-412A-B777-0F3010B4EC55@cs.otago.ac.nz> References: <05DE93E5-2C54-454C-B915-55E543D770D5@cs.otago.ac.nz> <859ADDA2-3D2C-412A-B777-0F3010B4EC55@cs.otago.ac.nz> Message-ID: Yep. Sorry, I should insert more clue that it was irony. H. On Mon, Dec 2, 2013 at 1:20 AM, Richard A. O'Keefe wrote: > > On 1/12/2013, at 5:51 AM, Hynek Vychodil wrote: > > But dc computes precise > > > > $ dc <<<"20k2452.45 100*245245-p" > > 0 > > > > $ dc <<<"20k28 85*312*5*0.85/p" > > 4368000.00000000000000000000 > > That's hardly surprising. > dc(1) implements *decimal* floating point, > though not IEEE decimal floating point. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.j.thompson@REDACTED Mon Dec 2 16:25:50 2013 From: s.j.thompson@REDACTED (Simon Thompson) Date: Mon, 2 Dec 2013 15:25:50 +0000 Subject: [erlang-questions] Call for Papers: 15th Symposium on Trends in Functional Programming, May 2014, Utrecht Message-ID: <79A3CECD-0C9C-4006-A831-8DE42D96DBD6@kent.ac.uk> ----------------------------- C A L L F O R P A P E R S ----------------------------- ======== TFP 2014 =========== 15th Symposium on Trends in Functional Programming May 26-28, 2014 Utrecht University Soesterberg, The Netherlands http://www.cs.uu.nl/wiki/TFP2014/WebHome The symposium on Trends in Functional Programming (TFP) is an international forum for researchers with interests in all aspects of functional programming, taking a broad view of current and future trends in the area. It aspires to be a lively environment for presenting the latest research results, and other contributions (see below), described in draft papers submitted prior to the symposium. A formal post-symposium refereeing process then selects a subset of the articles presented at the symposium and submitted for formal publication. Selected papers will be published as a Springer Lecture Notes in Computer Science (LNCS) volume. TFP 2014 will be the main event of a pair of functional programming events. The other is the International Workshop on Trends in Functional Programming in Education (TFPIE). TFPIE will take place on May 25th. The TFP symposium is the heir of the successful series of Scottish Functional Programming Workshops. Previous TFP symposia were held in Edinburgh (Scotland) in 2003, in Munich (Germany) in 2004, in Tallinn (Estonia) in 2005, in Nottingham (UK) in 2006, in New York (USA) in 2007, in Nijmegen (The Netherlands) in 2008, in Komarno (Slovakia) in 2009, in Oklahoma (USA) in 2010, in Madrid (Spain) in 2011, St. Andrews (UK) in 2012 and Provo (Utah, USA) in 2013. For further general information about TFP please see the TFP homepage. INVITED SPEAKERS TFP is pleased to announce talks by the following two invited speakers: John Hughes of Chalmers, Goteborg, Sweden, is well-known as author of Why Functional Programming Matters, and as one of the designers of QuickCheck (together with Koen Claessen); the paper on QuickCheck won the ICFP Most Influential Paper Award in 2010. Currently he divides his time between his professorship and Quviq, a company that performs property-based testing of software with a tool implemented in Erlang. Dr. Geoffrey Mainland received his PhD from Harvard University where he was advised by Greg Morrisett and Matt Welsh. After a two year postdoc with the Programming Principles and Tools group at Microsoft Research Cambridge, he is now an assistant professor at Drexel University. His research focuses on high-level programming language and runtime support for non-general purpose computation. SCOPE The symposium recognizes that new trends may arise through various routes. As part of the Symposium's focus on trends we therefore identify the following five article categories. High-quality articles are solicited in any of these categories: Research Articles: leading-edge, previously unpublished research work Position Articles: on what new trends should or should not be Project Articles: descriptions of recently started new projects Evaluation Articles: what lessons can be drawn from a finished project Overview Articles: summarizing work with respect to a trendy subject Articles must be original and not submitted for simultaneous publication to any other forum. They may consider any aspect of functional programming: theoretical, implementation-oriented, or more experience-oriented. Applications of functional programming techniques to other languages are also within the scope of the symposium. Topics suitable for the symposium include: Functional programming and multicore/manycore computing Functional programming in the cloud High performance functional computing Extra-functional (behavioural) properties of functional programs Dependently typed functional programming Validation and verification of functional programs Using functional techniques to reason about imperative/object-oriented programs Debugging for functional languages Functional programming in different application areas: security, mobility, telecommunications applications, embedded systems, global computing, grids, etc. Interoperability with imperative programming languages Novel memory management techniques Program analysis and transformation techniques Empirical performance studies Abstract/virtual machines and compilers for functional languages (Embedded) domain specific languages New implementation strategies Any new emerging trend in the functional programming area If you are in doubt on whether your article is within the scope of TFP, please contact the TFP 2014 program chair, Jurriaan Hage at J.Hage@REDACTED BEST PAPER AWARDS To reward excellent contributions, TFP awards a prize for the best paper accepted for the formal proceedings. TFP traditionally pays special attention to research students, acknowledging that students are almost by definition part of new subject trends. A student paper is one for which the authors state that the paper is mainly the work of students, the students are listed as first authors, and a student would present the paper. A prize for the best student paper is awarded each year. In both cases, it is the PC of TFP that awards the prize. In case the best paper happens to be a student paper, that paper will then receive both prizes. SPONSORS TFP is financially supported by NWO (Netherlands Organisation for Scientific Research), Well-Typed and Erlang Solutions. PAPER SUBMISSIONS Acceptance of articles for presentation at the symposium is based on a lightweight peer review process of extended abstracts (4 to 10 pages in length) or full papers (16 pages). The submission must clearly indicate which category it belongs to: research, position, project, evaluation, or overview paper. It should also indicate whether the main author or authors are research students. In the case of a full student paper, the paper will receive additional feedback by one of the PC members shortly after the symposium has taken place. We shall use EasyChair for the refereeing process. IMPORTANT DATES Submission of draft papers: March 17, 2014 Notification: March 24, 2014 Registration: April 7, 2014 TFP Symposium: May 26-28, 2014 Student papers feedback: June 9th, 2014 Submission for formal review: July 1st, 2014 Notification of acceptance: September 8th, 2014 Camera ready paper: October 8th, 2014 PROGRAM COMMITTEE Peter Achten Radboud University Nijmegen Emil Axelsson Chalmers Lucilia Camarao de Figueiredo Universidade Federal de Ouro Preto Laura Castro University of A Coruna Frank Huch Christian-Albrechts-University of Kiel Matthew Fluet Rochester Institute of Technology Jurriaan Hage (chair) University of Utrecht Yukiyoshi Kameyama University of Tsukuba Andrew Kennedy Microsoft Research Tamas Kozsik Eotvos Lorand University Ben Lippmeier University of New South Wales Luc Maranget INRIA Jay McCarthy Brigham Young University Marco T. Morazan Seton Hall University Ricardo Pena Universidad Complutense de Madrid Alexey Rodriguez madvertise Sven-Bodo Scholz Heriot-Watt University Manuel Serrano INRIA Sophia Antipolis Simon Thompson University of Kent Tarmo Uustalu Inst of Cybernetics David Van Horn Maryland University Janis Voigtlaender University of Bonn Simon Thompson | Professor of Logic and Computation School of Computing | University of Kent | Canterbury, CT2 7NF, UK s.j.thompson@REDACTED | M +44 7986 085754 | W www.cs.kent.ac.uk/~sjt From bombadil@REDACTED Tue Dec 3 01:28:49 2013 From: bombadil@REDACTED (Manuel A. Rubio "Bombadil") Date: Tue, 03 Dec 2013 01:28:49 +0100 Subject: [erlang-questions] myproto development status (erlang as an SQL server) In-Reply-To: References: Message-ID: Hi Max, El 2013-11-29 10:59, Max Lapshin escribi?: > Myproto library implements this server protocol and also makes some sql > parsing. Of course, I understand that writing full SQL parser will take > ages, so let's say that it focuses on most trivial requests. > > I had to make some fixes to myproto (including trivial fixes like > buffering tcp flow, because there are no messages in tcp =), so right > now Ruby on Rails 3.2 can connect to erlyvideo and request stream list, > opened sessions and their history, etc. > > My fork is https://github.com/flussonic/myproto [3] but I hope that > Manuel will accept it. Accepted! :-) Thanks for your contributions, Max. Regards. Manuel Rubio. From thomasl_erlang@REDACTED Tue Dec 3 13:14:51 2013 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 3 Dec 2013 04:14:51 -0800 (PST) Subject: [erlang-questions] Getting code from closures Message-ID: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> Hi guys, Before I start hacking on something, I thought I'd ask whether there already is a standard way to get the original code from a compiled fun/closure. (I know you can get it for interpreted funs by using fun_info.) E.g., for code like this: -module(a).? -compile(export_all). adder(N) -> fun(X) X+N end. I'd like to be able to write something like this: > c(a), F = a:adder(3), magic:get_code(F). {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, 0,'X'},{var,0,'N'}}]}], [{'N', 3}]} ?%% AST of fun F with free var env Or the equivalent. Best, Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Tue Dec 3 13:30:51 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Tue, 3 Dec 2013 13:30:51 +0100 Subject: [erlang-questions] Getting code from closures In-Reply-To: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> Message-ID: No there isn?t. Why do you need that, out of curiosity? -- Anthony Ramine Le 3 d?c. 2013 ? 13:14, Thomas Lindgren a ?crit : > Hi guys, > > Before I start hacking on something, I thought I'd ask whether there already is a standard way to get the original code from a compiled fun/closure. (I know you can get it for interpreted funs by using fun_info.) > > E.g., for code like this: > > -module(a). > -compile(export_all). > adder(N) -> fun(X) X+N end. > > I'd like to be able to write something like this: > > > c(a), F = a:adder(3), magic:get_code(F). > {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, 0,'X'},{var,0,'N'}}]}], [{'N', 3}]} %% AST of fun F with free var env > > Or the equivalent. > > Best, > Thomas > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From carlsson.richard@REDACTED Tue Dec 3 14:02:35 2013 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Tue, 03 Dec 2013 14:02:35 +0100 Subject: [erlang-questions] Getting code from closures In-Reply-To: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> Message-ID: <529DD66B.6070806@gmail.com> On 2013-12-03 13:14 , Thomas Lindgren wrote: > Hi guys, > > Before I start hacking on something, I thought I'd ask whether there > already is a standard way to get the original code from a compiled > fun/closure. (I know you can get it for interpreted funs by using fun_info.) > > E.g., for code like this: > > -module(a). > -compile(export_all). > adder(N) -> fun(X) X+N end. > > I'd like to be able to write something like this: > > > c(a), F = a:adder(3), magic:get_code(F). > {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, > 0,'X'},{var,0,'N'}}]}], [{'N', 3}]} %% AST of fun F with free var env > > Or the equivalent. Use fun_info to get the name/arity of the generated function and dig it out from the debug_info AST (or for bonus points, reverse-compile the beam code)? Keep in mind that if the code in the fun contains a local call to a function in the same module, you'll need to include the code for all reachable functions as well. Hence, the whole AST or the .beam file as a binary might be more suitable for whatever it is you're doing. /Richard From mrtndimitrov@REDACTED Tue Dec 3 14:05:10 2013 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Tue, 03 Dec 2013 15:05:10 +0200 Subject: [erlang-questions] suspending/resuming a process Message-ID: <529DD706.8010008@gmail.com> Hello, I am trying to figure out how to use sys:suspend/1,2 and sys:resume/1,2 but without any luck. I tried: 1> P = spawn(fun() -> lists:foreach(fun(_) -> io:format("cool~n", []), timer:sleep(1000) end, lists:seq(1, 100)) end). 2> sys:suspend(P). but the process clearly continued to run because was printing "cool" every second. After 5 seconds (which is the default timeout for sys:suspend/1,2, I guess), I got the following error: ** exception exit: {timeout,{sys,suspend,[<0.176.0>]}} in function sys:send_system_msg/2 (sys.erl, line 242) Thank you very much, Martin From bengt.kleberg@REDACTED Tue Dec 3 14:12:31 2013 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 3 Dec 2013 14:12:31 +0100 Subject: [erlang-questions] suspending/resuming a process In-Reply-To: <529DD706.8010008@gmail.com> References: <529DD706.8010008@gmail.com> Message-ID: <1386076351.4876.19.camel@sekic1152.release> These are opinions, not facts. When reading the sys manual page it mentions that the process "should implement the standard behaviours" or "still understand system messages". Your process does not seem to do that. bengt On Tue, 2013-12-03 at 15:05 +0200, Martin Dimitrov wrote: > Hello, > > I am trying to figure out how to use sys:suspend/1,2 and sys:resume/1,2 > but without any luck. > > I tried: > > 1> P = spawn(fun() -> lists:foreach(fun(_) -> io:format("cool~n", []), > timer:sleep(1000) end, lists:seq(1, 100)) end). > 2> sys:suspend(P). > > but the process clearly continued to run because was printing "cool" > every second. > > After 5 seconds (which is the default timeout for sys:suspend/1,2, I > guess), I got the following error: > > ** exception exit: {timeout,{sys,suspend,[<0.176.0>]}} > in function sys:send_system_msg/2 (sys.erl, line 242) > > Thank you very much, > > Martin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From dm.klionsky@REDACTED Tue Dec 3 14:13:38 2013 From: dm.klionsky@REDACTED (Dmitry Klionsky) Date: Tue, 03 Dec 2013 16:13:38 +0300 Subject: [erlang-questions] suspending/resuming a process In-Reply-To: <529DD706.8010008@gmail.com> References: <529DD706.8010008@gmail.com> Message-ID: <529DD902.3070400@gmail.com> The sys module doesn't work with any processes, but only with those implemented using behaviours or the special processes implemented using proc_lib. http://www.erlang.org/doc/design_principles/spec_proc.html On 12/03/2013 04:05 PM, Martin Dimitrov wrote: > Hello, > > I am trying to figure out how to use sys:suspend/1,2 and sys:resume/1,2 > but without any luck. > > I tried: > > 1> P = spawn(fun() -> lists:foreach(fun(_) -> io:format("cool~n", []), > timer:sleep(1000) end, lists:seq(1, 100)) end). > 2> sys:suspend(P). > > but the process clearly continued to run because was printing "cool" > every second. > > After 5 seconds (which is the default timeout for sys:suspend/1,2, I > guess), I got the following error: > > ** exception exit: {timeout,{sys,suspend,[<0.176.0>]}} > in function sys:send_system_msg/2 (sys.erl, line 242) > > Thank you very much, > > Martin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Best regards, Dmitry Klionsky From mrtndimitrov@REDACTED Tue Dec 3 14:53:38 2013 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Tue, 03 Dec 2013 15:53:38 +0200 Subject: [erlang-questions] suspending/resuming a process In-Reply-To: <529DD902.3070400@gmail.com> References: <529DD706.8010008@gmail.com> <529DD902.3070400@gmail.com> Message-ID: <529DE262.1080803@gmail.com> Thanks. I can't detach from my C background. On 12/3/2013 3:13 PM, Dmitry Klionsky wrote: > The sys module doesn't work with any processes, but only with those > implemented using behaviours or the special processes implemented using > proc_lib. > http://www.erlang.org/doc/design_principles/spec_proc.html > > > On 12/03/2013 04:05 PM, Martin Dimitrov wrote: >> Hello, >> >> I am trying to figure out how to use sys:suspend/1,2 and sys:resume/1,2 >> but without any luck. >> >> I tried: >> >> 1> P = spawn(fun() -> lists:foreach(fun(_) -> io:format("cool~n", []), >> timer:sleep(1000) end, lists:seq(1, 100)) end). >> 2> sys:suspend(P). >> >> but the process clearly continued to run because was printing "cool" >> every second. >> >> After 5 seconds (which is the default timeout for sys:suspend/1,2, I >> guess), I got the following error: >> >> ** exception exit: {timeout,{sys,suspend,[<0.176.0>]}} >> in function sys:send_system_msg/2 (sys.erl, line 242) >> >> Thank you very much, >> >> Martin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From egil@REDACTED Tue Dec 3 15:36:25 2013 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Tue, 3 Dec 2013 15:36:25 +0100 Subject: [erlang-questions] suspending/resuming a process In-Reply-To: <529DE262.1080803@gmail.com> References: <529DD706.8010008@gmail.com> <529DD902.3070400@gmail.com> <529DE262.1080803@gmail.com> Message-ID: <529DEC69.2060803@erlang.org> For debugging you can use: erlang:suspend_process/1,2 and erlang:resume_process/1 which does what you initially intended .. i believe. // Bj?rn-Egil On 2013-12-03 14:53, Martin Dimitrov wrote: > Thanks. I can't detach from my C background. > > > On 12/3/2013 3:13 PM, Dmitry Klionsky wrote: >> The sys module doesn't work with any processes, but only with those >> implemented using behaviours or the special processes implemented using >> proc_lib. >> http://www.erlang.org/doc/design_principles/spec_proc.html >> >> >> On 12/03/2013 04:05 PM, Martin Dimitrov wrote: >>> Hello, >>> >>> I am trying to figure out how to use sys:suspend/1,2 and sys:resume/1,2 >>> but without any luck. >>> >>> I tried: >>> >>> 1> P = spawn(fun() -> lists:foreach(fun(_) -> io:format("cool~n", []), >>> timer:sleep(1000) end, lists:seq(1, 100)) end). >>> 2> sys:suspend(P). >>> >>> but the process clearly continued to run because was printing "cool" >>> every second. >>> >>> After 5 seconds (which is the default timeout for sys:suspend/1,2, I >>> guess), I got the following error: >>> >>> ** exception exit: {timeout,{sys,suspend,[<0.176.0>]}} >>> in function sys:send_system_msg/2 (sys.erl, line 242) >>> >>> Thank you very much, >>> >>> Martin >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From hope@REDACTED Tue Dec 3 16:13:42 2013 From: hope@REDACTED (hope@REDACTED) Date: Tue, 3 Dec 2013 23:13:42 +0800 Subject: [erlang-questions] strange result of lists:map(fun(X)-> 20*X end, [2, 4, 6, 8]). Message-ID: <3372C4A8537A414DB30F979104CDF15E@vista> Hi, I am a beginner, and I got some strange result like this : 1> L=[2,4,6,8]. [2,4,6,8] 2> lists:map(fun(X)-> 20*X end,L). "(Px?" 3> lists:map(fun(X)-> 21*X end,L). "*T~?" 4> lists:map(fun(X)-> 27*X end,L). "6l?O" 5> lists:map(fun(X)-> 28*X end,L). "8p?a" 6> lists:map(fun(X)-> 29*X end,L). ":tRe" 7> lists:map(fun(X)-> 30*X end,L). " lists:map(fun(X)-> 31*X end,L). ">|oo" 9> lists:map(fun(X)-> 32*X end,L). [64,128,192,256] 10> lists:map(fun(X)-> 22*X end,L). [44,88,132,176] 11> lists:map(fun(X)-> 23*X end,L). [46,92,138,184] 12> lists:map(fun(X)-> 24*X end,L). [48,96,144,192] 13> lists:map(fun(X)-> 25*X end,L). [50,100,150,200] 14> lists:map(fun(X)-> 26*X end,L). [52,104,156,208] 15> lists:map(fun(X)-> 27*X end,L). "6l?O" ------------------- Erlang R16B02 (erts-5.10.3) [smp:2:2] [async-threads:10] Eshell V5.10.3 (abort with ^G) ------------------- Windows Vista ------------------- Can someone help me ? Thanks a lot ! best regards. hope@REDACTED 2013.12.03 -------------- next part -------------- An HTML attachment was scrubbed... URL: From elbrujohalcon@REDACTED Tue Dec 3 16:24:41 2013 From: elbrujohalcon@REDACTED (Work) Date: Tue, 3 Dec 2013 12:24:41 -0300 Subject: [erlang-questions] strange result of lists:map(fun(X)-> 20*X end, [2, 4, 6, 8]). In-Reply-To: <3372C4A8537A414DB30F979104CDF15E@vista> References: <3372C4A8537A414DB30F979104CDF15E@vista> Message-ID: <782F8122-9EF4-4A13-889D-B0996CBFFF4A@inaka.net> Hi! Since strings in Erlang are just lists of integers, and the results of some of your tests are proper lists of strings, they?re *displayed* as strings. In other words "(Px?" = [40, 80, 120, 160] Hope that helps :) For reference, check this: http://learnyousomeerlang.com/starting-out-for-real#lists On Dec 3, 2013, at 12:13, wrote: > Hi, > > I am a beginner, and I got some strange result like this : > > 1> L=[2,4,6,8]. > [2,4,6,8] > 2> lists:map(fun(X)-> 20*X end,L). > "(Px?" > 3> lists:map(fun(X)-> 21*X end,L). > "*T~?" > 4> lists:map(fun(X)-> 27*X end,L). > "6l?O" > 5> lists:map(fun(X)-> 28*X end,L). > "8p?a" > 6> lists:map(fun(X)-> 29*X end,L). > ":tRe" > 7> lists:map(fun(X)-> 30*X end,L). > " 8> lists:map(fun(X)-> 31*X end,L). > ">|oo" > 9> lists:map(fun(X)-> 32*X end,L). > [64,128,192,256] > 10> lists:map(fun(X)-> 22*X end,L). > [44,88,132,176] > 11> lists:map(fun(X)-> 23*X end,L). > [46,92,138,184] > 12> lists:map(fun(X)-> 24*X end,L). > [48,96,144,192] > 13> lists:map(fun(X)-> 25*X end,L). > [50,100,150,200] > 14> lists:map(fun(X)-> 26*X end,L). > [52,104,156,208] > 15> lists:map(fun(X)-> 27*X end,L). > "6l?O" > > ------------------- > Erlang R16B02 (erts-5.10.3) [smp:2:2] [async-threads:10] > Eshell V5.10.3 (abort with ^G) > ------------------- > Windows Vista > ------------------- > > Can someone help me ? > > Thanks a lot ! > > best regards. > > > hope@REDACTED 2013.12.03 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Tue Dec 3 16:28:38 2013 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 3 Dec 2013 16:28:38 +0100 Subject: [erlang-questions] Getting code from closures In-Reply-To: <529DD66B.6070806@gmail.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> <529DD66B.6070806@gmail.com> Message-ID: <69701B14-F104-4640-AC9F-220154D54B9C@feuerlabs.com> The ct_expand transform has a variation of this, where it also ?funnifies? local functions, in order to be able to evaluate them at compile-time. The locks_watcher also has a simple inlining transform that transforms a ?pseudo-function? into an abstract expression list that can be evaluated without the need of compiled code. It chases down calls to local functions and transforms those functions into funs inside the expression list. https://github.com/uwiger/locks/blob/master/src/locks_watcher.erl#L109 BR, Ulf W On 3 Dec 2013, at 14:02, Richard Carlsson wrote: > On 2013-12-03 13:14 , Thomas Lindgren wrote: >> Hi guys, >> >> Before I start hacking on something, I thought I'd ask whether there >> already is a standard way to get the original code from a compiled >> fun/closure. (I know you can get it for interpreted funs by using fun_info.) >> >> E.g., for code like this: >> >> -module(a). >> -compile(export_all). >> adder(N) -> fun(X) X+N end. >> >> I'd like to be able to write something like this: >> >> > c(a), F = a:adder(3), magic:get_code(F). >> {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, >> 0,'X'},{var,0,'N'}}]}], [{'N', 3}]} %% AST of fun F with free var env >> >> Or the equivalent. > > Use fun_info to get the name/arity of the generated function and dig it out from the debug_info AST (or for bonus points, reverse-compile the beam code)? > > Keep in mind that if the code in the fun contains a local call to a function in the same module, you'll need to include the code for all reachable functions as well. Hence, the whole AST or the .beam file as a binary might be more suitable for whatever it is you're doing. > > /Richard > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com From robert.virding@REDACTED Tue Dec 3 16:53:42 2013 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 3 Dec 2013 16:53:42 +0100 (CET) Subject: [erlang-questions] Binary:split and re:split woes In-Reply-To: <1089784920.205166.1386085460859.JavaMail.zimbra@erlang-solutions.com> Message-ID: <1981002184.205450.1386086022848.JavaMail.zimbra@erlang-solutions.com> These two functions allow you give a pattern to split binaries (and lists in re) into a list of sub binaries. If the split pattern occurs at the beginning or end of the binary then you get empty parts at the beginning or end. So: binary:split(<<" abc def ghi ">>, <<" ">>, [global]) ==> [<<>>,<<"abc">>,<<"def">>,<<"ghi">>,<<>>] This is fine and logical. Often you don't want these empty parts so there is a 'trim' options which removes them. But it only trims at the end and not at the beginning. So: binary:split(<<" abc def ghi ">>, <<" ">>, [global,trim]) ==> [<<>>,<<"abc">>,<<"def">>,<<"ghi">>] This is stupid! Saying it it done like this Perl is hardly a good excuse for bad behaviour. Sigh, Robert From elbrujohalcon@REDACTED Tue Dec 3 18:46:31 2013 From: elbrujohalcon@REDACTED (Work) Date: Tue, 3 Dec 2013 14:46:31 -0300 Subject: [erlang-questions] strange result of lists:map(fun(X)-> 20*X end, [2, 4, 6, 8]). In-Reply-To: References: <3372C4A8537A414DB30F979104CDF15E@vista> <782F8122-9EF4-4A13-889D-B0996CBFFF4A@inaka.net> Message-ID: <73A78F3D-055B-4992-8621-C46664A0765F@inaka.net> Yeah, this should work: io:format("~w~n", [lists:map(fun(X)-> 20*X end,L)]). On Dec 3, 2013, at 14:41, Patrick Schless wrote: > In cases like this, is there a way to explicitly show the result as numbers (as Hope expected)? > > > On Tue, Dec 3, 2013 at 9:24 AM, Work wrote: > Hi! > > Since strings in Erlang are just lists of integers, and the results of some of your tests are proper lists of strings, they?re *displayed* as strings. > In other words "(Px?" = [40, 80, 120, 160] > Hope that helps :) > For reference, check this: http://learnyousomeerlang.com/starting-out-for-real#lists > > On Dec 3, 2013, at 12:13, wrote: > >> Hi, >> >> I am a beginner, and I got some strange result like this : >> >> 1> L=[2,4,6,8]. >> [2,4,6,8] >> 2> lists:map(fun(X)-> 20*X end,L). >> "(Px?" >> 3> lists:map(fun(X)-> 21*X end,L). >> "*T~?" >> 4> lists:map(fun(X)-> 27*X end,L). >> "6l?O" >> 5> lists:map(fun(X)-> 28*X end,L). >> "8p?a" >> 6> lists:map(fun(X)-> 29*X end,L). >> ":tRe" >> 7> lists:map(fun(X)-> 30*X end,L). >> "> 8> lists:map(fun(X)-> 31*X end,L). >> ">|oo" >> 9> lists:map(fun(X)-> 32*X end,L). >> [64,128,192,256] >> 10> lists:map(fun(X)-> 22*X end,L). >> [44,88,132,176] >> 11> lists:map(fun(X)-> 23*X end,L). >> [46,92,138,184] >> 12> lists:map(fun(X)-> 24*X end,L). >> [48,96,144,192] >> 13> lists:map(fun(X)-> 25*X end,L). >> [50,100,150,200] >> 14> lists:map(fun(X)-> 26*X end,L). >> [52,104,156,208] >> 15> lists:map(fun(X)-> 27*X end,L). >> "6l?O" >> >> ------------------- >> Erlang R16B02 (erts-5.10.3) [smp:2:2] [async-threads:10] >> Eshell V5.10.3 (abort with ^G) >> ------------------- >> Windows Vista >> ------------------- >> >> Can someone help me ? >> >> Thanks a lot ! >> >> best regards. >> >> >> hope@REDACTED 2013.12.03 >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Tue Dec 3 20:03:36 2013 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 3 Dec 2013 11:03:36 -0800 (PST) Subject: [erlang-questions] Getting code from closures In-Reply-To: References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> Message-ID: <1386097416.74038.YahooMailNeo@web140105.mail.bf1.yahoo.com> I want to look at the closure code to investigate some stupid compiler tricks. Best, Thomas On Tuesday, December 3, 2013 1:30 PM, Anthony Ramine wrote: No there isn?t. > >Why do you need that, out of curiosity? > >-- >Anthony Ramine > > >Le 3 d?c. 2013 ? 13:14, Thomas Lindgren a ?crit : > >> Hi guys, >> >> Before I start hacking on something, I thought I'd ask whether there already is a standard way to get the original code from a compiled fun/closure. (I know you can get it for interpreted funs by using fun_info.) >> >> E.g., for code like this: >> >> -module(a). >> -compile(export_all). >> adder(N) -> fun(X) X+N end. >> >> I'd like to be able to write something like this: >> >> > c(a), F = a:adder(3), magic:get_code(F). >> {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, 0,'X'},{var,0,'N'}}]}], [{'N', 3}]}? %% AST of fun F with free var env >> >> Or the equivalent. >> >> Best, >> Thomas >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Tue Dec 3 20:06:29 2013 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 3 Dec 2013 11:06:29 -0800 (PST) Subject: [erlang-questions] Getting code from closures In-Reply-To: <529DD66B.6070806@gmail.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> <529DD66B.6070806@gmail.com> Message-ID: <1386097589.13215.YahooMailNeo@web140105.mail.bf1.yahoo.com> Shudder ... yeah, this is about what I thought might be the "default case". Are there any principles about what values go with what free variables? Best, Thomas On Tuesday, December 3, 2013 2:02 PM, Richard Carlsson wrote: On 2013-12-03 13:14 , Thomas Lindgren wrote: > >> Hi guys, >> >> Before I start hacking on something, I thought I'd ask whether there >> already is a standard way to get the original code from a compiled >> fun/closure. (I know you can get it for interpreted funs by using fun_info.) >> >> E.g., for code like this: >> >> -module(a). >> -compile(export_all). >> adder(N) -> fun(X) X+N end. >> >> I'd like to be able to write something like this: >> >>? > c(a), F = a:adder(3), magic:get_code(F). >> {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, >> 0,'X'},{var,0,'N'}}]}], [{'N', 3}]}? %% AST of fun F with free var env >> >> Or the equivalent. > >Use fun_info to get the name/arity of the generated function and dig it >out from the debug_info AST (or for bonus points, reverse-compile the >beam code)? > >Keep in mind that if the code in the fun contains a local call to a >function in the same module, you'll need to include the code for all >reachable functions as well. Hence, the whole AST or the .beam file as a >binary might be more suitable for whatever it is you're doing. > >? ? /Richard > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Tue Dec 3 20:10:26 2013 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 3 Dec 2013 11:10:26 -0800 (PST) Subject: [erlang-questions] Getting code from closures In-Reply-To: <69701B14-F104-4640-AC9F-220154D54B9C@feuerlabs.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> <529DD66B.6070806@gmail.com> <69701B14-F104-4640-AC9F-220154D54B9C@feuerlabs.com> Message-ID: <1386097826.20172.YahooMailNeo@web140105.mail.bf1.yahoo.com> OK, Ulf, I'll have a look at that. It looks like there probably will be a parse transform involved somewhere. Best, Thomas On Tuesday, December 3, 2013 4:28 PM, Ulf Wiger wrote: >The ct_expand transform has a variation of this, where it also ?funnifies? local functions, in order to be able to evaluate them at compile-time. > >The locks_watcher also has a simple inlining transform that transforms a ?pseudo-function? into an abstract expression list that can be evaluated without the need of compiled code. It chases down calls to local functions and transforms those functions into funs inside the expression list. > >https://github.com/uwiger/locks/blob/master/src/locks_watcher.erl#L109 > >BR, >Ulf W > > >On 3 Dec 2013, at 14:02, Richard Carlsson wrote: > >> On 2013-12-03 13:14 , Thomas Lindgren wrote: >>> Hi guys, >>> >>> Before I start hacking on something, I thought I'd ask whether there >>> already is a standard way to get the original code from a compiled >>> fun/closure. (I know you can get it for interpreted funs by using fun_info.) >>> >>> E.g., for code like this: >>> >>> -module(a). >>> -compile(export_all). >>> adder(N) -> fun(X) X+N end. >>> >>> I'd like to be able to write something like this: >>> >>> > c(a), F = a:adder(3), magic:get_code(F). >>> {fun, 0, [{clause, 0, [{var, 0, 'X'}], [], [{op, '+', {var, >>> 0,'X'},{var,0,'N'}}]}], [{'N', 3}]}? %% AST of fun F with free var env >>> >>> Or the equivalent. >> >> Use fun_info to get the name/arity of the generated function and dig it out from the debug_info AST (or for bonus points, reverse-compile the beam code)? >> >> Keep in mind that if the code in the fun contains a local call to a function in the same module, you'll need to include the code for all reachable functions as well. Hence, the whole AST or the .beam file as a binary might be more suitable for whatever it is you're doing. >> >>? /Richard >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > >Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. >http://feuerlabs.com > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Dec 4 01:34:17 2013 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 4 Dec 2013 13:34:17 +1300 Subject: [erlang-questions] Getting code from closures In-Reply-To: <1386097416.74038.YahooMailNeo@web140105.mail.bf1.yahoo.com> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> <1386097416.74038.YahooMailNeo@web140105.mail.bf1.yahoo.com> Message-ID: <1F5F0244-23EE-4F66-A3E0-D5AE0CC6C618@cs.otago.ac.nz> On 4/12/2013, at 8:03 AM, Thomas Lindgren wrote: > I want to look at the closure code to investigate some stupid compiler tricks. Why isn't compiling the with "S" option enough? From tuncer.ayaz@REDACTED Wed Dec 4 08:49:25 2013 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Wed, 4 Dec 2013 08:49:25 +0100 Subject: [erlang-questions] compile: making asm and core official In-Reply-To: References: Message-ID: On Mon, Nov 18, 2013 at 4:06 PM, Anthony Ramine wrote: > I am currently fixing bugs in the BEAM passes which do not expect > already-optimized BEAM code, we might want to want for these before > we start documenting the actual feature. Here's a pull request: https://github.com/erlang/otp/pull/154 http://erlang.org/pipermail/erlang-patches/2013-December/004438.html > Le 18 nov. 2013 ? 16:03, Tuncer Ayaz a ?crit : > >> On Mon, Oct 21, 2013 at 8:06 PM, Tuncer Ayaz wrote: >>> On Fri, Aug 23, 2013 at 2:13 PM, Tuncer Ayaz wrote: >>>> Motivated by a discussion at https://github.com/rebar/rebar/issues/105 >>>> and Bjorn-Egil's suggestion, I'd like to ask for opinions on >>>> officially supporting 'core' and 'asm' as compile:file/2 options. >>>> >>>> (1) How likely are you to accept patches which would: >>>> >>>> * Implement support for compile:file(File, [core]) same as >>>> compile:file(File, [asm]). >>>> >>>> * Officially document 'core' and 'asm' as external names for >>>> 'from_asm' and 'from_core'? >>>> >>>> * Change the existing documentation for 'asm' to not discourage use of >>>> the option as much. >>>> >>>> * Officially document that "erlc foo.core" and "erlc foo.S" have been >>>> wired to from_core and from_asm for ages? >>>> >>>> (2) Document compile_core/3 and compile_asm/3 >>>> >>>> Alternatively, one could call compile:compile_asm/3 and >>>> compile:compile_core/3, but they're internal functions meant to be >>>> used only from erl_compile (used by erlc). This would actually be the >>>> most backwards compatible solution if we don't want to require a >>>> patched compile.beam. >>>> >>>> So, what about alternatively or additionally documenting >>>> compile_core/3 and compile_asm/3? >>> >>> ping >> >> ping From trevorw@REDACTED Wed Dec 4 11:00:04 2013 From: trevorw@REDACTED (Trevor Woollacott) Date: Wed, 4 Dec 2013 12:00:04 +0200 Subject: [erlang-questions] OTP-10984 Message-ID: <004101cef0d7$9b1606f0$d14214d0$@pharos-avantgard.com> Hi, The release notes for Erlang R16B01 have the following fix: OTP-10984 Fixed a race condition when using delayed_write when writing to a file which would cause the same data to be written multiple times. Can anyone please describe under what circumstances the above race condition will occur when using delayed_write? Kind regards, Trevor -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukas@REDACTED Wed Dec 4 11:23:55 2013 From: lukas@REDACTED (Lukas Larsson) Date: Wed, 4 Dec 2013 11:23:55 +0100 Subject: [erlang-questions] OTP-10984 In-Reply-To: <004101cef0d7$9b1606f0$d14214d0$@pharos-avantgard.com> References: <004101cef0d7$9b1606f0$d14214d0$@pharos-avantgard.com> Message-ID: It was a while ago so I don't remember the exact details, but I think that in order to recreate the bug you have to do many many smallish (10-20 bytes) writes to a file with a small (1-2 ms) delayed_write timer. You can theoretically also get unlucky with larger delayed_write values, but I have yet to see that actually happen. Also fyi this race was introduced in the R15B release of Erlang/OTP. Lukas On Wed, Dec 4, 2013 at 11:00 AM, Trevor Woollacott < trevorw@REDACTED> wrote: > Hi, > > > > The release notes for Erlang R16B01 have the following fix: > > OTP-10984 Fixed a race condition when using delayed_write when writing > > to a file which would cause the same data to be written > > multiple times. > > > > Can anyone please describe under what circumstances the above race > condition will occur when using delayed_write? > > > > Kind regards, > Trevor > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carljohan.kjellander@REDACTED Wed Dec 4 14:15:34 2013 From: carljohan.kjellander@REDACTED (Carl-Johan Kjellander) Date: Wed, 4 Dec 2013 14:15:34 +0100 Subject: [erlang-questions] Jinterface OtpErlangBinary utf-8 double encoding Message-ID: I?m having utf-8 double encoding issues when sending binaries between Java and Erlang. java.lang.String foo = new java.lang.String("F??"); record[2] = new OtpErlangBinary(foo.getBytes()); But of course that comes back as <<"F????">> to my erlang node. Anyone have an idea why? Or how to fix? I'm compiling the java code with -encoding UTF-8 and using Erlang R15B (erts-5.9). /cjk -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmkolesnikov@REDACTED Wed Dec 4 14:57:58 2013 From: dmkolesnikov@REDACTED (Dmitry Kolesnikov) Date: Wed, 4 Dec 2013 15:57:58 +0200 Subject: [erlang-questions] Jinterface OtpErlangBinary utf-8 double encoding In-Reply-To: References: Message-ID: <96A5BD2F-5A42-454F-B3C0-7C4EB2196957@gmail.com> Hello, This is correct UTF8 binary. unicode:characters_to_list(B). "F??" <<_:8, A1/utf8, A2/utf8>> = <<"F????">>. A1 = 246 - Dmitry On Dec 4, 2013, at 3:15 PM, Carl-Johan Kjellander wrote: > I?m having utf-8 double encoding issues when sending binaries between Java and Erlang. > > java.lang.String foo = new java.lang.String("F??"); > record[2] = new OtpErlangBinary(foo.getBytes()); > But of course that comes back as <<"F????">> to my erlang node. > > Anyone have an idea why? Or how to fix? I'm compiling the java code with -encoding UTF-8 and using Erlang R15B (erts-5.9). > > /cjk > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From carljohan.kjellander@REDACTED Wed Dec 4 15:10:20 2013 From: carljohan.kjellander@REDACTED (Carl-Johan Kjellander) Date: Wed, 4 Dec 2013 15:10:20 +0100 Subject: [erlang-questions] Jinterface OtpErlangBinary utf-8 double encoding In-Reply-To: <96A5BD2F-5A42-454F-B3C0-7C4EB2196957@gmail.com> References: <96A5BD2F-5A42-454F-B3C0-7C4EB2196957@gmail.com> Message-ID: (moose@REDACTED)58> <<_:8, A1/utf8, A2/utf8>> = <<"F??">>. ** exception error: no match of right hand side value <<"F??">> So what is the correct way of seeing it in the shell? Should I see it as the correct character or the utf-8 encoded ones? /cjk On Wed, Dec 4, 2013 at 2:57 PM, Dmitry Kolesnikov wrote: > Hello, > > This is correct UTF8 binary. > > unicode:characters_to_list(B). > "F??" > > <<_:8, A1/utf8, A2/utf8>> = <<"F????">>. > A1 = 246 > > - Dmitry > > On Dec 4, 2013, at 3:15 PM, Carl-Johan Kjellander < > carljohan.kjellander@REDACTED> wrote: > > I?m having utf-8 double encoding issues when sending binaries between Java > and Erlang. > > java.lang.String foo = new java.lang.String("F??"); > record[2] = new OtpErlangBinary(foo.getBytes()); > > But of course that comes back as <<"F????">> to my erlang node. > > Anyone have an idea why? Or how to fix? I'm compiling the java code with > -encoding UTF-8 and using Erlang R15B (erts-5.9). > > /cjk > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carljohan.kjellander@REDACTED Wed Dec 4 15:20:58 2013 From: carljohan.kjellander@REDACTED (Carl-Johan Kjellander) Date: Wed, 4 Dec 2013 15:20:58 +0100 Subject: [erlang-questions] Jinterface OtpErlangBinary utf-8 double encoding In-Reply-To: References: <96A5BD2F-5A42-454F-B3C0-7C4EB2196957@gmail.com> Message-ID: Ok, it is just a display thing in R15B. (moose@REDACTED)67> <<"F??"/utf8>>. <<"F????">> (moose@REDACTED)68> <<"F??">>. <<"F??">> I thought the latter was utf-8 but probably not then, but the crazy unicode-list-thingee. /cjk On Wed, Dec 4, 2013 at 3:10 PM, Carl-Johan Kjellander < carljohan.kjellander@REDACTED> wrote: > (moose@REDACTED)58> <<_:8, A1/utf8, A2/utf8>> = <<"F??">>. > ** exception error: no match of right hand side value <<"F??">> > > So what is the correct way of seeing it in the shell? Should I see it as > the correct character or the utf-8 encoded ones? > > /cjk > > > On Wed, Dec 4, 2013 at 2:57 PM, Dmitry Kolesnikov wrote: > >> Hello, >> >> This is correct UTF8 binary. >> >> unicode:characters_to_list(B). >> "F??" >> >> <<_:8, A1/utf8, A2/utf8>> = <<"F????">>. >> A1 = 246 >> >> - Dmitry >> >> On Dec 4, 2013, at 3:15 PM, Carl-Johan Kjellander < >> carljohan.kjellander@REDACTED> wrote: >> >> I?m having utf-8 double encoding issues when sending binaries between >> Java and Erlang. >> >> java.lang.String foo = new java.lang.String("F??"); >> record[2] = new OtpErlangBinary(foo.getBytes()); >> >> But of course that comes back as <<"F????">> to my erlang node. >> >> Anyone have an idea why? Or how to fix? I'm compiling the java code with >> -encoding UTF-8 and using Erlang R15B (erts-5.9). >> >> /cjk >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Dec 4 15:57:00 2013 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 04 Dec 2013 15:57:00 +0100 Subject: [erlang-questions] [erlang-patches] Fix spec for cpu_sup:util/1 In-Reply-To: <1fb41668f5e8478398b8e62f3adcfd21@DB3PR03MB315.eurprd03.prod.outlook.com> References: <1fb41668f5e8478398b8e62f3adcfd21@DB3PR03MB315.eurprd03.prod.outlook.com> Message-ID: <529F42BC.6040809@cs.ntua.gr> On 12/04/2013 03:38 PM, Andrew Caruth wrote: > Hi OTP devs, > > I recently noticed dialyzer was flagging an issue in one of our own modules that was making a call to cpu_sup:util([detailed]). An 'is_list()' guard test was performed on the second element of the tuple returned which dialyzer was reporting as a test that could never succeed. Sample output from a call to cpu_sup:util([detailed]): > > {[0], > [{soft_irq,0.0}, > {hard_irq,0.0}, > {kernel,0.41368935690109065}, > {nice_user,0.0}, > {user,0.9402030838661151}], > [{steal,0.0},{idle,98.64610755923279},{wait,0.0}], > []} > > The spec implied {'all' | integer | list, tuple | float, tuple | float, []}, which excludes the above output, so I've updated the spec to allow the second and third elements as lists. > > Also, the atoms 'soft_irq', 'hard_irq', and 'steal' were also not part of the spec, so I've also added those. I do not want to comment on the particular patch, but only to point out that this a more general problem. Often, there are good reasons for implementations of built-in of library functions to contain *more* functionality than what the fine manual describes (e.g. to have some experimental features or interfaces that are not cast in stone yet). I think it's a good idea that the specs and the manual always agree with each other. In fact, I think that the manual of library modules should ideally be produced by what's in their code. All the above imply that dialyzer, which is based on specs, may be less forgiving than the actual implementation, and there are very good reasons for it to behave so: It warns you that you are relying on some undocumented (and likely to disappear) feature of the current implementation. Kostis From hope@REDACTED Wed Dec 4 16:31:50 2013 From: hope@REDACTED (hope@REDACTED) Date: Wed, 4 Dec 2013 23:31:50 +0800 Subject: [erlang-questions] strange result of lists:map(fun(X)-> 20*X end, [2, 4, 6, 8]). In-Reply-To: <73A78F3D-055B-4992-8621-C46664A0765F@inaka.net> References: <3372C4A8537A414DB30F979104CDF15E@vista> <782F8122-9EF4-4A13-889D-B0996CBFFF4A@inaka.net> <73A78F3D-055B-4992-8621-C46664A0765F@inaka.net> Message-ID: <061A118CEC2241EEAB3C00F843A19418@vista> Hi, Work : Again, thank you so much ! Ha, Ha ! Great ! It really work ! best regards. hoe@REDACTED 2013.12.0 --------------------------------------------------------------------------------- From: Work Sent: Wednesday, December 04, 2013 1:46 AM To: Patrick Schless Cc: hope@REDACTED ; erlang-questions Subject: Re: [erlang-questions] strange result of lists:map(fun(X)-> 20*X end, [2, 4, 6, 8]). Yeah, this should work: io:format("~w~n", [lists:map(fun(X)-> 20*X end,L)]). On Dec 3, 2013, at 14:41, Patrick Schless wrote: In cases like this, is there a way to explicitly show the result as numbers (as Hope expected)? On Tue, Dec 3, 2013 at 9:24 AM, Work wrote: Hi! Since strings in Erlang are just lists of integers, and the results of some of your tests are proper lists of strings, they?re *displayed* as strings. In other words "(Px?" = [40, 80, 120, 160] Hope that helps :) For reference, check this: http://learnyousomeerlang.com/starting-out-for-real#lists On Dec 3, 2013, at 12:13, wrote: Hi, I am a beginner, and I got some strange result like this : 1> L=[2,4,6,8]. [2,4,6,8] 2> lists:map(fun(X)-> 20*X end,L). "(Px?" 3> lists:map(fun(X)-> 21*X end,L). "*T~?" 4> lists:map(fun(X)-> 27*X end,L). "6l?O" 5> lists:map(fun(X)-> 28*X end,L). "8p?a" 6> lists:map(fun(X)-> 29*X end,L). ":tRe" 7> lists:map(fun(X)-> 30*X end,L). " lists:map(fun(X)-> 31*X end,L). ">|oo" 9> lists:map(fun(X)-> 32*X end,L). [64,128,192,256] 10> lists:map(fun(X)-> 22*X end,L). [44,88,132,176] 11> lists:map(fun(X)-> 23*X end,L). [46,92,138,184] 12> lists:map(fun(X)-> 24*X end,L). [48,96,144,192] 13> lists:map(fun(X)-> 25*X end,L). [50,100,150,200] 14> lists:map(fun(X)-> 26*X end,L). [52,104,156,208] 15> lists:map(fun(X)-> 27*X end,L). "6l?O" ------------------- Erlang R16B02 (erts-5.10.3) [smp:2:2] [async-threads:10] Eshell V5.10.3 (abort with ^G) ------------------- Windows Vista ------------------- Can someone help me ? Thanks a lot ! best regards. hope@REDACTED 2013.12.03 _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.Caruth@REDACTED Wed Dec 4 17:23:24 2013 From: Andrew.Caruth@REDACTED (Andrew Caruth) Date: Wed, 4 Dec 2013 16:23:24 +0000 Subject: [erlang-questions] [erlang-patches] Fix spec for cpu_sup:util/1 In-Reply-To: <529F42BC.6040809@cs.ntua.gr> References: <1fb41668f5e8478398b8e62f3adcfd21@DB3PR03MB315.eurprd03.prod.outlook.com> <529F42BC.6040809@cs.ntua.gr> Message-ID: Hi Kostis, Thanks for taking a look at that! I definitely agree that the ideal is the documentation of library functions should ultimately come from the code. Otherwise either the spec/documentation is misleading, or the code is misleading. Also, as you point out, the fact that dialyzer flags an error is a potential warning sign that the module is either incomplete, undergoing some changes, is potentially no longer properly supported, or simply contains bugs. Though, upon the completion of a release of a particular version of a library, is that not the point at which the functionality is cast in stone as it were? In general the OTP specs and documentation are excellent. Thanks, Andrew -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Kostis Sagonas Sent: 04 December 2013 14:57 To: erlang-patches@REDACTED Cc: Erlang Subject: Re: [erlang-questions] [erlang-patches] Fix spec for cpu_sup:util/1 On 12/04/2013 03:38 PM, Andrew Caruth wrote: > Hi OTP devs, > > I recently noticed dialyzer was flagging an issue in one of our own modules that was making a call to cpu_sup:util([detailed]). An 'is_list()' guard test was performed on the second element of the tuple returned which dialyzer was reporting as a test that could never succeed. Sample output from a call to cpu_sup:util([detailed]): > > {[0], > [{soft_irq,0.0}, > {hard_irq,0.0}, > {kernel,0.41368935690109065}, > {nice_user,0.0}, > {user,0.9402030838661151}], > [{steal,0.0},{idle,98.64610755923279},{wait,0.0}], > []} > > The spec implied {'all' | integer | list, tuple | float, tuple | float, []}, which excludes the above output, so I've updated the spec to allow the second and third elements as lists. > > Also, the atoms 'soft_irq', 'hard_irq', and 'steal' were also not part of the spec, so I've also added those. I do not want to comment on the particular patch, but only to point out that this a more general problem. Often, there are good reasons for implementations of built-in of library functions to contain *more* functionality than what the fine manual describes (e.g. to have some experimental features or interfaces that are not cast in stone yet). I think it's a good idea that the specs and the manual always agree with each other. In fact, I think that the manual of library modules should ideally be produced by what's in their code. All the above imply that dialyzer, which is based on specs, may be less forgiving than the actual implementation, and there are very good reasons for it to behave so: It warns you that you are relying on some undocumented (and likely to disappear) feature of the current implementation. Kostis _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From davidnwelton@REDACTED Wed Dec 4 17:34:35 2013 From: davidnwelton@REDACTED (David Welton) Date: Wed, 4 Dec 2013 17:34:35 +0100 Subject: [erlang-questions] supervisors & slow init's Message-ID: Hi, I have several questions: I need to start up something, hardware, say, that takes a while to initialize, via an external process. The next child of my supervisor should not start until the first, slow one does. How should I go about notifying Erlang that things are done? Currently, the external system connects as an external node and sends a message. Can I have a receive in the gen_server's init to wait for that? How long does Erlang wait for child processes to start, in any case? Thanks, -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From thomasl_erlang@REDACTED Wed Dec 4 17:56:29 2013 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 4 Dec 2013 08:56:29 -0800 (PST) Subject: [erlang-questions] Getting code from closures In-Reply-To: <1F5F0244-23EE-4F66-A3E0-D5AE0CC6C618@cs.otago.ac.nz> References: <1386072891.71572.YahooMailNeo@web140105.mail.bf1.yahoo.com> <1386097416.74038.YahooMailNeo@web140105.mail.bf1.yahoo.com> <1F5F0244-23EE-4F66-A3E0-D5AE0CC6C618@cs.otago.ac.nz> Message-ID: <1386176189.52334.YahooMailNeo@web140104.mail.bf1.yahoo.com> It's not quite what I need; I'd like to see what code and environment belongs to a (compiled) runtime closure.? Best, Thomas On Wednesday, December 4, 2013 1:34 AM, Richard A. O'Keefe wrote: >On 4/12/2013, at 8:03 AM, Thomas Lindgren wrote: > >> I want to look at the closure code to investigate some stupid compiler tricks. > >Why isn't compiling the with "S" option enough? > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Wed Dec 4 18:07:37 2013 From: davidnwelton@REDACTED (David Welton) Date: Wed, 4 Dec 2013 18:07:37 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: > How long does Erlang wait for child processes to start, in any case? At least in the case of my gen_server, that is apparently covered by gen_server's {timeout, Timeout} option, rather than anything in the supervisor. Well, that's one thing figured out. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From davidnwelton@REDACTED Wed Dec 4 18:35:29 2013 From: davidnwelton@REDACTED (David Welton) Date: Wed, 4 Dec 2013 18:35:29 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: > I need to start up something, hardware, say, that takes a while to > initialize, via an external process. The next child of my supervisor > should not start until the first, slow one does. How should I go > about notifying Erlang that things are done? Currently, the external > system connects as an external node and sends a message. Can I have a > receive in the gen_server's init to wait for that? Initial tests show that it does work, both with a pid, and with the name of the server. Whether it's the best thing to do or not is not something I'm sure of. If I have a 'ready' callback that receives a message from the hardware driver, how do I only then start up the other gen_servers under the supervisor - just do it dynamically? Seems a bit roundabout compared to just starting everything in the right order. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From jesper.louis.andersen@REDACTED Wed Dec 4 20:09:13 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 4 Dec 2013 20:09:13 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: Fire up the supervisor tree as fast as possible, then do the connectivity. A good example is how mnesia does it. You have to call mnesia:wait_for_tables/1,2 in order to wait for tables to come online, but the bootup of mnesia itself is very fast. So in your case, you would call: hardware:wait_ready(arduino, 8000) to wait at most 8000ms for the arduino to come online and so on. There is a recent post by Fred Hebert on this subject, http://ferd.ca/it-s-about-the-guarantees.html you might want to read as well. On Wed, Dec 4, 2013 at 6:35 PM, David Welton wrote: > > I need to start up something, hardware, say, that takes a while to > > initialize, via an external process. The next child of my supervisor > > should not start until the first, slow one does. How should I go > > about notifying Erlang that things are done? Currently, the external > > system connects as an external node and sends a message. Can I have a > > receive in the gen_server's init to wait for that? > > Initial tests show that it does work, both with a pid, and with the > name of the server. > > Whether it's the best thing to do or not is not something I'm sure of. > If I have a 'ready' callback that receives a message from the > hardware driver, how do I only then start up the other gen_servers > under the supervisor - just do it dynamically? Seems a bit roundabout > compared to just starting everything in the right order. > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trevorw@REDACTED Thu Dec 5 09:41:09 2013 From: trevorw@REDACTED (Trevor Woollacott) Date: Thu, 5 Dec 2013 10:41:09 +0200 Subject: [erlang-questions] OTP-10984 In-Reply-To: References: <004101cef0d7$9b1606f0$d14214d0$@pharos-avantgard.com> Message-ID: <002701cef195$bf0eea90$3d2cbfb0$@pharos-avantgard.com> Thanks for the explanation From: garazdawi@REDACTED [mailto:garazdawi@REDACTED] On Behalf Of Lukas Larsson Sent: 04 December 2013 12:24 To: Trevor Woollacott Cc: erlang-questions Subject: Re: [erlang-questions] OTP-10984 It was a while ago so I don't remember the exact details, but I think that in order to recreate the bug you have to do many many smallish (10-20 bytes) writes to a file with a small (1-2 ms) delayed_write timer. You can theoretically also get unlucky with larger delayed_write values, but I have yet to see that actually happen. Also fyi this race was introduced in the R15B release of Erlang/OTP. Lukas On Wed, Dec 4, 2013 at 11:00 AM, Trevor Woollacott > wrote: Hi, The release notes for Erlang R16B01 have the following fix: OTP-10984 Fixed a race condition when using delayed_write when writing to a file which would cause the same data to be written multiple times. Can anyone please describe under what circumstances the above race condition will occur when using delayed_write? Kind regards, Trevor _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Thu Dec 5 13:41:44 2013 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 5 Dec 2013 13:41:44 +0100 (CET) Subject: [erlang-questions] Binary:split and re:split woes In-Reply-To: <1981002184.205450.1386086022848.JavaMail.zimbra@erlang-solutions.com> References: <1981002184.205450.1386086022848.JavaMail.zimbra@erlang-solutions.com> Message-ID: <1565349663.244386.1386247304464.JavaMail.zimbra@erlang-solutions.com> A follow up question is whether and when the splits create new binaries. So if the input to split is a binary and the outputs are also binary are they completely new binaries or just references into the old binary sharing the actual binary data? Robert ----- Original Message ----- > From: "Robert Virding" > > These two functions allow you give a pattern to split binaries (and lists in > re) into a list of sub binaries. If the split pattern occurs at the > beginning or end of the binary then you get empty parts at the beginning or > end. So: > > binary:split(<<" abc def ghi ">>, <<" ">>, [global]) ==> > [<<>>,<<"abc">>,<<"def">>,<<"ghi">>,<<>>] > > This is fine and logical. Often you don't want these empty parts so there is > a 'trim' options which removes them. But it only trims at the end and not at > the beginning. So: > > binary:split(<<" abc def ghi ">>, <<" ">>, [global,trim]) ==> > [<<>>,<<"abc">>,<<"def">>,<<"ghi">>] > > This is stupid! Saying it it done like this Perl is hardly a good excuse for > bad behaviour. > > Sigh, > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From carljohan.kjellander@REDACTED Thu Dec 5 14:09:30 2013 From: carljohan.kjellander@REDACTED (Carl-Johan Kjellander) Date: Thu, 5 Dec 2013 14:09:30 +0100 Subject: [erlang-questions] Binary:split and re:split woes In-Reply-To: <1565349663.244386.1386247304464.JavaMail.zimbra@erlang-solutions.com> References: <1981002184.205450.1386086022848.JavaMail.zimbra@erlang-solutions.com> <1565349663.244386.1386247304464.JavaMail.zimbra@erlang-solutions.com> Message-ID: http://www.erlang.org/doc/efficiency_guide/binaryhandling.html In section 4.1: A *sub binary* is created by split_binary/2 and when a binary is matched out in a binary pattern. A sub binary is a reference into a part of another binary (refc or heap binary, never into a another sub binary). Therefore, matching out a binary is relatively cheap because the actual binary data is never copied. So hopefully it is cheap. I also hate the beginning <<>>, so annoying. I have code in tons of places that removes it. /cjk On Thu, Dec 5, 2013 at 1:41 PM, Robert Virding < robert.virding@REDACTED> wrote: > A follow up question is whether and when the splits create new binaries. > So if the input to split is a binary and the outputs are also binary are > they completely new binaries or just references into the old binary sharing > the actual binary data? > > Robert > > ----- Original Message ----- > > From: "Robert Virding" > > > > These two functions allow you give a pattern to split binaries (and > lists in > > re) into a list of sub binaries. If the split pattern occurs at the > > beginning or end of the binary then you get empty parts at the beginning > or > > end. So: > > > > binary:split(<<" abc def ghi ">>, <<" ">>, [global]) ==> > > [<<>>,<<"abc">>,<<"def">>,<<"ghi">>,<<>>] > > > > This is fine and logical. Often you don't want these empty parts so > there is > > a 'trim' options which removes them. But it only trims at the end and > not at > > the beginning. So: > > > > binary:split(<<" abc def ghi ">>, <<" ">>, [global,trim]) ==> > > [<<>>,<<"abc">>,<<"def">>,<<"ghi">>] > > > > This is stupid! Saying it it done like this Perl is hardly a good excuse > for > > bad behaviour. > > > > Sigh, > > Robert > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Thu Dec 5 14:19:59 2013 From: davidnwelton@REDACTED (David Welton) Date: Thu, 5 Dec 2013 14:19:59 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: > Fire up the supervisor tree as fast as possible, then do the connectivity. A > good example is how mnesia does it. You have to call > mnesia:wait_for_tables/1,2 in order to wait for tables to come online, but > the bootup of mnesia itself is very fast. So in your case, you would call: > hardware:wait_ready(arduino, 8000) to wait at most 8000ms for the arduino to > come online and so on. > > There is a recent post by Fred Hebert on this subject, > > http://ferd.ca/it-s-about-the-guarantees.html > > you might want to read as well. I already read it - it's a great post, as usual. However, perhaps I have not spelled out my problem very well. We have several bits of C code in external processes - let's call them A, B and C to be creative. A starts, and does some stuff. It's kind of slow to do it, so it'd be easy enough to just start it, and handle_info in the gen_server that supervises it to find out when it's really ready. But B and C cannot start until A is ready. So A should send messages to them, too? I can see how to do it, but it all seems kind of complicated compared to just letting them start in the order they are supposed to start in, one after the other. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From davidnwelton@REDACTED Thu Dec 5 17:39:11 2013 From: davidnwelton@REDACTED (David Welton) Date: Thu, 5 Dec 2013 17:39:11 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: Rereading Ferd's article, this jumps out at me: > You could force a connection during initialization if you know the database is on the same host and should be booted before your Erlang system, for example. Then a restart should work. In case of something incomprehensible and unexpected that breaks these guarantees, the node will end up crashing, which is desirable: a pre-condition to starting your system hasn't been met. It's a system-wide assertion that failed. That's what we want! If the "A" system does not start, things should be retried a few times, then everything but a small core which will provide a "fail politely" ( http://joearms.github.io/2013/04/28/Fail-fast-noisely-and-politely.html ) error message to the user should probably not start either. The system should not bring up "not really started B" and "not really started C" just to send them start messages (from where?) when A finally does start 20 seconds later. Incidentally, what's the best way to start this whole subtree so that a small core of the application will survive its death? -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From seancribbs@REDACTED Thu Dec 5 17:47:23 2013 From: seancribbs@REDACTED (Sean Cribbs) Date: Thu, 5 Dec 2013 10:47:23 -0600 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: I'd echo Jesper's comments in saying that is most important to make sure the supervisor tree starts up quickly. There are several options I see: 1) Change A into an FSM (optional, but useful IMHO). Have its initial state be 'connect_to_hardware' with a timeout of 0 returned from init/1, e.g. {ok, connect_to_hardware, State, 0}. Then in 'connect_to_hardware', match timeout and do the connection there, then transition to the 'ready' state. Note that this state will be entered before any other messages are received, meaning that B and C should probably use sync_send_event to communicate with A. 2) Keep A as a gen_server, but do the same timeout trick in init/1. Have A connect in handle_info when receiving 'timeout', and then notify B and C that it's ready after. 3) Use Loic's proc_lib:init_ack + gen_server:enter_loop hack instead of the regular gen_server/gen_fsm flow. This is less clean, but allows you to do those slower blocky things at startup. I think the moral of the story is that starting up your system and implementing a protocol between processes should not be conflated. If there's a sequence of steps to be done with potential exit points or branches at each step, FSMs plus messages feels the most sane to me. On Thu, Dec 5, 2013 at 7:19 AM, David Welton wrote: > > Fire up the supervisor tree as fast as possible, then do the > connectivity. A > > good example is how mnesia does it. You have to call > > mnesia:wait_for_tables/1,2 in order to wait for tables to come online, > but > > the bootup of mnesia itself is very fast. So in your case, you would > call: > > hardware:wait_ready(arduino, 8000) to wait at most 8000ms for the > arduino to > > come online and so on. > > > > There is a recent post by Fred Hebert on this subject, > > > > http://ferd.ca/it-s-about-the-guarantees.html > > > > you might want to read as well. > > I already read it - it's a great post, as usual. > > However, perhaps I have not spelled out my problem very well. > > We have several bits of C code in external processes - let's call them > A, B and C to be creative. A starts, and does some stuff. It's kind > of slow to do it, so it'd be easy enough to just start it, and > handle_info in the gen_server that supervises it to find out when it's > really ready. But B and C cannot start until A is ready. So A should > send messages to them, too? I can see how to do it, but it all seems > kind of complicated compared to just letting them start in the order > they are supposed to start in, one after the other. > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seancribbs@REDACTED Thu Dec 5 18:04:56 2013 From: seancribbs@REDACTED (Sean Cribbs) Date: Thu, 5 Dec 2013 11:04:56 -0600 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: Make the supervisor use the 'rest_for_one' strategy and have A crash if the connection fails. Then the supervisor will restart then entire subtree, starting with A. On Thu, Dec 5, 2013 at 10:39 AM, David Welton wrote: > Rereading Ferd's article, this jumps out at me: > > > You could force a connection during initialization if you know the > database is on the same host and should be booted before your Erlang > system, for example. Then a restart should work. In case of something > incomprehensible and unexpected that breaks these guarantees, the node will > end up crashing, which is desirable: a pre-condition to starting your > system hasn't been met. It's a system-wide assertion that failed. > > That's what we want! If the "A" system does not start, things should > be retried a few times, then everything but a small core which will > provide a "fail politely" ( > http://joearms.github.io/2013/04/28/Fail-fast-noisely-and-politely.html > ) error message to the user should probably not start either. The > system should not bring up "not really started B" and "not really > started C" just to send them start messages (from where?) when A > finally does start 20 seconds later. > > Incidentally, what's the best way to start this whole subtree so that > a small core of the application will survive its death? > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Thu Dec 5 18:57:33 2013 From: mononcqc@REDACTED (Fred Hebert) Date: Thu, 5 Dec 2013 09:57:33 -0800 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: References: Message-ID: <20131205175731.GH96517@ferdair.local> Answers inline. On 12/05, Sean Cribbs wrote: > I'd echo Jesper's comments in saying that is most important to make sure > the supervisor tree starts up quickly. There are several options I see: > Outside of the current's case context, I don't necessarily agree with that. The supervision tree can take as long as necessary to start as long as it's in a stable state. The requirement for speed is application-specific. If you need to do data syncing for 10 minutes before starting to boot, I prefer to lock up the supervision tree than having to implement 12 child applications than need to synchronize on things -- if I can afford it, of course. To me the most important thing is figuring out what you can or can't do, and picking the boot and supervision strategy the most adequate to that. If booting fast is counter-intuitive to the results you want, don't do it. Of course, requirements may change as usage grows over time, which means you may very well end up refactoring towards one way or another as people make use of the system and decide what they can and can't have. > 1) Change A into an FSM (optional, but useful IMHO). Have its initial state > be 'connect_to_hardware' with a timeout of 0 returned from init/1, e.g. > {ok, connect_to_hardware, State, 0}. Then in 'connect_to_hardware', match > timeout and do the connection there, then transition to the 'ready' state. > Note that this state will be entered before any other messages are > received, meaning that B and C should probably use sync_send_event to > communicate with A. > > 2) Keep A as a gen_server, but do the same timeout trick in init/1. Have A > connect in handle_info when receiving 'timeout', and then notify B and C > that it's ready after. > No adversarial opinion on this, I agree with that as a good approach to quick boots and whatnot. > 3) Use Loic's proc_lib:init_ack + gen_server:enter_loop hack instead of the > regular gen_server/gen_fsm flow. This is less clean, but allows you to do > those slower blocky things at startup. > I tend to prefer the 'send myself a message' approach in init. I especially like it because if I do, say a reconnect on a 'reconnect' event (or in this case a 'check_for_hardware' message), I trigger that event as part of the init callback, and can keep using the same mechanism and code path during regular operations after. They're both entirely valid, of course, and for the few years I've been around in the community, everybody has ended up picking their own favorite and defending it without yielding. The truth is that they all work fine and they all come down to aesthetic preferences. > I think the moral of the story is that starting up your system and > implementing a protocol between processes should not be conflated. If > there's a sequence of steps to be done with potential exit points or > branches at each step, FSMs plus messages feels the most sane to me. > Agreed. The opposite rule is that if potential exit points are unforseeable and should (according to spec) not happen (say not being able to open a UDP port to localhost, for example), then you may want to skip the protocol design step entirely (all code is a risk of bugs!). This means you *may* suffer unexpected failures, in which case your choice will be to take the necessary means to make the preconditions to your system's functionality be respected, or relax them and go with the protocols as you start needing them while you grow and groom your system. Production systems I end up working with often end up being a mix of both approaches. Things like configuration files, accessibility to the file system (say for logging purposes), local resources that can be depended on (opening UDP ports for logs, again), restoring a stable state from disk or network, and so on, are things I'll readily put into requirements of a supervisor and may decide to synchronously load no matter how long it takes (some applications may just end up having over 10 minutes boot times in rare cases, but that's okay because we're possibly syncing gigabytes that we *need* to work with as a base state if we don't want to serve incorrect information.) On the other hand, code that depends on non-local databases and external services will have the partial startup with quick tree booting because if the failure is expected to happen often during regular operations, then there's no difference between now and later. You gotta handle it the same, and for these parts of the system, internal protocols and far less strict guarantees are the solution. Regards, Fred. From alex@REDACTED Fri Dec 6 02:49:35 2013 From: alex@REDACTED (Alex Wilson) Date: Fri, 6 Dec 2013 11:49:35 +1000 Subject: [erlang-questions] myproto development status (erlang as an SQL server) In-Reply-To: References: Message-ID: <1D469045-6D87-4471-A7A9-74A0DEBAA6AD@cooperi.net> On 29 Nov 2013, at 7:59 pm, Max Lapshin wrote: > Hi. > > Some time ago Manuel has released myproto library: https://github.com/altenwald/myproto > > This is an implementation of mysql server protocol. Has anyone had a look at how hard it would be to add support for the MySQL 4.1 prepared statements protocol? I?m kinda curious if this could be used as a convenient transport for some other semi-SQL-like languages like SPARQL or other graph queries, but their quoting rules are not always identical to SQL, so the prepared statements protocol could make a lot of sense. Do you think it could be useful as a transport like this? (after disabling the SQL parser part) Maybe I?m crazy and taking this ?use mysql protocol instead of HTTP? idea too far? :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Dec 6 12:07:43 2013 From: davidnwelton@REDACTED (David Welton) Date: Fri, 6 Dec 2013 12:07:43 +0100 Subject: [erlang-questions] supervisors & slow init's In-Reply-To: <20131205175731.GH96517@ferdair.local> References: <20131205175731.GH96517@ferdair.local> Message-ID: Hi, and thanks to everyone for the great responses so far, On Thu, Dec 5, 2013 at 6:57 PM, Fred Hebert wrote: > On 12/05, Sean Cribbs wrote: >> I'd echo Jesper's comments in saying that is most important to make sure >> the supervisor tree starts up quickly. There are several options I see: >> > > Outside of the current's case context, I don't necessarily agree with > that. The supervision tree can take as long as necessary to start as > long as it's in a stable state. The requirement for speed is > application-specific. If you need to do data syncing for 10 minutes > before starting to boot, I prefer to lock up the supervision tree than > having to implement 12 child applications than need to synchronize on > things -- if I can afford it, of course. So this would be a reason to put a blocking receive in the init and just wait for it... I like this because it is simple and reflects how things work. A must start correctly for B and then C to start, and if A crashes, one_for_all will bring down B and C too, and try and restart A and then everything else. So far so good! > To me the most important thing is figuring out what you can or can't do, > and picking the boot and supervision strategy the most adequate to that. > If booting fast is counter-intuitive to the results you want, don't do > it. The system (based on some hardware that takes its time) does not come up fast, but is basically useless without the hardware. That said, some part of the system, that interacts with the end user, does need to come up fast, which is the next question about the . Clearly the UI should start before the hardware and be responsive in telling any users that "the system is not ready yet", and maybe for exceptional situations, have some diagnostics and tools to poke at a mostly dead system. And even if the hardware blows up, the UI should stick around and serve up some diagnostics. >> I think the moral of the story is that starting up your system and >> implementing a protocol between processes should not be conflated. If >> there's a sequence of steps to be done with potential exit points or >> branches at each step, FSMs plus messages feels the most sane to me. >> > > Agreed. > > The opposite rule is that if potential exit points are unforseeable > and should (according to spec) not happen (say not being able to open a > UDP port to localhost, for example), then you may want to skip the > protocol design step entirely (all code is a risk of bugs!). This means > you *may* suffer unexpected failures, in which case your choice will be > to take the necessary means to make the preconditions to your system's > functionality be respected, or relax them and go with the protocols as > you start needing them while you grow and groom your system. Yes - for the time being, if this stuff blows up, I don't want to send messages around, or make most other bits of the system aware that bits of the system might be compromised, I want to restart it to a known stable state or register it as FUBAR, and maintain a small system to let the user know this, and maybe attempt some diagnostics. Thank you, -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From a.brandon.clark@REDACTED Fri Dec 6 23:07:11 2013 From: a.brandon.clark@REDACTED (Brandon Clark) Date: Fri, 6 Dec 2013 14:07:11 -0800 Subject: [erlang-questions] Processes hanging in prim_inet:close_port/1 Message-ID: Greetings! I have an application where, once in a while, processes appear to hang in prim_inet:close_port/1. I'm not sure what to do with that. The application uses R16B02. Here's a sample of the process info for a "stuck" process: [{current_stacktrace,[{prim_inet,close_port,1,[]}, {inet,tcp_close,1,[{file,"inet.erl"},{line,1422}]}, {proxy_worker,disconnect_endpoint,1, [{file,"src/proxy_worker.erl"},{line,1082}]}, {proxy_worker,process_chunked_reply,1, [{file,"src/proxy_worker.erl"},{line,496}]}, {proxy_worker,process_request,2, [{file,"src/proxy_worker.erl"},{line,100}]}, {proxy_worker,work_request,2, [{file,"src/proxy_worker.erl"},{line,87}]}, {pool_worker,handle_cast,2, [{file,"src/pool_worker.erl"},{line,73}]}, {gen_server,handle_msg,5, [{file,"gen_server.erl"},{line,604}]}]}, {current_function,{prim_inet,close_port,1}}, {initial_call,{proc_lib,init_p,5}}, {status,waiting}, {message_queue_len,1}, {messages,[{tcp_closed,#Port<9492.545567>}]}, {links,[<9492.10266.0>]}, {dictionary,[{'$ancestors',[<9492.10266.0>,<9492.10263.0>, cellophane_sup,<9492.114.0>]}, {'$initial_call',{pool_worker,init,1}}]}, {trap_exit,true}, {error_handler,error_handler}, {priority,normal}, {group_leader,<9492.113.0>}, {total_heap_size,2586}, {heap_size,2586}, {stack_size,44}, {reductions,4490210}, {garbage_collection,[{min_bin_vheap_size,46422}, {min_heap_size,233}, {fullsweep_after,0}, {minor_gcs,0}]}, {suspending,[]}]}] Apparently, this condition occurs -- intermittently -- when the client (the process described above) and the server (a different app and platform) decide to close their socket connection at about the same time. Notice the tcp_closed message in the inbox. The socket in question is in {active, once} mode. The {status,waiting} and {trap_exit, true} suggest to me that the process is stuck in the receive at line 210 of prim_inet: 188 close_port(S) -> 189 case erlang:process_info(self(), trap_exit) of 190 {trap_exit,true} -> 191 %% Ensure exit message and consume it 192 link(S), 193 %% This is still not a perfect solution. 194 %% 195 %% The problem is to close the port and consume any exit 196 %% message while not knowing if this process traps exit 197 %% nor if this process has a link to the port. Here we 198 %% just knows that this process traps exit. 199 %% 200 %% If we right here get killed for some reason that exit 201 %% signal will propagate to the port and onwards to anyone 202 %% that is linked to the port. E.g when we close a socket 203 %% that is not ours. 204 %% 205 %% The problem can be solved with lists:member on our link 206 %% list but we deem that as potentially too expensive. We 207 %% need an is_linked/1 function or guard, or we need 208 %% a port_close function that can atomically unlink... 209 catch erlang:port_close(S), 210 receive {'EXIT',S,_} -> ok end; 211 {trap_exit,false} -> 212 catch erlang:port_close(S), 213 ok 214 end. But now I'm speculating. I'm in over my head, here. Any suggestions on how to clear up these stuck processes would be greatly appreciated! ~BC -------------- next part -------------- An HTML attachment was scrubbed... URL: From tstover@REDACTED Sat Dec 7 00:01:59 2013 From: tstover@REDACTED (Thomas Stover) Date: Fri, 6 Dec 2013 17:01:59 -0600 Subject: [erlang-questions] Erlang grammer definition Message-ID: Hi. I am aware of yecc, and leex, which I do use. Though, I am actually in need of a yacc/bison /lexx/flexx grammer definition for the erlang language itself. This sounds like the sort of thing that likely already exists out there in the wild. --- C. Thomas Stover Sr. Software Engineer Alert Logic, Inc. T 713.484.8383 ext. 2340 E tstover@REDACTED Security ? Compliance ? Cloud -------------- next part -------------- An HTML attachment was scrubbed... URL: From aggelgian@REDACTED Sat Dec 7 00:15:36 2013 From: aggelgian@REDACTED (Aggelos Giantsios) Date: Sat, 7 Dec 2013 01:15:36 +0200 Subject: [erlang-questions] Erlang grammer definition In-Reply-To: References: Message-ID: This is the YECC definition ( https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl) Hopefully, you can adapt it for the tool of your choice. Aggelos On Sat, Dec 7, 2013 at 1:01 AM, Thomas Stover wrote: > Hi. I am aware of yecc, and leex, which I do use. Though, I am actually in > need of a yacc/bison /lexx/flexx grammer definition for the erlang language > itself. This sounds like the sort of thing that likely already exists out > there in the wild. > > > --- > C. Thomas Stover > Sr. Software Engineer > > Alert Logic, Inc. > > > *T *713.484.8383 ext. 2340 > > *E* tstover@REDACTED > > *Security ? Compliance ? Cloud* > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pierrefenoll@REDACTED Sat Dec 7 01:49:59 2013 From: pierrefenoll@REDACTED (Pierre Fenoll) Date: Sat, 7 Dec 2013 00:49:59 +0000 Subject: [erlang-questions] Erlang grammer definition In-Reply-To: References: Message-ID: This should help. https://github.com/antlr/grammars-v4/tree/master/erlang It is an ANTLR4 grammar of Erlang R16B02. Lexer and parser. Cheers, -- Pierre Fenoll On 6 December 2013 23:15, Aggelos Giantsios wrote: > This is the YECC definition ( > https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl) > Hopefully, you can adapt it for the tool of your choice. > > Aggelos > > > On Sat, Dec 7, 2013 at 1:01 AM, Thomas Stover wrote: > >> Hi. I am aware of yecc, and leex, which I do use. Though, I am actually >> in need of a yacc/bison /lexx/flexx grammer definition for the erlang >> language itself. This sounds like the sort of thing that likely already >> exists out there in the wild. >> >> >> --- >> C. Thomas Stover >> Sr. Software Engineer >> >> Alert Logic, Inc. >> >> >> *T *713.484.8383 ext. 2340 >> >> *E* tstover@REDACTED >> >> *Security ? Compliance ? Cloud* >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Sat Dec 7 01:57:21 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Fri, 6 Dec 2013 17:57:21 -0700 Subject: [erlang-questions] 'ssh' security issue Message-ID: Greetings, I am attempting to just create an SSH shell to connect to a system by users so they can do commands without the web interface, and as such I certainly do not want things like port forwarding or being able to run arbitrary erlang code, however I do not seem to be able to disable running arbitrary erlang code. An example of the ssh_sample_cli included with erlang: """ $ erl Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Eshell V5.10.3 (abort with ^G) 1> c(ssh_sample_cli). ssh_sample_cli.erl:146: Warning: this expression will fail with a 'badarith' exception {ok,ssh_sample_cli} 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). {ok,<0.67.0>} """ And from another shell/computer: """ $ ssh -p 8321 to.the.host myusername@REDACTED's password: Enter command CLI> help CLI Sample crash crash the cli exit exit application factors prime factors of gcd greatest common divisor help help text host print host addr lcm least common multiplier prime check for primality primes print all primes up to rho prime factors using rho's alg. self print my pid user print name of user ---> ok CLI> exit ---> done Connection to to.the.host closed. """ So far so good (the main program where I have this implemented has a well running shell of its own), but lets try a couple other things: """ $ sftp -P 8321 to.the.host myusername@REDACTED's password: subsystem request failed on channel 0 Connection closed """ Also good, no file transfers can be done since the option subsystem is set to [], but notice: """ $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh gnineppah si tahw woN").' myusername@REDACTED's password: "Now what is happening here and how do I stop it?!" """ So... I can still run arbitrary erlang commands, how do I stop this? Unable to find an option to pass in or anything through a quick code perusal to no avail. Help? From wallentin.dahlberg@REDACTED Sat Dec 7 05:30:11 2013 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Sat, 7 Dec 2013 05:30:11 +0100 Subject: [erlang-questions] Processes hanging in prim_inet:close_port/1 In-Reply-To: References: Message-ID: We are aware of this problem and I think there is a fix to R16B03. I don't see it on maint on GitHub yet. The runtime forces the port to unlink during port_close in some cases which causes this problem. // Bj?rn-Egil 2013/12/6 Brandon Clark > Greetings! > > I have an application where, once in a while, processes appear to hang in > prim_inet:close_port/1. I'm not sure what to do with that. > > The application uses R16B02. > > Here's a sample of the process info for a "stuck" process: > > [{current_stacktrace,[{prim_inet,close_port,1,[]}, > {inet,tcp_close,1,[{file,"inet.erl"},{line,1422}]}, > {proxy_worker,disconnect_endpoint,1, > > [{file,"src/proxy_worker.erl"},{line,1082}]}, > {proxy_worker,process_chunked_reply,1, > > [{file,"src/proxy_worker.erl"},{line,496}]}, > {proxy_worker,process_request,2, > > [{file,"src/proxy_worker.erl"},{line,100}]}, > {proxy_worker,work_request,2, > > [{file,"src/proxy_worker.erl"},{line,87}]}, > {pool_worker,handle_cast,2, > > [{file,"src/pool_worker.erl"},{line,73}]}, > {gen_server,handle_msg,5, > > [{file,"gen_server.erl"},{line,604}]}]}, > {current_function,{prim_inet,close_port,1}}, > {initial_call,{proc_lib,init_p,5}}, > {status,waiting}, > {message_queue_len,1}, > {messages,[{tcp_closed,#Port<9492.545567>}]}, > {links,[<9492.10266.0>]}, > {dictionary,[{'$ancestors',[<9492.10266.0>,<9492.10263.0>, > cellophane_sup,<9492.114.0>]}, > {'$initial_call',{pool_worker,init,1}}]}, > {trap_exit,true}, > {error_handler,error_handler}, > {priority,normal}, > {group_leader,<9492.113.0>}, > {total_heap_size,2586}, > {heap_size,2586}, > {stack_size,44}, > {reductions,4490210}, > {garbage_collection,[{min_bin_vheap_size,46422}, > {min_heap_size,233}, > {fullsweep_after,0}, > {minor_gcs,0}]}, > {suspending,[]}]}] > > > Apparently, this condition occurs -- intermittently -- when the client > (the process described above) and the server (a different app and platform) > decide to close their socket connection at about the same time. Notice the > tcp_closed message in the inbox. > > The socket in question is in {active, once} mode. > > The {status,waiting} and {trap_exit, true} suggest to me that the process > is stuck in the receive at line 210 of prim_inet: > > 188 close_port(S) -> > 189 case erlang:process_info(self(), trap_exit) of > 190 {trap_exit,true} -> > 191 %% Ensure exit message and consume it > 192 link(S), > 193 %% This is still not a perfect solution. > 194 %% > 195 %% The problem is to close the port and consume any exit > 196 %% message while not knowing if this process traps exit > 197 %% nor if this process has a link to the port. Here we > 198 %% just knows that this process traps exit. > 199 %% > 200 %% If we right here get killed for some reason that exit > 201 %% signal will propagate to the port and onwards to anyone > 202 %% that is linked to the port. E.g when we close a socket > 203 %% that is not ours. > 204 %% > 205 %% The problem can be solved with lists:member on our link > 206 %% list but we deem that as potentially too expensive. We > 207 %% need an is_linked/1 function or guard, or we need > 208 %% a port_close function that can atomically unlink... > 209 catch erlang:port_close(S), > 210 receive {'EXIT',S,_} -> ok end; > 211 {trap_exit,false} -> > 212 catch erlang:port_close(S), > 213 ok > 214 end. > > > But now I'm speculating. I'm in over my head, here. > > Any suggestions on how to clear up these stuck processes would be greatly > appreciated! > > ~BC > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shivajisainik@REDACTED Sat Dec 7 15:41:59 2013 From: shivajisainik@REDACTED (Natesh Manikoth) Date: Sat, 7 Dec 2013 09:41:59 -0500 Subject: [erlang-questions] Any examples of use of Erlang in systems where safety is key requirement Message-ID: Hello list, Standards such as DO-178C (for level A,B,C) would preclude the use of Erlang. Are there any examples of use of Erlang in such environments even in cases where the software is not safety critical (but might be categorized as supporting safety critical systems - say in an advisory type system). Thanks Natesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From bombadil@REDACTED Sat Dec 7 20:50:26 2013 From: bombadil@REDACTED (Manuel A. Rubio "Bombadil") Date: Sat, 07 Dec 2013 20:50:26 +0100 Subject: [erlang-questions] myproto development status (erlang as an SQL server) In-Reply-To: <1D469045-6D87-4471-A7A9-74A0DEBAA6AD@cooperi.net> References: <1D469045-6D87-4471-A7A9-74A0DEBAA6AD@cooperi.net> Message-ID: <46b6bd8894aa46e60ccfe92c96bcf5b7@bosqueviejo.net> Hi Alex, El 2013-12-06 02:49, Alex Wilson escribi?: > Has anyone had a look at how hard it would be to add support for the > MySQL 4.1 prepared statements protocol? I'm kinda curious if this could > be used as a convenient transport for some other semi-SQL-like > languages like SPARQL or other graph queries, but their quoting rules > are not always identical to SQL, so the prepared statements protocol > could make a lot of sense. Do you think it could be useful as a > transport like this? (after disabling the SQL parser part) > > Maybe I'm crazy and taking this "use mysql protocol instead of HTTP" > idea too far? :) I think Max was working on it. It's not complex or hard to do, but requires time :-P About use SPARQL or another language for query, I think you can do a DSL and translate to SQL without problems. Neotoma is great for this tasks :-) Regards. Manuel Rubio. From bombadil@REDACTED Sat Dec 7 20:55:50 2013 From: bombadil@REDACTED (Manuel A. Rubio "Bombadil") Date: Sat, 07 Dec 2013 20:55:50 +0100 Subject: [erlang-questions] [ANN] ephp, A PHP Interpreter in pure Erlang Message-ID: <939b285caa803f3fd139a40223fd0d1c@bosqueviejo.net> Hi, I was playing with neotoma[1] and I did finally this tool: https://github.com/altenwald/ephp A PHP interpreter, with a lot of work to do, but I hope can be a good point for templates, plugins or addons in any project that need it. Comments are welcome :-) Thanks. Manuel Rubio. From janos.n.hary@REDACTED Sun Dec 8 18:17:46 2013 From: janos.n.hary@REDACTED (Janos Hary) Date: Sun, 8 Dec 2013 18:17:46 +0100 Subject: [erlang-questions] File synchronizer app in Erlang Message-ID: <001101cef439$6ab9fc90$402df5b0$@gmail.com> All, Is there an rsync/Unison like file synchronizer written in Erlang? The important feature would be running the app on two (or more) machines and transferring only the changes. Thanks for your answers, Janos From sean@REDACTED Mon Dec 9 08:00:03 2013 From: sean@REDACTED (Functional Jobs) Date: Mon, 9 Dec 2013 02:00:03 -0500 Subject: [erlang-questions] New Functional Programming Job Opportunities Message-ID: <52a56a7bce712@functionaljobs.com> Here are some functional programming job opportunities that were posted recently: Senior Software Engineer ? Erlang (m/f) at SumUp http://functionaljobs.com/jobs/8667-senior-software-engineer--erlang-m-f-at-sumup Cheers, Sean Murphy FunctionalJobs.com From jesper.louis.andersen@REDACTED Mon Dec 9 11:32:39 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 9 Dec 2013 11:32:39 +0100 Subject: [erlang-questions] Any examples of use of Erlang in systems where safety is key requirement In-Reply-To: References: Message-ID: On Sat, Dec 7, 2013 at 3:41 PM, Natesh Manikoth wrote: > Standards such as DO-178C (for level A,B,C) would preclude the use of > Erlang. Why do you insist those levels will preclude the use of Erlang? There is one area in which Erlang is currently not too suitable and that is for hard real time systems. But if you can accept soft realtime characteristics, it is possible to certify Erlang systems to a very high level. I have not heard of Erlangs use in such systems. But even if Erlang is not hard realtime, you can still use Erlang in such an environment. You just have to decouple the hard realtime components from the rest of the system in such a way that the rest of the system can run in a soft-realtime environment. And if the Erlang system fails to meet a deadline, the hard-realtime part just needs to have a way to do failure mitigation. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jose.valim@REDACTED Mon Dec 9 11:51:39 2013 From: jose.valim@REDACTED (=?ISO-8859-1?Q?Jos=E9_Valim?=) Date: Mon, 9 Dec 2013 10:51:39 +0000 Subject: [erlang-questions] Any examples of use of Erlang in systems where safety is key requirement In-Reply-To: References: Message-ID: > > Why do you insist those levels will preclude the use of Erlang? There is > one area in which Erlang is currently not too suitable and that is for hard > real time systems. But if you can accept soft realtime characteristics, it > is possible to certify Erlang systems to a very high level. I have not > heard of Erlangs use in such systems. But even if Erlang is not hard > realtime, you can still use Erlang in such an environment. You just have to > decouple the hard realtime components from the rest of the system in such a > way that the rest of the system can run in a soft-realtime environment. And > if the Erlang system fails to meet a deadline, the hard-realtime part just > needs to have a way to do failure mitigation. > There was a talk at Codemesh this year (http://codemesh.io/) called "Grisp: Building Space Ships with Erlang" that presented a system designed similarly to what Jesper just described, with the hard-realtime decoupled from the soft-realtime in Erlang. Although the video is not yet online, the talk slides can be found on the website. *Jos? Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer -------------- next part -------------- An HTML attachment was scrubbed... URL: From igonin_phys@REDACTED Mon Dec 9 15:07:23 2013 From: igonin_phys@REDACTED (=?UTF-8?B?0JjQs9C+0L3QuNC9INCc0LjRhdCw0LjQuw==?=) Date: Mon, 09 Dec 2013 18:07:23 +0400 Subject: [erlang-questions] =?utf-8?q?SSL/TLS_distribution?= Message-ID: <1386598043.503864108@f331.i.mail.ru> Hi! I already asked this question in Basho/node_package/riak, but received no clear answer. Someone may be encountered such a problem? I'm using rebar to build my application, and node_package to create RPM-package. Then i define an environment variables in the file vm.ags as described? http://www.erlang.org/doc/apps/ssl/ssl_distribution.html: -proto_dist inet_tls -ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" -ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" -ssl_dist_opt server_secure_renegotiate true -ssl_dist_opt client_secure_renegotiate true And then run: [root@REDACTED bin]# myapp start !!!! !!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. !!!! myapp failed to start within 15 seconds, see the output of 'myapp console' for more information. If you want to wait longer, set the environment variable WAIT_FOR_ERLANG to the number of seconds to wait. =========== In the result I get: 1. The console log -- all well, as if the node is started correctly. 2. The error log is empty. 3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual machine is running (!). 4. But: * Command 'start' -- hangs * 'ping' is not work * The node cannot be stopped, because the 'stop' command does not work * I can't connect to the node through 'attach'/'attach-direct' for the same reason * Even 'getpid' says that the node is not running.... What could be the problem? (Erlang R16B01, RHEL6.3 ) From dmkolesnikov@REDACTED Mon Dec 9 16:02:40 2013 From: dmkolesnikov@REDACTED (Dmitry Kolesnikov) Date: Mon, 9 Dec 2013 17:02:40 +0200 Subject: [erlang-questions] SSL/TLS distribution In-Reply-To: <1386598043.503864108@f331.i.mail.ru> References: <1386598043.503864108@f331.i.mail.ru> Message-ID: <259CB0D5-25E3-4F48-B381-F1401D004BA7@gmail.com> Hello, This looks like Out-Of-File descriptor "death". Why this happened I do not have any idea!! I bet this relates to SSL distribution. Should you try to increase limit like it was advertised? - Dmitry On Dec 9, 2013, at 4:07 PM, ?????? ?????? wrote: > > Hi! > I already asked this question in Basho/node_package/riak, but received no clear answer. Someone may be encountered such a problem? > > I'm using rebar to build my application, and node_package to create RPM-package. > Then i define an environment variables in the file vm.ags as described http://www.erlang.org/doc/apps/ssl/ssl_distribution.html: > -proto_dist inet_tls > -ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" > -ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" > -ssl_dist_opt server_secure_renegotiate true > -ssl_dist_opt client_secure_renegotiate true > And then run: > > [root@REDACTED bin]# myapp start > !!!! > !!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. > !!!! > myapp failed to start within 15 seconds, > see the output of 'myapp console' for more information. > If you want to wait longer, set the environment variable > WAIT_FOR_ERLANG to the number of seconds to wait. > > =========== > In the result I get: > 1. The console log -- all well, as if the node is started correctly. > 2. The error log is empty. > 3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual machine is running (!). > 4. But: > * Command 'start' -- hangs > * 'ping' is not work > * The node cannot be stopped, because the 'stop' command does not work > * I can't connect to the node through 'attach'/'attach-direct' for the same reason > * Even 'getpid' says that the node is not running.... > > What could be the problem? > > (Erlang R16B01, RHEL6.3 ) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From igonin_phys@REDACTED Tue Dec 10 07:44:09 2013 From: igonin_phys@REDACTED (=?UTF-8?B?TWlraGFpbCBJZ29uaW4=?=) Date: Tue, 10 Dec 2013 10:44:09 +0400 Subject: [erlang-questions] =?utf-8?q?SSL/TLS_distribution?= In-Reply-To: <259CB0D5-25E3-4F48-B381-F1401D004BA7@gmail.com> References: <1386598043.503864108@f331.i.mail.ru> <259CB0D5-25E3-4F48-B381-F1401D004BA7@gmail.com> Message-ID: <1386657849.702359889@f78.i.mail.ru> Hello Dmitry,?i installed the hard and soft limits on 65536, but the result is the same... With best regards, Mike >Hello, > >This looks like Out-Of-File descriptor "death". >Why this happened I do not have any idea!! I bet this relates to SSL distribution. >Should you try to increase limit like it was advertised? > >- Dmitry > >On Dec 9, 2013, at 4:07 PM, < igonin_phys@REDACTED > wrote: > >> >> Hi! >> I already asked this question in Basho/node_package/riak, but received no clear answer. Someone may be encountered such a problem? >> >> I'm using rebar to build my application, and node_package to create RPM-package. >> Then i define an environment variables in the file vm.ags as described http://www.erlang.org/doc/apps/ssl/ssl_distribution.html : >> -proto_dist inet_tls >> -ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" >> -ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" >> -ssl_dist_opt server_secure_renegotiate true >> -ssl_dist_opt client_secure_renegotiate true >> And then run: >> >> [root@REDACTED bin]# myapp start >> !!!! >> !!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. >> !!!! >> myapp failed to start within 15 seconds, >> see the output of 'myapp console' for more information. >> If you want to wait longer, set the environment variable >> WAIT_FOR_ERLANG to the number of seconds to wait. >> >> =========== >> In the result I get: >> 1. The console log -- all well, as if the node is started correctly. >> 2. The error log is empty. >> 3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual machine is running (!). >> 4. But: >> * Command 'start' -- hangs >> * 'ping' is not work >> * The node cannot be stopped, because the 'stop' command does not work >> * I can't connect to the node through 'attach'/'attach-direct' for the same reason >> * Even 'getpid' says that the node is not running.... >> >> What could be the problem? >> >> (Erlang R16B01, RHEL6.3 ) >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > From ingela.andin@REDACTED Tue Dec 10 11:08:55 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Tue, 10 Dec 2013 11:08:55 +0100 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Hi! The CLI example in the SSH application must be seen as a hack. We intend to clean it up and extend the SSH documentation, when it gets prioritized I can not say. Well anyway your CLI implementation must take care of SSH exec request as well. You can also look at the ssh_cli.erl module. If I remember correctly there was a bug, before ssh-2.1.7, with regards to the exec request so that it was not forwarded to CLI process but rather always interpreted in the erlang shell environment. Regards Ingela Erlang/OTP team - Ericsson AB 2013/12/7 OvermindDL1 > Greetings, > > I am attempting to just create an SSH shell to connect to a system by > users so they can do commands without the web interface, and as such I > certainly do not want things like port forwarding or being able to run > arbitrary erlang code, however I do not seem to be able to disable > running arbitrary erlang code. An example of the ssh_sample_cli > included with erlang: > """ > $ erl > Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] > [async-threads:10] [hipe] [kernel-poll:false] > > Eshell V5.10.3 (abort with ^G) > 1> c(ssh_sample_cli). > ssh_sample_cli.erl:146: Warning: this expression will fail with a > 'badarith' exception > {ok,ssh_sample_cli} > 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). > {ok,<0.67.0>} > """ > > And from another shell/computer: > """ > $ ssh -p 8321 to.the.host > myusername@REDACTED's password: > Enter command > CLI> help > CLI Sample > crash crash the cli > exit exit application > factors prime factors of > gcd greatest common divisor > help help text > host print host addr > lcm least common multiplier > prime check for primality > primes print all primes up to > rho prime factors using rho's alg. > self print my pid > user print name of user > > ---> ok > CLI> exit > ---> done > Connection to to.the.host closed. > """ > > So far so good (the main program where I have this implemented has a > well running shell of its own), but lets try a couple other things: > """ > $ sftp -P 8321 to.the.host > myusername@REDACTED's password: > subsystem request failed on channel 0 > Connection closed > """ > > Also good, no file transfers can be done since the option subsystem is > set to [], but notice: > """ > $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh > gnineppah si tahw woN").' > myusername@REDACTED's password: > "Now what is happening here and how do I stop it?!" > """ > > So... I can still run arbitrary erlang commands, how do I stop this? > Unable to find an option to pass in or anything through a quick code > perusal to no avail. Help? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Tue Dec 10 11:21:03 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Tue, 10 Dec 2013 11:21:03 +0100 Subject: [erlang-questions] SSL/TLS distribution In-Reply-To: <1386598043.503864108@f331.i.mail.ru> References: <1386598043.503864108@f331.i.mail.ru> Message-ID: Hi! Have you verified that you can perform the ssl handshake with your input options running just normally without the distribution? Regards Ingela Erlang/OTP team Ericsson AB 2013/12/9 ?????? ?????? > > Hi! > I already asked this question in Basho/node_package/riak, but received no > clear answer. Someone may be encountered such a problem? > > I'm using rebar to build my application, and node_package to create > RPM-package. > Then i define an environment variables in the file vm.ags as described > http://www.erlang.org/doc/apps/ssl/ssl_distribution.html: > -proto_dist inet_tls > -ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" > -ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" > -ssl_dist_opt server_secure_renegotiate true > -ssl_dist_opt client_secure_renegotiate true > And then run: > > [root@REDACTED bin]# myapp start > !!!! > !!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. > !!!! > myapp failed to start within 15 seconds, > see the output of 'myapp console' for more information. > If you want to wait longer, set the environment variable > WAIT_FOR_ERLANG to the number of seconds to wait. > > =========== > In the result I get: > 1. The console log -- all well, as if the node is started correctly. > 2. The error log is empty. > 3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual > machine is running (!). > 4. But: > * Command 'start' -- hangs > * 'ping' is not work > * The node cannot be stopped, because the 'stop' command does not work > * I can't connect to the node through 'attach'/'attach-direct' for the > same reason > * Even 'getpid' says that the node is not running.... > > What could be the problem? > > (Erlang R16B01, RHEL6.3 ) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From igonin_phys@REDACTED Tue Dec 10 11:41:31 2013 From: igonin_phys@REDACTED (=?UTF-8?B?TWlraGFpbCBJZ29uaW4=?=) Date: Tue, 10 Dec 2013 14:41:31 +0400 Subject: [erlang-questions] =?utf-8?q?SSL/TLS_distribution?= In-Reply-To: References: <1386598043.503864108@f331.i.mail.ru> Message-ID: <1386672091.933663871@f397.i.mail.ru> Hello Ingela! Yes, of course. When i disable SSL -- everything is working correctly. With best regards, Mike ???????, 10 ??????? 2013, 11:21 +01:00 ?? Ingela Andin : >Hi! > >Have you verified that you can perform the ssl handshake with your input options running just normally >without the distribution? > >Regards Ingela Erlang/OTP team Ericsson AB > > >2013/12/9 ?????? ?????? < igonin_phys@REDACTED > >> >>Hi! >>I already asked this question in Basho/node_package/riak, but received no clear answer. Someone may be encountered such a problem? >> >>I'm using rebar to build my application, and ?node_package to create RPM-package. >>Then i define an environment variables in the file vm.ags as described? http://www.erlang.org/doc/apps/ssl/ssl_distribution.html : >>-proto_dist inet_tls >>-ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" >>-ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" >>-ssl_dist_opt server_secure_renegotiate true >>-ssl_dist_opt client_secure_renegotiate true >>And then run: >> >>[root@REDACTED bin]# myapp start >>!!!! >>!!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. >>!!!! >>myapp failed to start within 15 seconds, >>see the output of 'myapp console' for more information. >>If you want to wait longer, set the environment variable >>WAIT_FOR_ERLANG to the number of seconds to wait. >> >>=========== >>In the result I get: >>1. The console log -- all well, as if the node is started correctly. >>2. The error log is empty. >>3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual machine is running (!). >>4. But: >>* ?Command 'start' -- hangs >>* ?'ping' is not work >>* ?The node cannot be stopped, because the 'stop' command does not work >>* ?I can't connect to the node through 'attach'/'attach-direct' for the same reason >>* ?Even 'getpid' says that the node is not running.... >> >>What could be the problem? >> >>(Erlang R16B01, RHEL6.3 ) >>_______________________________________________ >>erlang-questions mailing list >>erlang-questions@REDACTED >>http://erlang.org/mailman/listinfo/erlang-questions > From ingela.andin@REDACTED Tue Dec 10 12:31:11 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Tue, 10 Dec 2013 12:31:11 +0100 Subject: [erlang-questions] SSL/TLS distribution In-Reply-To: <1386672091.933663871@f397.i.mail.ru> References: <1386598043.503864108@f331.i.mail.ru> <1386672091.933663871@f397.i.mail.ru> Message-ID: Hi! 2013/12/10 Mikhail Igonin > Hello Ingela! > > Yes, of course. When i disable SSL -- everything is working correctly. > > Well, that is not what I meant, the question is can you start an ssl connection with your certs without running the erlang distribution? Regards Ingela Erlang/OTP team - Ericsson AB > With best regards, > Mike > > ???????, 10 ??????? 2013, 11:21 +01:00 ?? Ingela Andin < > ingela.andin@REDACTED>: > >Hi! > > > >Have you verified that you can perform the ssl handshake with your input > options running just normally > >without the distribution? > > > >Regards Ingela Erlang/OTP team Ericsson AB > > > > > >2013/12/9 ?????? ?????? < igonin_phys@REDACTED > > >> > >>Hi! > >>I already asked this question in Basho/node_package/riak, but received > no clear answer. Someone may be encountered such a problem? > >> > >>I'm using rebar to build my application, and node_package to create > RPM-package. > >>Then i define an environment variables in the file vm.ags as described > http://www.erlang.org/doc/apps/ssl/ssl_distribution.html : > >>-proto_dist inet_tls > >>-ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" > >>-ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" > >>-ssl_dist_opt server_secure_renegotiate true > >>-ssl_dist_opt client_secure_renegotiate true > >>And then run: > >> > >>[root@REDACTED bin]# myapp start > >>!!!! > >>!!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. > >>!!!! > >>myapp failed to start within 15 seconds, > >>see the output of 'myapp console' for more information. > >>If you want to wait longer, set the environment variable > >>WAIT_FOR_ERLANG to the number of seconds to wait. > >> > >>=========== > >>In the result I get: > >>1. The console log -- all well, as if the node is started correctly. > >>2. The error log is empty. > >>3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang > virtual machine is running (!). > >>4. But: > >>* Command 'start' -- hangs > >>* 'ping' is not work > >>* The node cannot be stopped, because the 'stop' command does not work > >>* I can't connect to the node through 'attach'/'attach-direct' for the > same reason > >>* Even 'getpid' says that the node is not running.... > >> > >>What could be the problem? > >> > >>(Erlang R16B01, RHEL6.3 ) > >>_______________________________________________ > >>erlang-questions mailing list > >>erlang-questions@REDACTED > >>http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From igonin_phys@REDACTED Tue Dec 10 15:08:01 2013 From: igonin_phys@REDACTED (=?UTF-8?B?TWlraGFpbCBJZ29uaW4=?=) Date: Tue, 10 Dec 2013 18:08:01 +0400 Subject: [erlang-questions] =?utf-8?q?SSL/TLS_distribution?= In-Reply-To: References: <1386598043.503864108@f331.i.mail.ru> <1386672091.933663871@f397.i.mail.ru> Message-ID: <1386684481.365499325@f91.i.mail.ru> Ok, I'm sorry! I performed the following (if it is not correct, please advise how to make a test): I took my file 'my_app.rel', commented out external applications and created a boot script: [root@REDACTED test ]$ erl Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async threads:10] [hipe] [kernel-poll:false] Eshell V5.10.2 (abort with ^G) 1> systools:make_script("my_app", []). ok Then I ran two erlang nodes with my certificate: erl -boot my_app -proto_dist inet_tls -ssl_dist_opt server_certfile "path_to_pem" -ssl_dist_opt client_certfile " path_to_pem " -ssl_dist_opt server_secure_renegotiate true client_secure_renegotiate true -name my_app1 -setcookie 123 erl -boot my_app -proto_dist inet_tls -ssl_dist_opt server_certfile " path_to_pem " -ssl_dist_opt client_certfile " path_to_pem " -ssl_dist_opt server_secure_renegotiate true client_secure_renegotiate true -name my_app2 -setcookie 123 Finally: (my_app1@REDACTED)1> net_adm:ping('my_app2@REDACTED'). =PROGRESS REPORT==== 10-Dec-2013::17:28:25 === supervisor: {local,inet_gethost_native_sup} started: [{pid,<0.93.0>},{mfa,{inet_gethost_native,init,[[]]}}] =PROGRESS REPORT==== 10-Dec-2013::17:28:25 === supervisor: {local,kernel_safe_sup} started: [{pid,<0.92.0>}, {name,inet_gethost_native_sup}, {mfargs,{inet_gethost_native,start_link,[]}}, {restart_type,temporary}, {shutdown,1000}, {child_type,worker}] pong (my_app1@REDACTED)2> So, i can make a conclusion, that the certificate is correct With best regards, Mike ???????, 10 ??????? 2013, 12:31 +01:00 ?? Ingela Andin : > >Hi! > >2013/12/10 Mikhail Igonin < igonin_phys@REDACTED > >>Hello Ingela! >> >>Yes, of course. When i disable SSL -- everything is working correctly. >> > > >Well, that is not what I meant, the question is can you? start an ssl connection with your certs without running the erlang distribution? > >Regards Ingela Erlang/OTP team - Ericsson AB > > > >? With best regards, >>Mike >> >>???????, 10 ??????? 2013, 11:21 +01:00 ?? Ingela Andin < ingela.andin@REDACTED >: >>>Hi! >>> >>>Have you verified that you can perform the ssl handshake with your input options running just normally >>>without the distribution? >>> >>>Regards Ingela Erlang/OTP team Ericsson AB >>> >>> >>>2013/12/9 ?????? ?????? ?< igonin_phys@REDACTED > >>>> >>>>Hi! >>>>I already asked this question in Basho/node_package/riak, but received no clear answer. Someone may be encountered such a problem? >>>> >>>>I'm using rebar to build my application, and ?node_package to create RPM-package. >>>>Then i define an environment variables in the file vm.ags as described? ? http://www.erlang.org/doc/apps/ssl/ssl_distribution.html : >>>>-proto_dist inet_tls >>>>-ssl_dist_opt client_certfile "/var/lib/myapp/cert.pem" >>>>-ssl_dist_opt server_certfile "/var/lib/myapp/cert.pem" >>>>-ssl_dist_opt server_secure_renegotiate true >>>>-ssl_dist_opt client_secure_renegotiate true >>>>And then run: >>>> >>>>[root@REDACTED bin]# myapp start >>>>!!!! >>>>!!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum. >>>>!!!! >>>>myapp failed to start within 15 seconds, >>>>see the output of 'myapp console' for more information. >>>>If you want to wait longer, set the environment variable >>>>WAIT_FOR_ERLANG to the number of seconds to wait. >>>> >>>>=========== >>>>In the result I get: >>>>1. The console log -- all well, as if the node is started correctly. >>>>2. The error log is empty. >>>>3. The 'ps eax | grep beam.smp' command -- shows, that the Erlang virtual machine is running (!). >>>>4. But: >>>>* ?Command 'start' -- hangs >>>>* ?'ping' is not work >>>>* ?The node cannot be stopped, because the 'stop' command does not work >>>>* ?I can't connect to the node through 'attach'/'attach-direct' for the same reason >>>>* ?Even 'getpid' says that the node is not running.... >>>> >>>>What could be the problem? >>>> >>>>(Erlang R16B01, RHEL6.3 ) >>>>_______________________________________________ >>>>erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> > -- Mikhail Igonin -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Tue Dec 10 15:48:09 2013 From: dgud@REDACTED (Dan Gudmundsson) Date: Tue, 10 Dec 2013 15:48:09 +0100 Subject: [erlang-questions] wxErlang and wxWidgets 3.0 In-Reply-To: References: Message-ID: On Mon, Nov 18, 2013 at 8:52 AM, Sergei Golovan wrote: > Hi Dan, > > On Fri, Nov 15, 2013 at 1:14 PM, Dan Gudmundsson wrote: > > The intention is that is should work with both. But I only test it > > occasionally. > > > > I personally try to link against 3.0, or rather their master branch, when > > doing development. > > Good to hear that. > > > > > But we don't support newer functionality, and some erlang code may need > to > > be rewritten > > to work on both 2.8 and 3.0, btw SUSE 10 and thus wxWidgets 2.6 is still > > used here internally, sigh. > > It's not really about the newer functionality, the old one is fine as > long as it works. > > > > > I have not noticed the notebook problem, don't know if that is a > wxWidgets > > problem or a demo problem. > > I did a closer look at the demos and tried to run applications which > use wxErlang. There are a few minor bugs and one segfault > unfortunately: > > Testing your issues with their master (i.e. to be 3.1) > 1) aui page in demo: after you drag'n'drop tab over the other tab to > rearrange them the latter tab label stops reacting to the mouse clicks > (I can't bring it to the front by clicking on it). See that, the C++ auidemo behaves the same a wxWidgets bug. > 2) choices page in demo: wxChoice control shows empty label on start > (in 2.8 it shows "one"). > > 3) notebook page in demo: Background color is not showed (this one > I've mentioned earlier). > > Same behavoiur in the C++ demo as far as I can see, they are not exactly the same. > 4) Segfault of dialyzer. dialyzer --wx segfaults immediately after I > click any of the "Add", "Add Dir", or "Add Recursively" button. It > works fine with 2.8. > > Your patch have been applied and included in R16B03, thanks. And I will send a bug report on the other issues to wxWidgets. > I don't know if these bugs are wxErlang or wxWidgets bugs though. But > the last one is not good... > > Cheers! > -- > Sergei Golovan > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eli.cohen357@REDACTED Tue Dec 10 16:09:36 2013 From: eli.cohen357@REDACTED (Eli Cohen) Date: Tue, 10 Dec 2013 17:09:36 +0200 Subject: [erlang-questions] Inter nodes messaging bottleneck Message-ID: Hello, I'm facing a bottleneck issue between two nodes. I have several nodes in my cluster, each on different machine. Physical interface between the machines is 10G. On one node I have about 100 processes receiving packets from UDP sockets (~200 sockets) and banging Erlang messages towards a registered process located on remote node (also remote machine). In the reduced scenario the receiving process is a gen_server which does nothing with the messages - just counts the received messages (internal state counter, not a DB). By checking this internal counter I can say that maximum rx rate of this process stands on ~150K messages per second and there is no messages waiting in its queue. Increasing the transmitting node feed does not affect this number and finally the transmitting processes queues start to grow. Just to clarify that these 150K messages are about 120Mbps (over 10G line). Actually I expected to see about 1M. When I'm running these both nodes on same machine - the maximum received messages rate grows to ~400K per second. I've tried to set port parallelism (+spp) flag, increase distribution buffer busy limit (+zdbbl), set kernel poll (+K) - no significant difference. Currently my conclusion is that the bottleneck is somewhere on transmit between nodes. Is there any flags/parameters that may affect this area? Any ideas, comments, help are more than welcomed :-) Thanks, Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From sergej.jurecko@REDACTED Tue Dec 10 16:29:24 2013 From: sergej.jurecko@REDACTED (Sergej Jurecko) Date: Tue, 10 Dec 2013 16:29:24 +0100 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: <9CED5B4E-F9A8-4041-8D59-376F0A5F1475@gmail.com> Why don't you use a public ets table for counting? The number of messages being sent to a process should always be controlled in some way. Sergej On Dec 10, 2013, at 4:09 PM, Eli Cohen wrote: > Hello, > > I'm facing a bottleneck issue between two nodes. > I have several nodes in my cluster, each on different machine. > Physical interface between the machines is 10G. > On one node I have about 100 processes receiving packets from UDP sockets (~200 sockets) and banging Erlang messages towards a registered process located on remote node (also remote machine). > In the reduced scenario the receiving process is a gen_server which does nothing with the messages - just counts the received messages (internal state counter, not a DB). > By checking this internal counter I can say that maximum rx rate of this process stands on ~150K messages per second and there is no messages waiting in its queue. > Increasing the transmitting node feed does not affect this number and finally the transmitting processes queues start to grow. > Just to clarify that these 150K messages are about 120Mbps (over 10G line). Actually I expected to see about 1M. > > When I'm running these both nodes on same machine - the maximum received messages rate grows to ~400K per second. > > I've tried to set port parallelism (+spp) flag, increase distribution buffer busy limit (+zdbbl), set kernel poll (+K) - no significant difference. > > Currently my conclusion is that the bottleneck is somewhere on transmit between nodes. > > Is there any flags/parameters that may affect this area? > > Any ideas, comments, help are more than welcomed :-) > Thanks, > Eli > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From jon@REDACTED Tue Dec 10 16:30:56 2013 From: jon@REDACTED (Jon Schneider) Date: Tue, 10 Dec 2013 15:30:56 -0000 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: > Any ideas, comments, help are more than welcomed :-) Take a _short_ snapshot of your network traffic at either end. Could it be the TCP window or network buffers ? Jon From valentin@REDACTED Tue Dec 10 16:43:27 2013 From: valentin@REDACTED (Valentin Micic) Date: Tue, 10 Dec 2013 17:43:27 +0200 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: <2D5400E0-CB66-40D8-A0C0-BA925B166743@pixie.co.za> Hi Eli, If you're sending more then you're receiving whilst using UDP as a transport, best bet would be to increase tx and rx buffers on the UDP socket? but then again, I am confused as to why are you using 200 UDP sockets -- care to share your reason for that? Kind regards V/ On 10 Dec 2013, at 5:09 PM, Eli Cohen wrote: > Hello, > > I'm facing a bottleneck issue between two nodes. > I have several nodes in my cluster, each on different machine. > Physical interface between the machines is 10G. > On one node I have about 100 processes receiving packets from UDP sockets (~200 sockets) and banging Erlang messages towards a registered process located on remote node (also remote machine). > In the reduced scenario the receiving process is a gen_server which does nothing with the messages - just counts the received messages (internal state counter, not a DB). > By checking this internal counter I can say that maximum rx rate of this process stands on ~150K messages per second and there is no messages waiting in its queue. > Increasing the transmitting node feed does not affect this number and finally the transmitting processes queues start to grow. > Just to clarify that these 150K messages are about 120Mbps (over 10G line). Actually I expected to see about 1M. > > When I'm running these both nodes on same machine - the maximum received messages rate grows to ~400K per second. > > I've tried to set port parallelism (+spp) flag, increase distribution buffer busy limit (+zdbbl), set kernel poll (+K) - no significant difference. > > Currently my conclusion is that the bottleneck is somewhere on transmit between nodes. > > Is there any flags/parameters that may affect this area? > > Any ideas, comments, help are more than welcomed :-) > Thanks, > Eli > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From jesper.louis.andersen@REDACTED Tue Dec 10 16:52:30 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 10 Dec 2013 16:52:30 +0100 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: On Tue, Dec 10, 2013 at 4:09 PM, Eli Cohen wrote: > Is there any flags/parameters that may affect this area? First thing: Verify that you can actually get the bandwidth you assume between the two nodes in a raw transmit without any Erlang in between. Secondly, look at the TCP connection between the two machines. On a 10Gig interface, it is often the case you need to tune the kernel and the network card a bit before you can push data flawlessly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jakobce@REDACTED Tue Dec 10 18:20:57 2013 From: jakobce@REDACTED (Jakob Cederlund) Date: Tue, 10 Dec 2013 18:20:57 +0100 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Actually, the sample cli module works quite all right. The problem is that the default implementation in ssh_cli for the "exec" thing in ssh is actually to execute it (using erl_scan and erl_eval and stuff). There is an undocumented option to ssh (actually to the ssh_cli module) that can be used to customize this. The option {exec, {M, F, []}} takes an exported function (M:F/1) that is called with the parameters given to the ssh commands as a string. This function should spawn a process that writes the desired output on stdout. So to avoid the strange eval phenomenon, and provide another function that just echoes the parameters back, you can write a module x: -module(x). -export([exec/1]). exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). and specify the function x:exec/1 as a call-back for the exec option: B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). And then when you do: > ssh -p 8323 to.the.host 'lists:reverse("test").' You get back: "list:reverse(\"test\")." Hope this helps. (And sorry for the mess?) /Jakob 2013/12/10 Ingela Andin > Hi! > > The CLI example in the SSH application must be seen as a hack. We intend > to clean it up and > extend the SSH documentation, when it gets prioritized I can not say. Well > anyway your CLI > implementation must take care of SSH exec request as well. You can also > look at the ssh_cli.erl module. > If I remember correctly there was a bug, before ssh-2.1.7, with regards to > the exec request so that it was not forwarded to CLI process but rather > always interpreted in the erlang shell environment. > > Regards Ingela Erlang/OTP team - Ericsson AB > > > > 2013/12/7 OvermindDL1 > >> Greetings, >> >> I am attempting to just create an SSH shell to connect to a system by >> users so they can do commands without the web interface, and as such I >> certainly do not want things like port forwarding or being able to run >> arbitrary erlang code, however I do not seem to be able to disable >> running arbitrary erlang code. An example of the ssh_sample_cli >> included with erlang: >> """ >> $ erl >> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >> [async-threads:10] [hipe] [kernel-poll:false] >> >> Eshell V5.10.3 (abort with ^G) >> 1> c(ssh_sample_cli). >> ssh_sample_cli.erl:146: Warning: this expression will fail with a >> 'badarith' exception >> {ok,ssh_sample_cli} >> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >> {ok,<0.67.0>} >> """ >> >> And from another shell/computer: >> """ >> $ ssh -p 8321 to.the.host >> myusername@REDACTED's password: >> Enter command >> CLI> help >> CLI Sample >> crash crash the cli >> exit exit application >> factors prime factors of >> gcd greatest common divisor >> help help text >> host print host addr >> lcm least common multiplier >> prime check for primality >> primes print all primes up to >> rho prime factors using rho's alg. >> self print my pid >> user print name of user >> >> ---> ok >> CLI> exit >> ---> done >> Connection to to.the.host closed. >> """ >> >> So far so good (the main program where I have this implemented has a >> well running shell of its own), but lets try a couple other things: >> """ >> $ sftp -P 8321 to.the.host >> myusername@REDACTED's password: >> subsystem request failed on channel 0 >> Connection closed >> """ >> >> Also good, no file transfers can be done since the option subsystem is >> set to [], but notice: >> """ >> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >> gnineppah si tahw woN").' >> myusername@REDACTED's password: >> "Now what is happening here and how do I stop it?!" >> """ >> >> So... I can still run arbitrary erlang commands, how do I stop this? >> Unable to find an option to pass in or anything through a quick code >> perusal to no avail. Help? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Tue Dec 10 22:22:36 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Tue, 10 Dec 2013 14:22:36 -0700 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Ah all you are amazing, I never saw that option in the docs indeed and looks like it should do what I want. Thanks much for all the help! On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund wrote: > Actually, the sample cli module works quite all right. The problem is that > the default implementation in ssh_cli for the "exec" thing in ssh is > actually to execute it (using erl_scan and erl_eval and stuff). There is an > undocumented option to ssh (actually to the ssh_cli module) that can be used > to customize this. The option {exec, {M, F, []}} takes an exported function > (M:F/1) that is called with the parameters given to the ssh commands as a > string. This function should spawn a process that writes the desired output > on stdout. > > So to avoid the strange eval phenomenon, and provide another function that > just echoes the parameters back, you can write a module x: > -module(x). > -export([exec/1]). > exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). > > and specify the function x:exec/1 as a call-back for the exec option: > B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). > > And then when you do: >> ssh -p 8323 to.the.host 'lists:reverse("test").' > > You get back: > "list:reverse(\"test\")." > > Hope this helps. (And sorry for the mess?) > /Jakob > > > > 2013/12/10 Ingela Andin >> >> Hi! >> >> The CLI example in the SSH application must be seen as a hack. We intend >> to clean it up and >> extend the SSH documentation, when it gets prioritized I can not say. Well >> anyway your CLI >> implementation must take care of SSH exec request as well. You can also >> look at the ssh_cli.erl module. >> If I remember correctly there was a bug, before ssh-2.1.7, with regards to >> the exec request so that it was not forwarded to CLI process but rather >> always interpreted in the erlang shell environment. >> >> Regards Ingela Erlang/OTP team - Ericsson AB >> >> >> >> 2013/12/7 OvermindDL1 >>> >>> Greetings, >>> >>> I am attempting to just create an SSH shell to connect to a system by >>> users so they can do commands without the web interface, and as such I >>> certainly do not want things like port forwarding or being able to run >>> arbitrary erlang code, however I do not seem to be able to disable >>> running arbitrary erlang code. An example of the ssh_sample_cli >>> included with erlang: >>> """ >>> $ erl >>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >>> [async-threads:10] [hipe] [kernel-poll:false] >>> >>> Eshell V5.10.3 (abort with ^G) >>> 1> c(ssh_sample_cli). >>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >>> 'badarith' exception >>> {ok,ssh_sample_cli} >>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >>> {ok,<0.67.0>} >>> """ >>> >>> And from another shell/computer: >>> """ >>> $ ssh -p 8321 to.the.host >>> myusername@REDACTED's password: >>> Enter command >>> CLI> help >>> CLI Sample >>> crash crash the cli >>> exit exit application >>> factors prime factors of >>> gcd greatest common divisor >>> help help text >>> host print host addr >>> lcm least common multiplier >>> prime check for primality >>> primes print all primes up to >>> rho prime factors using rho's alg. >>> self print my pid >>> user print name of user >>> >>> ---> ok >>> CLI> exit >>> ---> done >>> Connection to to.the.host closed. >>> """ >>> >>> So far so good (the main program where I have this implemented has a >>> well running shell of its own), but lets try a couple other things: >>> """ >>> $ sftp -P 8321 to.the.host >>> myusername@REDACTED's password: >>> subsystem request failed on channel 0 >>> Connection closed >>> """ >>> >>> Also good, no file transfers can be done since the option subsystem is >>> set to [], but notice: >>> """ >>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >>> gnineppah si tahw woN").' >>> myusername@REDACTED's password: >>> "Now what is happening here and how do I stop it?!" >>> """ >>> >>> So... I can still run arbitrary erlang commands, how do I stop this? >>> Unable to find an option to pass in or anything through a quick code >>> perusal to no avail. Help? >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > From overminddl1@REDACTED Tue Dec 10 22:26:22 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Tue, 10 Dec 2013 14:26:22 -0700 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Another question while I am at it with this exec option, the 'shell' option gets a User and PeerAddr passed in, any way to do that with exec? If I can at least get the User then I can allow them to issue one-off commands this way too, which would be quite useful for remote scripting. On Tue, Dec 10, 2013 at 2:22 PM, OvermindDL1 wrote: > Ah all you are amazing, I never saw that option in the docs indeed and > looks like it should do what I want. Thanks much for all the help! > > On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund wrote: >> Actually, the sample cli module works quite all right. The problem is that >> the default implementation in ssh_cli for the "exec" thing in ssh is >> actually to execute it (using erl_scan and erl_eval and stuff). There is an >> undocumented option to ssh (actually to the ssh_cli module) that can be used >> to customize this. The option {exec, {M, F, []}} takes an exported function >> (M:F/1) that is called with the parameters given to the ssh commands as a >> string. This function should spawn a process that writes the desired output >> on stdout. >> >> So to avoid the strange eval phenomenon, and provide another function that >> just echoes the parameters back, you can write a module x: >> -module(x). >> -export([exec/1]). >> exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). >> >> and specify the function x:exec/1 as a call-back for the exec option: >> B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). >> >> And then when you do: >>> ssh -p 8323 to.the.host 'lists:reverse("test").' >> >> You get back: >> "list:reverse(\"test\")." >> >> Hope this helps. (And sorry for the mess?) >> /Jakob >> >> >> >> 2013/12/10 Ingela Andin >>> >>> Hi! >>> >>> The CLI example in the SSH application must be seen as a hack. We intend >>> to clean it up and >>> extend the SSH documentation, when it gets prioritized I can not say. Well >>> anyway your CLI >>> implementation must take care of SSH exec request as well. You can also >>> look at the ssh_cli.erl module. >>> If I remember correctly there was a bug, before ssh-2.1.7, with regards to >>> the exec request so that it was not forwarded to CLI process but rather >>> always interpreted in the erlang shell environment. >>> >>> Regards Ingela Erlang/OTP team - Ericsson AB >>> >>> >>> >>> 2013/12/7 OvermindDL1 >>>> >>>> Greetings, >>>> >>>> I am attempting to just create an SSH shell to connect to a system by >>>> users so they can do commands without the web interface, and as such I >>>> certainly do not want things like port forwarding or being able to run >>>> arbitrary erlang code, however I do not seem to be able to disable >>>> running arbitrary erlang code. An example of the ssh_sample_cli >>>> included with erlang: >>>> """ >>>> $ erl >>>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >>>> [async-threads:10] [hipe] [kernel-poll:false] >>>> >>>> Eshell V5.10.3 (abort with ^G) >>>> 1> c(ssh_sample_cli). >>>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >>>> 'badarith' exception >>>> {ok,ssh_sample_cli} >>>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >>>> {ok,<0.67.0>} >>>> """ >>>> >>>> And from another shell/computer: >>>> """ >>>> $ ssh -p 8321 to.the.host >>>> myusername@REDACTED's password: >>>> Enter command >>>> CLI> help >>>> CLI Sample >>>> crash crash the cli >>>> exit exit application >>>> factors prime factors of >>>> gcd greatest common divisor >>>> help help text >>>> host print host addr >>>> lcm least common multiplier >>>> prime check for primality >>>> primes print all primes up to >>>> rho prime factors using rho's alg. >>>> self print my pid >>>> user print name of user >>>> >>>> ---> ok >>>> CLI> exit >>>> ---> done >>>> Connection to to.the.host closed. >>>> """ >>>> >>>> So far so good (the main program where I have this implemented has a >>>> well running shell of its own), but lets try a couple other things: >>>> """ >>>> $ sftp -P 8321 to.the.host >>>> myusername@REDACTED's password: >>>> subsystem request failed on channel 0 >>>> Connection closed >>>> """ >>>> >>>> Also good, no file transfers can be done since the option subsystem is >>>> set to [], but notice: >>>> """ >>>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >>>> gnineppah si tahw woN").' >>>> myusername@REDACTED's password: >>>> "Now what is happening here and how do I stop it?!" >>>> """ >>>> >>>> So... I can still run arbitrary erlang commands, how do I stop this? >>>> Unable to find an option to pass in or anything through a quick code >>>> perusal to no avail. Help? >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> From overminddl1@REDACTED Tue Dec 10 23:15:12 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Tue, 10 Dec 2013 15:15:12 -0700 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Nevermind, and for future documentation I found this in ssh_cli.erl: ``` start_shell(_ConnectionHandler, Cmd, #state{exec={M, F, A}} = State) -> Group = group:start(self(), {M, F, A++[Cmd]}, [{echo, false}]), State#state{group = Group, buf = empty_buf()}; start_shell(ConnectionHandler, Cmd, #state{exec=Shell} = State) when is_function(Shell) -> ConnectionInfo = ssh_connection_handler:info(ConnectionHandler, [peer, user]), {ok, User} = proplists:get_value(user, ConnectionInfo), ShellFun = case erlang:fun_info(Shell, arity) of {arity, 1} -> fun() -> Shell(Cmd) end; {arity, 2} -> fun() -> Shell(Cmd, User) end; {arity, 3} -> [{_, PeerAddr}] = proplists:get_value(peer, ConnectionInfo), fun() -> Shell(Cmd, User, PeerAddr) end; _ -> Shell end, Echo = get_echo(State#state.pty), Group = group:start(self(), ShellFun, [{echo,Echo}]), State#state{group = Group, buf = empty_buf()}. ``` The exec property of the state record is set on init, so I figured I could just pass in a fun instead like I can the shell option: ``` {error,{eoptions,{exec,#Fun}} ``` Nope. But yet it looks like it should accept a fun fine, so... what is going on. I take a look at where ssh_cli is called and found this in ssh_connection_handler.erl: ``` Shell = proplists:get_value(shell, Opts), Exec = proplists:get_value(exec, Opts), CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), State#state{starter = Pid, connection_state = Connection#connection{ cli_spec = CliSpec, exec = Exec, system_supervisor = SystemSup, sub_system_supervisor = SubSystemSup, connection_supervisor = ConnectionSup }}. ``` So, it seems the exec is set here as an option to the connection state, and the exec is filtered on this in ssh.erl: ``` handle_ssh_option({exec, {Module, Function, _}} = Opt) when is_atom(Module), is_atom(Function) -> Opt; ``` And that looks like it should work, but wait, remember what I said about exec only being set on init in ssh_cli.erl, and look at the line above that sets the default ssh_cli option: ``` CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), ``` Hmm, so it never sets the exec option in the ssh_cli, if it did then it should actually be calling: ``` CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell, Exec]}), ``` Yet it is not. So I removed my shell and exec options from ssh:daemon and replaced it with a single option of: ``` {ssh_cli, {ssh_cli, [ fun(User, PeerAddr) -> msw_ssh_server_shell:start(User, PeerAddr) end, fun(Cmd, User, PeerAddr) -> msw_ssh_server_shell:exec(Cmd, User, PeerAddr) end]}}, ``` And badda bing it works. I am not sure if this is the 'proper' way to do it (and I would love to learn of a proper way if it exists), but it works with both setting a shell, exec, and getting the User and PeerAddress in both cases as well. On Tue, Dec 10, 2013 at 2:26 PM, OvermindDL1 wrote: > Another question while I am at it with this exec option, the 'shell' > option gets a User and PeerAddr passed in, any way to do that with > exec? If I can at least get the User then I can allow them to issue > one-off commands this way too, which would be quite useful for remote > scripting. > > On Tue, Dec 10, 2013 at 2:22 PM, OvermindDL1 wrote: >> Ah all you are amazing, I never saw that option in the docs indeed and >> looks like it should do what I want. Thanks much for all the help! >> >> On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund wrote: >>> Actually, the sample cli module works quite all right. The problem is that >>> the default implementation in ssh_cli for the "exec" thing in ssh is >>> actually to execute it (using erl_scan and erl_eval and stuff). There is an >>> undocumented option to ssh (actually to the ssh_cli module) that can be used >>> to customize this. The option {exec, {M, F, []}} takes an exported function >>> (M:F/1) that is called with the parameters given to the ssh commands as a >>> string. This function should spawn a process that writes the desired output >>> on stdout. >>> >>> So to avoid the strange eval phenomenon, and provide another function that >>> just echoes the parameters back, you can write a module x: >>> -module(x). >>> -export([exec/1]). >>> exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). >>> >>> and specify the function x:exec/1 as a call-back for the exec option: >>> B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). >>> >>> And then when you do: >>>> ssh -p 8323 to.the.host 'lists:reverse("test").' >>> >>> You get back: >>> "list:reverse(\"test\")." >>> >>> Hope this helps. (And sorry for the mess?) >>> /Jakob >>> >>> >>> >>> 2013/12/10 Ingela Andin >>>> >>>> Hi! >>>> >>>> The CLI example in the SSH application must be seen as a hack. We intend >>>> to clean it up and >>>> extend the SSH documentation, when it gets prioritized I can not say. Well >>>> anyway your CLI >>>> implementation must take care of SSH exec request as well. You can also >>>> look at the ssh_cli.erl module. >>>> If I remember correctly there was a bug, before ssh-2.1.7, with regards to >>>> the exec request so that it was not forwarded to CLI process but rather >>>> always interpreted in the erlang shell environment. >>>> >>>> Regards Ingela Erlang/OTP team - Ericsson AB >>>> >>>> >>>> >>>> 2013/12/7 OvermindDL1 >>>>> >>>>> Greetings, >>>>> >>>>> I am attempting to just create an SSH shell to connect to a system by >>>>> users so they can do commands without the web interface, and as such I >>>>> certainly do not want things like port forwarding or being able to run >>>>> arbitrary erlang code, however I do not seem to be able to disable >>>>> running arbitrary erlang code. An example of the ssh_sample_cli >>>>> included with erlang: >>>>> """ >>>>> $ erl >>>>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >>>>> [async-threads:10] [hipe] [kernel-poll:false] >>>>> >>>>> Eshell V5.10.3 (abort with ^G) >>>>> 1> c(ssh_sample_cli). >>>>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >>>>> 'badarith' exception >>>>> {ok,ssh_sample_cli} >>>>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >>>>> {ok,<0.67.0>} >>>>> """ >>>>> >>>>> And from another shell/computer: >>>>> """ >>>>> $ ssh -p 8321 to.the.host >>>>> myusername@REDACTED's password: >>>>> Enter command >>>>> CLI> help >>>>> CLI Sample >>>>> crash crash the cli >>>>> exit exit application >>>>> factors prime factors of >>>>> gcd greatest common divisor >>>>> help help text >>>>> host print host addr >>>>> lcm least common multiplier >>>>> prime check for primality >>>>> primes print all primes up to >>>>> rho prime factors using rho's alg. >>>>> self print my pid >>>>> user print name of user >>>>> >>>>> ---> ok >>>>> CLI> exit >>>>> ---> done >>>>> Connection to to.the.host closed. >>>>> """ >>>>> >>>>> So far so good (the main program where I have this implemented has a >>>>> well running shell of its own), but lets try a couple other things: >>>>> """ >>>>> $ sftp -P 8321 to.the.host >>>>> myusername@REDACTED's password: >>>>> subsystem request failed on channel 0 >>>>> Connection closed >>>>> """ >>>>> >>>>> Also good, no file transfers can be done since the option subsystem is >>>>> set to [], but notice: >>>>> """ >>>>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >>>>> gnineppah si tahw woN").' >>>>> myusername@REDACTED's password: >>>>> "Now what is happening here and how do I stop it?!" >>>>> """ >>>>> >>>>> So... I can still run arbitrary erlang commands, how do I stop this? >>>>> Unable to find an option to pass in or anything through a quick code >>>>> perusal to no avail. Help? >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>> From overminddl1@REDACTED Tue Dec 10 23:26:54 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Tue, 10 Dec 2013 15:26:54 -0700 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Be calling the option with Exec added to it with a fixed handle_ssh_option test to test for if a fun as well. On Tue, Dec 10, 2013 at 3:15 PM, OvermindDL1 wrote: > Nevermind, and for future documentation I found this in ssh_cli.erl: > ``` > start_shell(_ConnectionHandler, Cmd, #state{exec={M, F, A}} = State) -> > Group = group:start(self(), {M, F, A++[Cmd]}, [{echo, false}]), > State#state{group = Group, buf = empty_buf()}; > start_shell(ConnectionHandler, Cmd, #state{exec=Shell} = State) when > is_function(Shell) -> > > ConnectionInfo = ssh_connection_handler:info(ConnectionHandler, > [peer, user]), > {ok, User} = > proplists:get_value(user, ConnectionInfo), > ShellFun = > case erlang:fun_info(Shell, arity) of > {arity, 1} -> > fun() -> Shell(Cmd) end; > {arity, 2} -> > fun() -> Shell(Cmd, User) end; > {arity, 3} -> > [{_, PeerAddr}] = > proplists:get_value(peer, ConnectionInfo), > fun() -> Shell(Cmd, User, PeerAddr) end; > _ -> > Shell > end, > Echo = get_echo(State#state.pty), > Group = group:start(self(), ShellFun, [{echo,Echo}]), > State#state{group = Group, buf = empty_buf()}. > ``` > The exec property of the state record is set on init, so I figured I > could just pass in a fun instead like I can the shell option: > ``` > {error,{eoptions,{exec,#Fun}} > ``` > Nope. But yet it looks like it should accept a fun fine, so... what > is going on. > I take a look at where ssh_cli is called and found this in > ssh_connection_handler.erl: > ``` > Shell = proplists:get_value(shell, Opts), > Exec = proplists:get_value(exec, Opts), > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), > State#state{starter = Pid, connection_state = Connection#connection{ > cli_spec = CliSpec, > exec = Exec, > system_supervisor > = SystemSup, > > sub_system_supervisor = SubSystemSup, > > connection_supervisor = ConnectionSup > }}. > ``` > So, it seems the exec is set here as an option to the connection > state, and the exec is filtered on this in ssh.erl: > ``` > > handle_ssh_option({exec, {Module, Function, _}} = Opt) when is_atom(Module), > is_atom(Function) -> > > Opt; > ``` > And that looks like it should work, but wait, remember what I said > about exec only being set on init in ssh_cli.erl, and look at the line > above that sets the default ssh_cli option: > ``` > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), > ``` > Hmm, so it never sets the exec option in the ssh_cli, if it did then > it should actually be calling: > ``` > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell, Exec]}), > ``` > Yet it is not. So I removed my shell and exec options from ssh:daemon > and replaced it with a single option of: > ``` > {ssh_cli, {ssh_cli, [ > fun(User, PeerAddr) -> msw_ssh_server_shell:start(User, PeerAddr) end, > fun(Cmd, User, PeerAddr) -> msw_ssh_server_shell:exec(Cmd, > User, PeerAddr) end]}}, > ``` > And badda bing it works. I am not sure if this is the 'proper' way to > do it (and I would love to learn of a proper way if it exists), but it > works with both setting a shell, exec, and getting the User and > PeerAddress in both cases as well. > > On Tue, Dec 10, 2013 at 2:26 PM, OvermindDL1 wrote: >> Another question while I am at it with this exec option, the 'shell' >> option gets a User and PeerAddr passed in, any way to do that with >> exec? If I can at least get the User then I can allow them to issue >> one-off commands this way too, which would be quite useful for remote >> scripting. >> >> On Tue, Dec 10, 2013 at 2:22 PM, OvermindDL1 wrote: >>> Ah all you are amazing, I never saw that option in the docs indeed and >>> looks like it should do what I want. Thanks much for all the help! >>> >>> On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund wrote: >>>> Actually, the sample cli module works quite all right. The problem is that >>>> the default implementation in ssh_cli for the "exec" thing in ssh is >>>> actually to execute it (using erl_scan and erl_eval and stuff). There is an >>>> undocumented option to ssh (actually to the ssh_cli module) that can be used >>>> to customize this. The option {exec, {M, F, []}} takes an exported function >>>> (M:F/1) that is called with the parameters given to the ssh commands as a >>>> string. This function should spawn a process that writes the desired output >>>> on stdout. >>>> >>>> So to avoid the strange eval phenomenon, and provide another function that >>>> just echoes the parameters back, you can write a module x: >>>> -module(x). >>>> -export([exec/1]). >>>> exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). >>>> >>>> and specify the function x:exec/1 as a call-back for the exec option: >>>> B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). >>>> >>>> And then when you do: >>>>> ssh -p 8323 to.the.host 'lists:reverse("test").' >>>> >>>> You get back: >>>> "list:reverse(\"test\")." >>>> >>>> Hope this helps. (And sorry for the mess?) >>>> /Jakob >>>> >>>> >>>> >>>> 2013/12/10 Ingela Andin >>>>> >>>>> Hi! >>>>> >>>>> The CLI example in the SSH application must be seen as a hack. We intend >>>>> to clean it up and >>>>> extend the SSH documentation, when it gets prioritized I can not say. Well >>>>> anyway your CLI >>>>> implementation must take care of SSH exec request as well. You can also >>>>> look at the ssh_cli.erl module. >>>>> If I remember correctly there was a bug, before ssh-2.1.7, with regards to >>>>> the exec request so that it was not forwarded to CLI process but rather >>>>> always interpreted in the erlang shell environment. >>>>> >>>>> Regards Ingela Erlang/OTP team - Ericsson AB >>>>> >>>>> >>>>> >>>>> 2013/12/7 OvermindDL1 >>>>>> >>>>>> Greetings, >>>>>> >>>>>> I am attempting to just create an SSH shell to connect to a system by >>>>>> users so they can do commands without the web interface, and as such I >>>>>> certainly do not want things like port forwarding or being able to run >>>>>> arbitrary erlang code, however I do not seem to be able to disable >>>>>> running arbitrary erlang code. An example of the ssh_sample_cli >>>>>> included with erlang: >>>>>> """ >>>>>> $ erl >>>>>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >>>>>> [async-threads:10] [hipe] [kernel-poll:false] >>>>>> >>>>>> Eshell V5.10.3 (abort with ^G) >>>>>> 1> c(ssh_sample_cli). >>>>>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >>>>>> 'badarith' exception >>>>>> {ok,ssh_sample_cli} >>>>>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >>>>>> {ok,<0.67.0>} >>>>>> """ >>>>>> >>>>>> And from another shell/computer: >>>>>> """ >>>>>> $ ssh -p 8321 to.the.host >>>>>> myusername@REDACTED's password: >>>>>> Enter command >>>>>> CLI> help >>>>>> CLI Sample >>>>>> crash crash the cli >>>>>> exit exit application >>>>>> factors prime factors of >>>>>> gcd greatest common divisor >>>>>> help help text >>>>>> host print host addr >>>>>> lcm least common multiplier >>>>>> prime check for primality >>>>>> primes print all primes up to >>>>>> rho prime factors using rho's alg. >>>>>> self print my pid >>>>>> user print name of user >>>>>> >>>>>> ---> ok >>>>>> CLI> exit >>>>>> ---> done >>>>>> Connection to to.the.host closed. >>>>>> """ >>>>>> >>>>>> So far so good (the main program where I have this implemented has a >>>>>> well running shell of its own), but lets try a couple other things: >>>>>> """ >>>>>> $ sftp -P 8321 to.the.host >>>>>> myusername@REDACTED's password: >>>>>> subsystem request failed on channel 0 >>>>>> Connection closed >>>>>> """ >>>>>> >>>>>> Also good, no file transfers can be done since the option subsystem is >>>>>> set to [], but notice: >>>>>> """ >>>>>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >>>>>> gnineppah si tahw woN").' >>>>>> myusername@REDACTED's password: >>>>>> "Now what is happening here and how do I stop it?!" >>>>>> """ >>>>>> >>>>>> So... I can still run arbitrary erlang commands, how do I stop this? >>>>>> Unable to find an option to pass in or anything through a quick code >>>>>> perusal to no avail. Help? >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> From eli.cohen357@REDACTED Wed Dec 11 08:16:01 2013 From: eli.cohen357@REDACTED (Eli Cohen) Date: Wed, 11 Dec 2013 09:16:01 +0200 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: Hi all, First, thank you all for your inputs. I'll try to address all the inputs here: Regarding the network and the interface: I've tested the network configuration and the interface between the machines using iperf tool: I've reach about 8Gbits bandwidth. I've checked my net.core and net.ipv4.tcp_X configuration and it seems OK. I also tried to reduce the window size and run parallel connections - in the worst case scenario I've reached about 2.5Gbits throughput between the machines. To remind you I'm talking about ~120Mbits bottleneck. Regarding the number of UDP sockets: The requests to start receiving data dynamic. Each data flow may be received from several UDP ports. My way to implement it was dynamically create processes when each may create several gen_udp's to listen on. This was my way to implement it. I'll be happy to hear another ideas. To remind you, when I'm moving the receiving machine - the throughput between the nodes is doubled. (which is still low, but it proves that the UDP sockets are not the bottleneck - at least not the original 120Mbits bottleneck). Regarding the counter: This is only a helper for debugging this issue. I've mentioned the counter to clarify that this is the only activity done in the receiving process (dst node). For my understanding storing this counter in internal gen_server State record is the cheapest way to realize it. Please advice, Thanks again 2013/12/10 Jesper Louis Andersen > > On Tue, Dec 10, 2013 at 4:09 PM, Eli Cohen wrote: > >> Is there any flags/parameters that may affect this area? > > > First thing: Verify that you can actually get the bandwidth you assume > between the two nodes in a raw transmit without any Erlang in between. > > Secondly, look at the TCP connection between the two machines. On a 10Gig > interface, it is often the case you need to tune the kernel and the network > card a bit before you can push data flawlessly. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From valentin@REDACTED Wed Dec 11 09:01:02 2013 From: valentin@REDACTED (Valentin Micic) Date: Wed, 11 Dec 2013 10:01:02 +0200 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: > To remind you, when I'm moving the receiving machine - the throughput between the nodes is doubled. (which is still low, but it proves that the UDP sockets are not the bottleneck - Not sure what does "moving the receiving machine" mean and how does it prove that UDP sockets are not bottleneck. Care to elaborate? As for number of UDP sockets you're using: at some point you will face the curse of diminishing returns. In my view, assuming that you've written an ideal server (*) and have adequate receiving buffer sizes, a number of cooperating UDP sockets (e.g. sockets offering the same service) should not exceed the number of CPU's used by Erlang run-time (in other words number of Erlang schedulers). Could you share what kind of "socket activity" you're using with your server: {active, true}, {active, false} or {active, once}? V/ (*) A server that has zero processing time. From ingela.andin@REDACTED Wed Dec 11 09:17:14 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Wed, 11 Dec 2013 09:17:14 +0100 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Hi! 2013/12/10 Jakob Cederlund > Actually, the sample cli module works quite all right. > The problem with it is that it was written a long time ago, before the today documented API was set. And until we have had time to look it over and make it part of the documented examples of the users guide it must be considered a hack. Also in the upcoming release of the ssh application the internals of ssh has changed quite a bit. And although ssh is still fully backwards compatible with every documented aspect of the application some very early never documented aspects may not work anymore. There also exists some undocumented features that we intend to document in the future. Regards Ingela Erlang/OTP team - Ericsson AB The problem is that the default implementation in ssh_cli for the "exec" > thing in ssh is actually to execute it (using erl_scan and erl_eval and > stuff). There is an undocumented option to ssh (actually to the ssh_cli > module) that can be used to customize this. The option {exec, {M, F, []}}takes an exported function (M:F/1) that is called with the parameters given > to the ssh commands as a string. This function should spawn a process that > writes the desired output on stdout. > > So to avoid the strange eval phenomenon, and provide another function that > just echoes the parameters back, you can write a module x: > -module(x). > -export([exec/1]). > exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). > > and specify the function x:exec/1 as a call-back for the exec option: > B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). > > And then when you do: > > ssh -p 8323 to.the.host 'lists:reverse("test").' > > You get back: > "list:reverse(\"test\")." > > Hope this helps. (And sorry for the mess?) > /Jakob > > > > 2013/12/10 Ingela Andin > >> Hi! >> >> The CLI example in the SSH application must be seen as a hack. We intend >> to clean it up and >> extend the SSH documentation, when it gets prioritized I can not say. >> Well anyway your CLI >> implementation must take care of SSH exec request as well. You can also >> look at the ssh_cli.erl module. >> If I remember correctly there was a bug, before ssh-2.1.7, with regards >> to the exec request so that it was not forwarded to CLI process but >> rather always interpreted in the erlang shell environment. >> >> Regards Ingela Erlang/OTP team - Ericsson AB >> >> >> >> 2013/12/7 OvermindDL1 >> >>> Greetings, >>> >>> I am attempting to just create an SSH shell to connect to a system by >>> users so they can do commands without the web interface, and as such I >>> certainly do not want things like port forwarding or being able to run >>> arbitrary erlang code, however I do not seem to be able to disable >>> running arbitrary erlang code. An example of the ssh_sample_cli >>> included with erlang: >>> """ >>> $ erl >>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >>> [async-threads:10] [hipe] [kernel-poll:false] >>> >>> Eshell V5.10.3 (abort with ^G) >>> 1> c(ssh_sample_cli). >>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >>> 'badarith' exception >>> {ok,ssh_sample_cli} >>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >>> {ok,<0.67.0>} >>> """ >>> >>> And from another shell/computer: >>> """ >>> $ ssh -p 8321 to.the.host >>> myusername@REDACTED's password: >>> Enter command >>> CLI> help >>> CLI Sample >>> crash crash the cli >>> exit exit application >>> factors prime factors of >>> gcd greatest common divisor >>> help help text >>> host print host addr >>> lcm least common multiplier >>> prime check for primality >>> primes print all primes up to >>> rho prime factors using rho's alg. >>> self print my pid >>> user print name of user >>> >>> ---> ok >>> CLI> exit >>> ---> done >>> Connection to to.the.host closed. >>> """ >>> >>> So far so good (the main program where I have this implemented has a >>> well running shell of its own), but lets try a couple other things: >>> """ >>> $ sftp -P 8321 to.the.host >>> myusername@REDACTED's password: >>> subsystem request failed on channel 0 >>> Connection closed >>> """ >>> >>> Also good, no file transfers can be done since the option subsystem is >>> set to [], but notice: >>> """ >>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna ereh >>> gnineppah si tahw woN").' >>> myusername@REDACTED's password: >>> "Now what is happening here and how do I stop it?!" >>> """ >>> >>> So... I can still run arbitrary erlang commands, how do I stop this? >>> Unable to find an option to pass in or anything through a quick code >>> perusal to no avail. Help? >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Wed Dec 11 09:25:28 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Wed, 11 Dec 2013 09:25:28 +0100 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: Hi! As I mentioned in my previous post, ssh will change quite a lot in the upcoming release so please try it when it comes and let me now if there are any further improvements that you need. Regards Ingela Erlang/OTP team - Ericsson AB 2013/12/10 OvermindDL1 > Be calling the option with Exec added to it with a fixed > handle_ssh_option test to test for if a fun as well. > > On Tue, Dec 10, 2013 at 3:15 PM, OvermindDL1 > wrote: > > Nevermind, and for future documentation I found this in ssh_cli.erl: > > ``` > > start_shell(_ConnectionHandler, Cmd, #state{exec={M, F, A}} = State) -> > > Group = group:start(self(), {M, F, A++[Cmd]}, [{echo, false}]), > > State#state{group = Group, buf = empty_buf()}; > > start_shell(ConnectionHandler, Cmd, #state{exec=Shell} = State) when > > is_function(Shell) -> > > > > ConnectionInfo = ssh_connection_handler:info(ConnectionHandler, > > [peer, user]), > > {ok, User} = > > proplists:get_value(user, ConnectionInfo), > > ShellFun = > > case erlang:fun_info(Shell, arity) of > > {arity, 1} -> > > fun() -> Shell(Cmd) end; > > {arity, 2} -> > > fun() -> Shell(Cmd, User) end; > > {arity, 3} -> > > [{_, PeerAddr}] = > > proplists:get_value(peer, ConnectionInfo), > > fun() -> Shell(Cmd, User, PeerAddr) end; > > _ -> > > Shell > > end, > > Echo = get_echo(State#state.pty), > > Group = group:start(self(), ShellFun, [{echo,Echo}]), > > State#state{group = Group, buf = empty_buf()}. > > ``` > > The exec property of the state record is set on init, so I figured I > > could just pass in a fun instead like I can the shell option: > > ``` > > {error,{eoptions,{exec,#Fun}} > > ``` > > Nope. But yet it looks like it should accept a fun fine, so... what > > is going on. > > I take a look at where ssh_cli is called and found this in > > ssh_connection_handler.erl: > > ``` > > Shell = proplists:get_value(shell, Opts), > > Exec = proplists:get_value(exec, Opts), > > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), > > State#state{starter = Pid, connection_state = Connection#connection{ > > cli_spec = CliSpec, > > exec = Exec, > > system_supervisor > > = SystemSup, > > > > sub_system_supervisor = SubSystemSup, > > > > connection_supervisor = ConnectionSup > > }}. > > ``` > > So, it seems the exec is set here as an option to the connection > > state, and the exec is filtered on this in ssh.erl: > > ``` > > > > handle_ssh_option({exec, {Module, Function, _}} = Opt) when > is_atom(Module), > > > is_atom(Function) -> > > > > Opt; > > ``` > > And that looks like it should work, but wait, remember what I said > > about exec only being set on init in ssh_cli.erl, and look at the line > > above that sets the default ssh_cli option: > > ``` > > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), > > ``` > > Hmm, so it never sets the exec option in the ssh_cli, if it did then > > it should actually be calling: > > ``` > > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell, > Exec]}), > > ``` > > Yet it is not. So I removed my shell and exec options from ssh:daemon > > and replaced it with a single option of: > > ``` > > {ssh_cli, {ssh_cli, [ > > fun(User, PeerAddr) -> msw_ssh_server_shell:start(User, > PeerAddr) end, > > fun(Cmd, User, PeerAddr) -> msw_ssh_server_shell:exec(Cmd, > > User, PeerAddr) end]}}, > > ``` > > And badda bing it works. I am not sure if this is the 'proper' way to > > do it (and I would love to learn of a proper way if it exists), but it > > works with both setting a shell, exec, and getting the User and > > PeerAddress in both cases as well. > > > > On Tue, Dec 10, 2013 at 2:26 PM, OvermindDL1 > wrote: > >> Another question while I am at it with this exec option, the 'shell' > >> option gets a User and PeerAddr passed in, any way to do that with > >> exec? If I can at least get the User then I can allow them to issue > >> one-off commands this way too, which would be quite useful for remote > >> scripting. > >> > >> On Tue, Dec 10, 2013 at 2:22 PM, OvermindDL1 > wrote: > >>> Ah all you are amazing, I never saw that option in the docs indeed and > >>> looks like it should do what I want. Thanks much for all the help! > >>> > >>> On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund > wrote: > >>>> Actually, the sample cli module works quite all right. The problem is > that > >>>> the default implementation in ssh_cli for the "exec" thing in ssh is > >>>> actually to execute it (using erl_scan and erl_eval and stuff). There > is an > >>>> undocumented option to ssh (actually to the ssh_cli module) that can > be used > >>>> to customize this. The option {exec, {M, F, []}} takes an exported > function > >>>> (M:F/1) that is called with the parameters given to the ssh commands > as a > >>>> string. This function should spawn a process that writes the desired > output > >>>> on stdout. > >>>> > >>>> So to avoid the strange eval phenomenon, and provide another function > that > >>>> just echoes the parameters back, you can write a module x: > >>>> -module(x). > >>>> -export([exec/1]). > >>>> exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). > >>>> > >>>> and specify the function x:exec/1 as a call-back for the exec option: > >>>> B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, ""]). > >>>> > >>>> And then when you do: > >>>>> ssh -p 8323 to.the.host 'lists:reverse("test").' > >>>> > >>>> You get back: > >>>> "list:reverse(\"test\")." > >>>> > >>>> Hope this helps. (And sorry for the mess?) > >>>> /Jakob > >>>> > >>>> > >>>> > >>>> 2013/12/10 Ingela Andin > >>>>> > >>>>> Hi! > >>>>> > >>>>> The CLI example in the SSH application must be seen as a hack. We > intend > >>>>> to clean it up and > >>>>> extend the SSH documentation, when it gets prioritized I can not > say. Well > >>>>> anyway your CLI > >>>>> implementation must take care of SSH exec request as well. You can > also > >>>>> look at the ssh_cli.erl module. > >>>>> If I remember correctly there was a bug, before ssh-2.1.7, with > regards to > >>>>> the exec request so that it was not forwarded to CLI process but > rather > >>>>> always interpreted in the erlang shell environment. > >>>>> > >>>>> Regards Ingela Erlang/OTP team - Ericsson AB > >>>>> > >>>>> > >>>>> > >>>>> 2013/12/7 OvermindDL1 > >>>>>> > >>>>>> Greetings, > >>>>>> > >>>>>> I am attempting to just create an SSH shell to connect to a system > by > >>>>>> users so they can do commands without the web interface, and as > such I > >>>>>> certainly do not want things like port forwarding or being able to > run > >>>>>> arbitrary erlang code, however I do not seem to be able to disable > >>>>>> running arbitrary erlang code. An example of the ssh_sample_cli > >>>>>> included with erlang: > >>>>>> """ > >>>>>> $ erl > >>>>>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] > >>>>>> [async-threads:10] [hipe] [kernel-poll:false] > >>>>>> > >>>>>> Eshell V5.10.3 (abort with ^G) > >>>>>> 1> c(ssh_sample_cli). > >>>>>> ssh_sample_cli.erl:146: Warning: this expression will fail with a > >>>>>> 'badarith' exception > >>>>>> {ok,ssh_sample_cli} > >>>>>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). > >>>>>> {ok,<0.67.0>} > >>>>>> """ > >>>>>> > >>>>>> And from another shell/computer: > >>>>>> """ > >>>>>> $ ssh -p 8321 to.the.host > >>>>>> myusername@REDACTED's password: > >>>>>> Enter command > >>>>>> CLI> help > >>>>>> CLI Sample > >>>>>> crash crash the cli > >>>>>> exit exit application > >>>>>> factors prime factors of > >>>>>> gcd greatest common divisor > >>>>>> help help text > >>>>>> host print host addr > >>>>>> lcm least common multiplier > >>>>>> prime check for primality > >>>>>> primes print all primes up to > >>>>>> rho prime factors using rho's alg. > >>>>>> self print my pid > >>>>>> user print name of user > >>>>>> > >>>>>> ---> ok > >>>>>> CLI> exit > >>>>>> ---> done > >>>>>> Connection to to.the.host closed. > >>>>>> """ > >>>>>> > >>>>>> So far so good (the main program where I have this implemented has a > >>>>>> well running shell of its own), but lets try a couple other things: > >>>>>> """ > >>>>>> $ sftp -P 8321 to.the.host > >>>>>> myusername@REDACTED's password: > >>>>>> subsystem request failed on channel 0 > >>>>>> Connection closed > >>>>>> """ > >>>>>> > >>>>>> Also good, no file transfers can be done since the option subsystem > is > >>>>>> set to [], but notice: > >>>>>> """ > >>>>>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna > ereh > >>>>>> gnineppah si tahw woN").' > >>>>>> myusername@REDACTED's password: > >>>>>> "Now what is happening here and how do I stop it?!" > >>>>>> """ > >>>>>> > >>>>>> So... I can still run arbitrary erlang commands, how do I stop this? > >>>>>> Unable to find an option to pass in or anything through a quick code > >>>>>> perusal to no avail. Help? > >>>>>> _______________________________________________ > >>>>>> erlang-questions mailing list > >>>>>> erlang-questions@REDACTED > >>>>>> http://erlang.org/mailman/listinfo/erlang-questions > >>>>> > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> erlang-questions mailing list > >>>>> erlang-questions@REDACTED > >>>>> http://erlang.org/mailman/listinfo/erlang-questions > >>>>> > >>>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zambal@REDACTED Wed Dec 11 11:34:39 2013 From: zambal@REDACTED (Vincent Siliakus) Date: Wed, 11 Dec 2013 11:34:39 +0100 Subject: [erlang-questions] Data locality and the Erlang Runtime Message-ID: Dear Erlangers, Last night I was reading the following article: http://gameprogrammingpatterns.com/data-locality.html. It gives a nice overview about the importance of data locality for performance critical code these days. So I started wondering how much of this applies to my favourite runtime (I say runtime because I use Elixir more often than Erlang lately). I'm perfectly aware that Erlang's intended use is not high performance, arithmetic applications and I don't have any performance problems with the Elixir/Erlang code I write, so I ask this purely out of curiosity, although I can see having some knowledge about this in the context of Erlang can have some practical value for cases when you do have some tight loops with performance constraints. So could anybody with deep enough knowledge of the Erlang Runtime be so kind to give some insight in this matter? thanks, vincent PS I already posted this mail yesterday via the Google Groups mirror, but apparently mails posted via Google Groups don't get forwarded to the actual mailing-list any more. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eli.cohen357@REDACTED Wed Dec 11 12:42:00 2013 From: eli.cohen357@REDACTED (Eli Cohen) Date: Wed, 11 Dec 2013 13:42:00 +0200 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: Hi all, I've reduced my scenario: In the reduced scenario I have two nodes. On one node I have a process that generates messages and banging towards a process located on "destination" node. The receiving process does nothing with the messages. No UDP activity at all. The result is similar - ~150K messages per second throughput limitation. Hope it simplifies the case. Please advice, Thanks in advance. 2013/12/11 Valentin Micic > > To remind you, when I'm moving the receiving machine - the throughput > between the nodes is doubled. (which is still low, but it proves that the > UDP sockets are not the bottleneck - > > Not sure what does "moving the receiving machine" mean and how does it > prove that UDP sockets are not bottleneck. > Care to elaborate? > > As for number of UDP sockets you're using: at some point you will face the > curse of diminishing returns. > In my view, assuming that you've written an ideal server (*) and have > adequate receiving buffer sizes, a number of cooperating UDP sockets (e.g. > sockets offering the same service) should not exceed the number of CPU's > used by Erlang run-time (in other words number of Erlang schedulers). > > Could you share what kind of "socket activity" you're using with your > server: {active, true}, {active, false} or {active, once}? > > > V/ > > (*) A server that has zero processing time. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon@REDACTED Wed Dec 11 12:48:23 2013 From: jon@REDACTED (Jon Schneider) Date: Wed, 11 Dec 2013 11:48:23 -0000 Subject: [erlang-questions] Inter nodes messaging bottleneck In-Reply-To: References: Message-ID: <089f1cc0bd06d4510c3b1187e1c323a7.squirrel@mail.jschneider.net> > The result is similar - ~150K messages per second throughput limitation. The overhead of system calls is of the order of a few thousand cycles or a microsecond so I suspect this will always be the case while messages have a 1:1 correspondence with physical packets. What happens when you up the message size ? Jon From mail@REDACTED Wed Dec 11 15:54:33 2013 From: mail@REDACTED (Alexander Alexeev) Date: Wed, 11 Dec 2013 18:54:33 +0400 Subject: [erlang-questions] FYI: bug in tim/erlang-decimal Message-ID: <20131211185433.73c57ce8@portege> https://github.com/tim/erlang-decimal/issues/2 -- Best regards, Alexander Alexeev http://eax.me/ From jesper.louis.andersen@REDACTED Wed Dec 11 16:03:56 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 11 Dec 2013 16:03:56 +0100 Subject: [erlang-questions] Data locality and the Erlang Runtime In-Reply-To: References: Message-ID: On Wed, Dec 11, 2013 at 11:34 AM, Vincent Siliakus wrote: > Last night I was reading the following article: > http://gameprogrammingpatterns.com/data-locality.html. It gives a nice > overview about the importance of data locality for performance critical > code these days. So I started wondering how much of this applies to my > favourite runtime (I say runtime because I use Elixir more often than > Erlang lately). > It is hard to say exactly how a given piece of code will execute on a system. The general consensus the latter years has been optimizing for data locality and limiting DRAM access speeds things up. This is mostly due to how caches work and so on. Clock cycles today are almost "free". The Erlang BEAM VM is quite pointer-heavy in the sense that we usually don't pack data that tightly and prefer to use a tree-like term structure. The advantage of the approach is it gives a better and easier path to handle persistence and immutability, which are cornerstones of writing large functional programs. Furthermore, you have relatively little control over the concrete memory layout of data in BEAM, making it harder to pack data tightly. It makes it hard to apply those kinds of tricks in the article. The "structural zoo" of Erlang is not that strong and due to the language being dynamic--it is limited how much representational control you have. If you want to exploit memory layout, there are better languages out there. However, the article is written for single-core imperative code. One advantage you have on the BEAM is that small process heaps tend to stay in cache. This makes their garbage collection and operation faster and it improves locality for the heap. Also, the article completely forgets to touch on the fact that modern systems have multiple cores. In such a system, immutability and copying can help drive up parallelism, which in turn means you can get more cores to do productive work. It is not as clear-cut as one might believe. Multiple cores changes everything, especially with respect to data mutation which become more expensive. -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Wed Dec 11 16:39:55 2013 From: james.hague@REDACTED (James Hague) Date: Wed, 11 Dec 2013 09:39:55 -0600 Subject: [erlang-questions] Data locality and the Erlang Runtime In-Reply-To: References: Message-ID: In C++, memory blocks can be allocated anywhere. If you malloc/new 50 blocks, they could be in 50 different parts of the address space. It all depends on the memory allocator. In Erlang, and any language with a compacting garbage collector, data is allocated sequentially. With a small per-process heap, you might only have 4 or 16K of data, all contained within a consecutive address space. I wrote an action game in Erlang a few years ago, and if I mapped out what all of the data looked like in memory it would have been a crazy, tangled mess of pointers. The entire game ran at 60fps and only used a small fraction of the available CPU (this was on a laptop from 2006). James From mallen@REDACTED Wed Dec 11 17:19:42 2013 From: mallen@REDACTED (Mark Allen) Date: Wed, 11 Dec 2013 10:19:42 -0600 Subject: [erlang-questions] pg2 scale limits Message-ID: What has been the experience of folks with the practical upper bound of process groups registered with the pg2 application? I have an application where I need to track 10000 or so process groups across a set of erlang nodes (2 R14B04 Erlang VMs running on top of 2 Debian VMs to start.) Would that size of registry cause problems? I read http://christophermeiklejohn.com/erlang/2013/06/03/erlang-pg2-failure-seman tics.html and it was a great read - are there any other pitfalls about pg2 that I should be aware of? I am planning to implement a "prototype" of this application using pg2 at reasonably low scale, but I am open to other implementation suggestions or applications (I looked at gproc too, but I'd rather stick with pg2 if possible because it comes "out of the box"...) Thanks. Mark From konrad.gadek@REDACTED Wed Dec 11 18:06:09 2013 From: konrad.gadek@REDACTED (Konrad =?utf-8?Q?G=C4=85dek?=) Date: Wed, 11 Dec 2013 18:06:09 +0100 (CET) Subject: [erlang-questions] R16B03 binary packages for CentOS, Debian, Mac, Ubuntu and Windows In-Reply-To: <1738389517.358194.1386781304005.JavaMail.zimbra@erlang-solutions.com> Message-ID: <1026545019.358256.1386781569840.JavaMail.zimbra@erlang-solutions.com> Hello, You can find our binary packages for the newest Erlang release (R16B03) at http://www.erlang-solutions.com/downloads/download-erlang-otp The systems we provide the packages for are CentOS 6, Mac OS X Snow Leopard and newer, Debian 7.0.0, Ubuntu 13.10 + 13.04 + 12.10 + 12.04, and Windows. More to come soon! Best regards, -- Konrad G?dek Erlang Solutions From kenneth.lundin@REDACTED Wed Dec 11 18:15:43 2013 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 11 Dec 2013 18:15:43 +0100 Subject: [erlang-questions] OTP R16B03 has been released Message-ID: Erlang/OTP R16B03 has been released. OTP R16B03 is a service release with mostly a number of small corrections and user contributions. But there are some new functions worth mentioning as well, here are some of them: - A new memory allocation feature called "super carrier" has been introduced. It can for example be used for pre-allocation of all memory that the runtime system should be able to use. It is enabled by passing the +MMscs (size in MB) command line argument. For more information see the documentation of the +MMsco, +MMscrfsd, +MMscrpm, +MMscs, +MMusac, and, +Mlpm command line arguments in the erts_alloc(3) documentation. - The LDAP client (eldap application) now supports the start_tls operation. This upgrades an existing tcp connection to encryption using TLS, see eldap:start_tls/2 and /3. - The FTP client (inets application) now supports FTP over TLS (ftps). ~50 open source contributions. Many thanks for that! You can find the README file with more detailed info at http://www.erlang.org/download/otp_src_R16B03.readme You can download the full source distribution from http://www.erlang.org/download/otp_src_R16B03.tar.gz http://www.erlang.org/download/otp_src_R16B03.readme (this file) Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README that is part of the distribution. You can also find this release at the official Erlang/OTP Git-repository at Github here: https://github.com/erlang/otp tagged *OTP_R16B03* The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R16B03.exe http://www.erlang.org/download/otp_win64_R16B03.exe On-line documentation can be found at http://www.erlang.org/doc/. You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R16B03.tar.gz http://www.erlang.org/download/otp_doc_man_R16B03.tar.gz We also want to thank those that sent us patches, suggestions and bug reports, The Erlang/OTP Team at Ericsson -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Wed Dec 11 19:49:06 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Wed, 11 Dec 2013 11:49:06 -0700 Subject: [erlang-questions] 'ssh' security issue In-Reply-To: References: Message-ID: I can build erlang from git whenever the changes are available if you want me to test it with a running application, just tell me when. Thanks for the assistance, it put me right on the right track. I love the help that is available here! On Dec 11, 2013 1:25 AM, "Ingela Andin" wrote: > Hi! > > As I mentioned in my previous post, ssh will change quite a lot in the > upcoming release so please > try it when it comes and let me now if there are any further improvements > that you need. > > Regards Ingela Erlang/OTP team - Ericsson AB > > > 2013/12/10 OvermindDL1 > >> Be calling the option with Exec added to it with a fixed >> handle_ssh_option test to test for if a fun as well. >> >> On Tue, Dec 10, 2013 at 3:15 PM, OvermindDL1 >> wrote: >> > Nevermind, and for future documentation I found this in ssh_cli.erl: >> > ``` >> > start_shell(_ConnectionHandler, Cmd, #state{exec={M, F, A}} = State) -> >> > Group = group:start(self(), {M, F, A++[Cmd]}, [{echo, false}]), >> > State#state{group = Group, buf = empty_buf()}; >> > start_shell(ConnectionHandler, Cmd, #state{exec=Shell} = State) when >> > is_function(Shell) -> >> > >> > ConnectionInfo = ssh_connection_handler:info(ConnectionHandler, >> > [peer, user]), >> > {ok, User} = >> > proplists:get_value(user, ConnectionInfo), >> > ShellFun = >> > case erlang:fun_info(Shell, arity) of >> > {arity, 1} -> >> > fun() -> Shell(Cmd) end; >> > {arity, 2} -> >> > fun() -> Shell(Cmd, User) end; >> > {arity, 3} -> >> > [{_, PeerAddr}] = >> > proplists:get_value(peer, ConnectionInfo), >> > fun() -> Shell(Cmd, User, PeerAddr) end; >> > _ -> >> > Shell >> > end, >> > Echo = get_echo(State#state.pty), >> > Group = group:start(self(), ShellFun, [{echo,Echo}]), >> > State#state{group = Group, buf = empty_buf()}. >> > ``` >> > The exec property of the state record is set on init, so I figured I >> > could just pass in a fun instead like I can the shell option: >> > ``` >> > {error,{eoptions,{exec,#Fun}} >> > ``` >> > Nope. But yet it looks like it should accept a fun fine, so... what >> > is going on. >> > I take a look at where ssh_cli is called and found this in >> > ssh_connection_handler.erl: >> > ``` >> > Shell = proplists:get_value(shell, Opts), >> > Exec = proplists:get_value(exec, Opts), >> > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), >> > State#state{starter = Pid, connection_state = Connection#connection{ >> > cli_spec = CliSpec, >> > exec = Exec, >> > system_supervisor >> > = SystemSup, >> > >> > sub_system_supervisor = SubSystemSup, >> > >> > connection_supervisor = ConnectionSup >> > }}. >> > ``` >> > So, it seems the exec is set here as an option to the connection >> > state, and the exec is filtered on this in ssh.erl: >> > ``` >> > >> > handle_ssh_option({exec, {Module, Function, _}} = Opt) when >> is_atom(Module), >> > >> is_atom(Function) -> >> > >> > Opt; >> > ``` >> > And that looks like it should work, but wait, remember what I said >> > about exec only being set on init in ssh_cli.erl, and look at the line >> > above that sets the default ssh_cli option: >> > ``` >> > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), >> > ``` >> > Hmm, so it never sets the exec option in the ssh_cli, if it did then >> > it should actually be calling: >> > ``` >> > CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell, >> Exec]}), >> > ``` >> > Yet it is not. So I removed my shell and exec options from ssh:daemon >> > and replaced it with a single option of: >> > ``` >> > {ssh_cli, {ssh_cli, [ >> > fun(User, PeerAddr) -> msw_ssh_server_shell:start(User, >> PeerAddr) end, >> > fun(Cmd, User, PeerAddr) -> msw_ssh_server_shell:exec(Cmd, >> > User, PeerAddr) end]}}, >> > ``` >> > And badda bing it works. I am not sure if this is the 'proper' way to >> > do it (and I would love to learn of a proper way if it exists), but it >> > works with both setting a shell, exec, and getting the User and >> > PeerAddress in both cases as well. >> > >> > On Tue, Dec 10, 2013 at 2:26 PM, OvermindDL1 >> wrote: >> >> Another question while I am at it with this exec option, the 'shell' >> >> option gets a User and PeerAddr passed in, any way to do that with >> >> exec? If I can at least get the User then I can allow them to issue >> >> one-off commands this way too, which would be quite useful for remote >> >> scripting. >> >> >> >> On Tue, Dec 10, 2013 at 2:22 PM, OvermindDL1 >> wrote: >> >>> Ah all you are amazing, I never saw that option in the docs indeed and >> >>> looks like it should do what I want. Thanks much for all the help! >> >>> >> >>> On Tue, Dec 10, 2013 at 10:20 AM, Jakob Cederlund >> wrote: >> >>>> Actually, the sample cli module works quite all right. The problem >> is that >> >>>> the default implementation in ssh_cli for the "exec" thing in ssh is >> >>>> actually to execute it (using erl_scan and erl_eval and stuff). >> There is an >> >>>> undocumented option to ssh (actually to the ssh_cli module) that can >> be used >> >>>> to customize this. The option {exec, {M, F, []}} takes an exported >> function >> >>>> (M:F/1) that is called with the parameters given to the ssh commands >> as a >> >>>> string. This function should spawn a process that writes the desired >> output >> >>>> on stdout. >> >>>> >> >>>> So to avoid the strange eval phenomenon, and provide another >> function that >> >>>> just echoes the parameters back, you can write a module x: >> >>>> -module(x). >> >>>> -export([exec/1]). >> >>>> exec(A) -> spawn(fun() -> io:format("~p\n", [A]), exit(normal) end). >> >>>> >> >>>> and specify the function x:exec/1 as a call-back for the exec option: >> >>>> B=ssh_sample_cli:listen(8323, [{subsystems, []}, {exec, x, exec, >> ""]). >> >>>> >> >>>> And then when you do: >> >>>>> ssh -p 8323 to.the.host 'lists:reverse("test").' >> >>>> >> >>>> You get back: >> >>>> "list:reverse(\"test\")." >> >>>> >> >>>> Hope this helps. (And sorry for the mess?) >> >>>> /Jakob >> >>>> >> >>>> >> >>>> >> >>>> 2013/12/10 Ingela Andin >> >>>>> >> >>>>> Hi! >> >>>>> >> >>>>> The CLI example in the SSH application must be seen as a hack. We >> intend >> >>>>> to clean it up and >> >>>>> extend the SSH documentation, when it gets prioritized I can not >> say. Well >> >>>>> anyway your CLI >> >>>>> implementation must take care of SSH exec request as well. You can >> also >> >>>>> look at the ssh_cli.erl module. >> >>>>> If I remember correctly there was a bug, before ssh-2.1.7, with >> regards to >> >>>>> the exec request so that it was not forwarded to CLI process but >> rather >> >>>>> always interpreted in the erlang shell environment. >> >>>>> >> >>>>> Regards Ingela Erlang/OTP team - Ericsson AB >> >>>>> >> >>>>> >> >>>>> >> >>>>> 2013/12/7 OvermindDL1 >> >>>>>> >> >>>>>> Greetings, >> >>>>>> >> >>>>>> I am attempting to just create an SSH shell to connect to a system >> by >> >>>>>> users so they can do commands without the web interface, and as >> such I >> >>>>>> certainly do not want things like port forwarding or being able to >> run >> >>>>>> arbitrary erlang code, however I do not seem to be able to disable >> >>>>>> running arbitrary erlang code. An example of the ssh_sample_cli >> >>>>>> included with erlang: >> >>>>>> """ >> >>>>>> $ erl >> >>>>>> Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] >> >>>>>> [async-threads:10] [hipe] [kernel-poll:false] >> >>>>>> >> >>>>>> Eshell V5.10.3 (abort with ^G) >> >>>>>> 1> c(ssh_sample_cli). >> >>>>>> ssh_sample_cli.erl:146: Warning: this expression will fail with a >> >>>>>> 'badarith' exception >> >>>>>> {ok,ssh_sample_cli} >> >>>>>> 2> B=ssh_sample_cli:listen(8323, [{subsystems, []}]). >> >>>>>> {ok,<0.67.0>} >> >>>>>> """ >> >>>>>> >> >>>>>> And from another shell/computer: >> >>>>>> """ >> >>>>>> $ ssh -p 8321 to.the.host >> >>>>>> myusername@REDACTED's password: >> >>>>>> Enter command >> >>>>>> CLI> help >> >>>>>> CLI Sample >> >>>>>> crash crash the cli >> >>>>>> exit exit application >> >>>>>> factors prime factors of >> >>>>>> gcd greatest common divisor >> >>>>>> help help text >> >>>>>> host print host addr >> >>>>>> lcm least common multiplier >> >>>>>> prime check for primality >> >>>>>> primes print all primes up to >> >>>>>> rho prime factors using rho's alg. >> >>>>>> self print my pid >> >>>>>> user print name of user >> >>>>>> >> >>>>>> ---> ok >> >>>>>> CLI> exit >> >>>>>> ---> done >> >>>>>> Connection to to.the.host closed. >> >>>>>> """ >> >>>>>> >> >>>>>> So far so good (the main program where I have this implemented has >> a >> >>>>>> well running shell of its own), but lets try a couple other things: >> >>>>>> """ >> >>>>>> $ sftp -P 8321 to.the.host >> >>>>>> myusername@REDACTED's password: >> >>>>>> subsystem request failed on channel 0 >> >>>>>> Connection closed >> >>>>>> """ >> >>>>>> >> >>>>>> Also good, no file transfers can be done since the option >> subsystem is >> >>>>>> set to [], but notice: >> >>>>>> """ >> >>>>>> $ ssh -p 8323 to.the.host 'lists:reverse("!?ti pots I od woh dna >> ereh >> >>>>>> gnineppah si tahw woN").' >> >>>>>> myusername@REDACTED's password: >> >>>>>> "Now what is happening here and how do I stop it?!" >> >>>>>> """ >> >>>>>> >> >>>>>> So... I can still run arbitrary erlang commands, how do I stop >> this? >> >>>>>> Unable to find an option to pass in or anything through a quick >> code >> >>>>>> perusal to no avail. Help? >> >>>>>> _______________________________________________ >> >>>>>> erlang-questions mailing list >> >>>>>> erlang-questions@REDACTED >> >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >> >>>>> >> >>>>> >> >>>>> >> >>>>> _______________________________________________ >> >>>>> erlang-questions mailing list >> >>>>> erlang-questions@REDACTED >> >>>>> http://erlang.org/mailman/listinfo/erlang-questions >> >>>>> >> >>>> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pablo.platt@REDACTED Thu Dec 12 03:11:41 2013 From: pablo.platt@REDACTED (pablo platt) Date: Thu, 12 Dec 2013 04:11:41 +0200 Subject: [erlang-questions] DTLS client/server In-Reply-To: References: <-2812677860635758685@unknownmsgid> Message-ID: Hi Will it be possible to use DTLS for DTLS-SRTP when it will be released? http://tools.ietf.org/html/rfc5764 DTLS-SRTP requires sending use_srtp in extended hello and exchanging SRTP keys. DTLS-SRTP also requires that RTP and STUN messages are forwarded to the app. Will there be support out of the box for such extension? Thanks On Fri, Oct 18, 2013 at 5:07 AM, pablo platt wrote: > A preview in a few weeks will be great. > > Thanks > > > On Fri, Oct 18, 2013 at 12:12 AM, Ingela Andin wrote: > >> Hi! >> >> >> 2013/10/17 pablo platt >> >>> Is there a chance for release preview of DTLS before the R17 release on >>> February? >>> >>> >> Alas, I still do not have anything releasable that is runnable. I have >> had to work with some other stuff in between. >> But I think previews can be possible. I have a rather large step in the >> pipeline that I probably can release in a few weeks >> as it then can be merged to maint. This step will include some code from >> Andreas that implements basic stuff. But >> the internal structure of the code is quite different and the API is not >> totally set yet. >> >> Regards Ingela Erlang/OTP team - Ericsson AB >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji@REDACTED Thu Dec 12 13:13:04 2013 From: kenji@REDACTED (Kenji Rikitake) Date: Thu, 12 Dec 2013 21:13:04 +0900 Subject: [erlang-questions] enforcing concurrent make in otp_build Message-ID: <20131212121304.GA42615@k2r.org> I am trying to find out how to enforce concurrent execution of `make` in the otp_build shell script. I want to do the same thing as `make -j8`. So far I have discovered that setting the environment variable MAKE will do, such as `env MAKE="make -j8" otp_build build`. Am I in the right path? (Note that on FreeBSD it's `gmake`) I want to make the build process of the kerl script faster, such as in env MAKE="make -j10" kerl build R16B03 r16b03-test # `gmake` on FreeBSD I`d be glad if I could hear more efficient ways to do this. Regards, Kenji Rikitake From zambal@REDACTED Thu Dec 12 13:15:17 2013 From: zambal@REDACTED (Vincent Siliakus) Date: Thu, 12 Dec 2013 13:15:17 +0100 Subject: [erlang-questions] Data locality and the Erlang Runtime In-Reply-To: References: Message-ID: Thanks for the detailed and informative answer. In my day to day programming I rarely encounter cases where thinking about memory layout would make much sense. However, the referenced article triggered my curiosity to what level BEAM's implementation could take advantage of this, although I already suspected it would be hard, given Erlang's semantics. Apart from binaries/bitstrings, the only thing I could think of that might create a tightly packed data structure, is a tuple of small integers, unless my assumption is false that small integers are unboxed values and tuples, as opposed to lists, directly stores it's elements in Erlang. But then again, even if that would be the case, you still have to unpack these integers from the tuple to do something meaningful with them, so that probably mitigates any advantage of having these integers nicely packed together in a tuple. BTW, the referenced article did in fact mention that the described techniques only work in a single threaded environment, but it was sneakily put a way in a side bar of the article ;) : "There?s a key assumption here, though: one thread. If you are accessing nearby data on multiple threads, it?s faster to have it on *different*cache lines. If two threads try to use data on the same cache line, both cores have to do some costly synchronization of their caches." On Wed, Dec 11, 2013 at 4:03 PM, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > > On Wed, Dec 11, 2013 at 11:34 AM, Vincent Siliakus wrote: > >> Last night I was reading the following article: >> http://gameprogrammingpatterns.com/data-locality.html. It gives a nice >> overview about the importance of data locality for performance critical >> code these days. So I started wondering how much of this applies to my >> favourite runtime (I say runtime because I use Elixir more often than >> Erlang lately). >> > > It is hard to say exactly how a given piece of code will execute on a > system. The general consensus the latter years has been optimizing for data > locality and limiting DRAM access speeds things up. This is mostly due to > how caches work and so on. Clock cycles today are almost "free". The Erlang > BEAM VM is quite pointer-heavy in the sense that we usually don't pack data > that tightly and prefer to use a tree-like term structure. The advantage of > the approach is it gives a better and easier path to handle persistence and > immutability, which are cornerstones of writing large functional programs. > > Furthermore, you have relatively little control over the concrete memory > layout of data in BEAM, making it harder to pack data tightly. It makes it > hard to apply those kinds of tricks in the article. The "structural zoo" of > Erlang is not that strong and due to the language being dynamic--it is > limited how much representational control you have. If you want to exploit > memory layout, there are better languages out there. > > However, the article is written for single-core imperative code. One > advantage you have on the BEAM is that small process heaps tend to stay in > cache. This makes their garbage collection and operation faster and it > improves locality for the heap. Also, the article completely forgets to > touch on the fact that modern systems have multiple cores. In such a > system, immutability and copying can help drive up parallelism, which in > turn means you can get more cores to do productive work. It is not as > clear-cut as one might believe. Multiple cores changes everything, > especially with respect to data mutation which become more expensive. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From garazdawi@REDACTED Thu Dec 12 13:30:04 2013 From: garazdawi@REDACTED (Lukas Larsson) Date: Thu, 12 Dec 2013 13:30:04 +0100 Subject: [erlang-questions] enforcing concurrent make in otp_build In-Reply-To: <20131212121304.GA42615@k2r.org> References: <20131212121304.GA42615@k2r.org> Message-ID: I normally use "export MAKEFLAGS=-j10 && ./otp_build" on Linux, maybe that works for you as well on bsd? Lukas On Thu, Dec 12, 2013 at 1:13 PM, Kenji Rikitake wrote: > I am trying to find out how to enforce concurrent execution of `make` > in the otp_build shell script. I want to do the same thing as `make -j8`. > So far I have discovered that setting the environment variable MAKE will > do, > such as `env MAKE="make -j8" otp_build build`. Am I in the right path? > (Note that on FreeBSD it's `gmake`) > > I want to make the build process of the kerl script faster, such as in > > env MAKE="make -j10" kerl build R16B03 r16b03-test # `gmake` on FreeBSD > > I`d be glad if I could hear more efficient ways to do this. > > Regards, > Kenji Rikitake > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zambal@REDACTED Thu Dec 12 13:32:47 2013 From: zambal@REDACTED (Vincent Siliakus) Date: Thu, 12 Dec 2013 13:32:47 +0100 Subject: [erlang-questions] Data locality and the Erlang Runtime Message-ID: Thanks for the extra insight. As a side note, I really enjoyed reading your functional game programming articles at the time you published them. Do you have any plans for a sequel? :) -vincent Op woensdag 11 december 2013 16:39:55 UTC+1 schreef James Hague: In C++, memory blocks can be allocated anywhere. If you malloc/new 50 blocks, they could be in 50 different parts of the address space. It all depends on the memory allocator. In Erlang, and any language with a compacting garbage collector, data is allocated sequentially. With a small per-process heap, you might only have 4 or 16K of data, all contained within a consecutive address space. I wrote an action game in Erlang a few years ago, and if I mapped out what all of the data looked like in memory it would have been a crazy, tangled mess of pointers. The entire game ran at 60fps and only used a small fraction of the available CPU (this was on a laptop from 2006). James ______________________________ > > _________________ > erlang-questions mailing list > erlang-q...@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Thu Dec 12 13:51:54 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 12 Dec 2013 13:51:54 +0100 Subject: [erlang-questions] enforcing concurrent make in otp_build In-Reply-To: References: <20131212121304.GA42615@k2r.org> Message-ID: <40838E65-3838-46A6-8AB7-95E8DB98B172@gmail.com> I do MAKEFLAGS="..." ./otp_build ... As a side note, GNU Make 4 has a nice feature for improving parallel build output: -O[type], --output-sync[=type] When running multiple jobs in parallel with -j, ensure the output of each job is collected together rather than interspersed with output from other jobs. If type is not specified or is target the output from the entire recipe for each target is grouped together. If type is line the output from each command line within a recipe is grouped together. If type is recurse output from an entire recursive make is grouped together. If type is none output synchroniza- tion is disabled. This makes Clang diagnostics readable even in a parallel build. -- Anthony Ramine Le 12 d?c. 2013 ? 13:30, Lukas Larsson a ?crit : > I normally use "export MAKEFLAGS=-j10 && ./otp_build" on Linux, maybe that works for you as well on bsd? > > Lukas > > > On Thu, Dec 12, 2013 at 1:13 PM, Kenji Rikitake wrote: > I am trying to find out how to enforce concurrent execution of `make` > in the otp_build shell script. I want to do the same thing as `make -j8`. > So far I have discovered that setting the environment variable MAKE will do, > such as `env MAKE="make -j8" otp_build build`. Am I in the right path? > (Note that on FreeBSD it's `gmake`) > > I want to make the build process of the kerl script faster, such as in > > env MAKE="make -j10" kerl build R16B03 r16b03-test # `gmake` on FreeBSD > > I`d be glad if I could hear more efficient ways to do this. > > Regards, > Kenji Rikitake > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From ingela.andin@REDACTED Thu Dec 12 13:55:22 2013 From: ingela.andin@REDACTED (Ingela Andin) Date: Thu, 12 Dec 2013 13:55:22 +0100 Subject: [erlang-questions] DTLS client/server In-Reply-To: References: <-2812677860635758685@unknownmsgid> Message-ID: Hi! 2013/12/12 pablo platt > Hi > > > Will it be possible to use DTLS for DTLS-SRTP when it will be released? > http://tools.ietf.org/html/rfc5764 > > > DTLS-SRTP requires sending use_srtp in extended hello and exchanging SRTP keys. > > DTLS-SRTP also requires that RTP and STUN messages are forwarded to the app. > > Will there be support out of the box for such extension? > > No this will not work out of the box. But once DTLS is in place it could be a fairly easy user contribution ;) Regards Ingela Erlang/OTP Team Ericssson AB > > On Fri, Oct 18, 2013 at 5:07 AM, pablo platt wrote: > >> A preview in a few weeks will be great. >> >> Thanks >> >> >> On Fri, Oct 18, 2013 at 12:12 AM, Ingela Andin wrote: >> >>> Hi! >>> >>> >>> 2013/10/17 pablo platt >>> >>>> Is there a chance for release preview of DTLS before the R17 release on >>>> February? >>>> >>>> >>> Alas, I still do not have anything releasable that is runnable. I have >>> had to work with some other stuff in between. >>> But I think previews can be possible. I have a rather large step in the >>> pipeline that I probably can release in a few weeks >>> as it then can be merged to maint. This step will include some code >>> from Andreas that implements basic stuff. But >>> the internal structure of the code is quite different and the API is not >>> totally set yet. >>> >>> Regards Ingela Erlang/OTP team - Ericsson AB >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji@REDACTED Thu Dec 12 14:16:07 2013 From: kenji@REDACTED (Kenji Rikitake) Date: Thu, 12 Dec 2013 22:16:07 +0900 Subject: [erlang-questions] enforcing concurrent make in otp_build In-Reply-To: References: <20131212121304.GA42615@k2r.org> Message-ID: <20131212131607.GA61792@k2r.org> Using MAKEFLAGS is indeed appropriate. Many thanks. Kenji Rikitake ++> Lukas Larsson [2013-12-12 13:30:04 +0100]: > Date: Thu, 12 Dec 2013 13:30:04 +0100 > From: Lukas Larsson > To: Kenji Rikitake > Cc: Erlang Questions > Subject: Re: [erlang-questions] enforcing concurrent make in otp_build > > I normally use "export MAKEFLAGS=-j10 && ./otp_build" on Linux, maybe that > works for you as well on bsd? > > Lukas > > > On Thu, Dec 12, 2013 at 1:13 PM, Kenji Rikitake wrote: > > > I am trying to find out how to enforce concurrent execution of `make` > > in the otp_build shell script. I want to do the same thing as `make -j8`. > > So far I have discovered that setting the environment variable MAKE will > > do, > > such as `env MAKE="make -j8" otp_build build`. Am I in the right path? > > (Note that on FreeBSD it's `gmake`) > > > > I want to make the build process of the kerl script faster, such as in > > > > env MAKE="make -j10" kerl build R16B03 r16b03-test # `gmake` on FreeBSD > > > > I`d be glad if I could hear more efficient ways to do this. > > > > Regards, > > Kenji Rikitake From raimo+erlang-questions@REDACTED Thu Dec 12 14:16:55 2013 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 12 Dec 2013 14:16:55 +0100 Subject: [erlang-questions] Planned power outage Sun 15 Dec 7:00-14:00 CET Message-ID: <20131212131655.GA29249@erix.ericsson.se> Hi all. There will be a planned power outage at Sun 15 Dec 7:00-14:00 CET in the building where the erlang.org servers are located. So all services (www, mail, ...) will be down at least during that period. We are sorry for any inconveniences this may cause the community. Best regards -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From pablo.platt@REDACTED Thu Dec 12 14:17:44 2013 From: pablo.platt@REDACTED (pablo platt) Date: Thu, 12 Dec 2013 15:17:44 +0200 Subject: [erlang-questions] DTLS client/server In-Reply-To: References: <-2812677860635758685@unknownmsgid> Message-ID: Thanks On Thu, Dec 12, 2013 at 2:55 PM, Ingela Andin wrote: > > Hi! > > 2013/12/12 pablo platt > >> Hi >> >> >> Will it be possible to use DTLS for DTLS-SRTP when it will be released? >> http://tools.ietf.org/html/rfc5764 >> >> >> DTLS-SRTP requires sending use_srtp in extended hello and exchanging SRTP keys. >> >> DTLS-SRTP also requires that RTP and STUN messages are forwarded to the app. >> >> Will there be support out of the box for such extension? >> >> > No this will not work out of the box. But once DTLS is in place it could > be a fairly easy user contribution ;) > > > Regards Ingela Erlang/OTP Team Ericssson AB > > >> >> On Fri, Oct 18, 2013 at 5:07 AM, pablo platt wrote: >> >>> A preview in a few weeks will be great. >>> >>> Thanks >>> >>> >>> On Fri, Oct 18, 2013 at 12:12 AM, Ingela Andin wrote: >>> >>>> Hi! >>>> >>>> >>>> 2013/10/17 pablo platt >>>> >>>>> Is there a chance for release preview of DTLS before the R17 release >>>>> on February? >>>>> >>>>> >>>> Alas, I still do not have anything releasable that is runnable. I have >>>> had to work with some other stuff in between. >>>> But I think previews can be possible. I have a rather large step in the >>>> pipeline that I probably can release in a few weeks >>>> as it then can be merged to maint. This step will include some code >>>> from Andreas that implements basic stuff. But >>>> the internal structure of the code is quite different and the API is >>>> not totally set yet. >>>> >>>> Regards Ingela Erlang/OTP team - Ericsson AB >>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattevans123@REDACTED Thu Dec 12 18:30:05 2013 From: mattevans123@REDACTED (Matthew Evans) Date: Thu, 12 Dec 2013 12:30:05 -0500 Subject: [erlang-questions] pg2 scale limits In-Reply-To: References: Message-ID: The one thing to watch for is that pg2 will take a global lock over all nodes in a mesh when a join/leave is done. This means that if you are doing lots of joins, and have a mesh of Erlang nodes, then there is a performance overhead. Not a massive one, but something to watch for. > From: mallen@REDACTED > To: erlang-questions@REDACTED > Date: Wed, 11 Dec 2013 10:19:42 -0600 > Subject: [erlang-questions] pg2 scale limits > > What has been the experience of folks with the practical upper bound of > process groups registered with the pg2 application? > > I have an application where I need to track 10000 or so process groups > across a set of erlang nodes (2 R14B04 Erlang VMs running on top of 2 > Debian VMs to start.) Would that size of registry cause problems? > > I read > http://christophermeiklejohn.com/erlang/2013/06/03/erlang-pg2-failure-seman > tics.html and it was a great read - are there any other pitfalls about pg2 > that I should be aware of? > > I am planning to implement a "prototype" of this application using pg2 at > reasonably low scale, but I am open to other implementation suggestions or > applications (I looked at gproc too, but I'd rather stick with pg2 if > possible because it comes "out of the box"...) > > Thanks. > > Mark > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Thu Dec 12 19:50:40 2013 From: mjtruog@REDACTED (Michael Truog) Date: Thu, 12 Dec 2013 10:50:40 -0800 Subject: [erlang-questions] pg2 scale limits In-Reply-To: References: Message-ID: <52AA0580.10904@gmail.com> If you want to avoid the global lock, you can do so with cpg (https://github.com/okeuday/cpg/), which provides the same pg2 API with additional functionality. It does this with the default macro define of GROUP_NAME_WITH_LOCAL_PIDS_ONLYwhere the global lock is not needed if only local Erlang pids are used with the cpg API. If necessary, the define could be commented in the cpg_constants.hrl file, to have the same global locking pg2 does. cpg doesn't use ets like pg2 does, and with the default cpg_constants.hrl defines it requires the group names are strings (list of integers), but that can be changed with GROUP_STORAGE. On 12/12/2013 09:30 AM, Matthew Evans wrote: > > The one thing to watch for is that pg2 will take a global lock over all nodes in a mesh when a join/leave is done. This means that if you are doing lots of joins, and have a mesh of Erlang nodes, then there is a performance overhead. Not a massive one, but something to watch for. > > > From: mallen@REDACTED > > To: erlang-questions@REDACTED > > Date: Wed, 11 Dec 2013 10:19:42 -0600 > > Subject: [erlang-questions] pg2 scale limits > > > > What has been the experience of folks with the practical upper bound of > > process groups registered with the pg2 application? > > > > I have an application where I need to track 10000 or so process groups > > across a set of erlang nodes (2 R14B04 Erlang VMs running on top of 2 > > Debian VMs to start.) Would that size of registry cause problems? > > > > I read > > http://christophermeiklejohn.com/erlang/2013/06/03/erlang-pg2-failure-seman > > tics.html and it was a great read - are there any other pitfalls about pg2 > > that I should be aware of? > > > > I am planning to implement a "prototype" of this application using pg2 at > > reasonably low scale, but I am open to other implementation suggestions or > > applications (I looked at gproc too, but I'd rather stick with pg2 if > > possible because it comes "out of the box"...) > > > > Thanks. > > > > Mark > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaveh.shahbazian@REDACTED Fri Dec 13 07:31:45 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Fri, 13 Dec 2013 10:01:45 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning Message-ID: I wanted to write something like ((IStringer)object).ToString() (in C#) in Erlang. After some studying I've learnt that Elixir has something called Protocols that pretty much resembles the same thing of C# (in an inside-out manner). Then I came up with this idea/code in Erlang - which is nice enough to me like: ?stringer(my_val):to_string(). And it either returns the expected value or not_implemented atom! But 2 questions: 1 - Why nobody use this or promote things based on stateful modules in Erlang? (OTP aside and from talking to some Erlangers they did not know that actually OTP is built around this! So really there is a need to change how Erlang is being taught and promoted. It's possible that I am confused.). 2 - Why I get this warning? That call actually never fails. The warning: stringer.erl:18: Warning: invalid module and/or function name; this call will always fail stringer.erl:19: Warning: invalid module and/or function name; this call will always fail stringer.erl:20: Warning: invalid module and/or function name; this call will always fail The code: -module(stringer). -export([to_string/1,sample/0]). -define(stringer(V), {stringer, V}). to_string({stringer, V}) when is_list(V) -> to_string(V, nop); to_string({stringer, V}) when is_atom(V) -> to_string(V, nop); to_string({stringer, _V}) -> not_implemented. to_string(V, _Nop) -> Buffer = io_lib:format("~p",[V]), lists:flatten(Buffer). sample() -> io:format("~p~n", [?stringer([1,2]):to_string()]), io:format("~p~n", [?stringer(cute_atom):to_string()]), io:format("~p~n", [?stringer(13):to_string()]). And the output is: "[1,2]" "cute_atom" not_implemented -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmkolesnikov@REDACTED Fri Dec 13 09:10:36 2013 From: dmkolesnikov@REDACTED (Dmitry Kolesnikov) Date: Fri, 13 Dec 2013 10:10:36 +0200 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: Message-ID: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> Hello, Essentially you are trying to use parametrized modules, which get deprecated in R14/15 and dropped from R16. See for details: * http://www.erlang.org/news/35 * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf This type of problems are solvable either via pattern match or currying: -module(stringer). -export([stringer/1,sample/0]). stringer(V) when is_list(V) -> fun() -> to_string(V, nop) end; stringer(V) when is_atom(V) -> fun() -> to_string(V, nop) end; stringer(_V) -> fun() -> not_implemented end. to_string(V, _Nop) -> Buffer = io_lib:format("~p",[V]), lists:flatten(Buffer). sample() -> io:format("~p~n", [(stringer([1,2]))()]), io:format("~p~n", [(stringer(cute_atom))()]), io:format("~p~n", [(stringer(13))()]). Best Regards, Dmitry On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian wrote: > I wanted to write something like ((IStringer)object).ToString() (in C#) in Erlang. After some studying I've learnt that Elixir has something called Protocols that pretty much resembles the same thing of C# (in an inside-out manner). Then I came up with this idea/code in Erlang - which is nice enough to me like: > > ?stringer(my_val):to_string(). > And it either returns the expected value or not_implemented atom! > > But 2 questions: > > 1 - Why nobody use this or promote things based on stateful modules in Erlang? (OTP aside and from talking to some Erlangers they did not know that actually OTP is built around this! So really there is a need to change how Erlang is being taught and promoted. It's possible that I am confused.). > > 2 - Why I get this warning? That call actually never fails. > > The warning: > > stringer.erl:18: Warning: invalid module and/or function name; this call will always fail > stringer.erl:19: Warning: invalid module and/or function name; this call will always fail > stringer.erl:20: Warning: invalid module and/or function name; this call will always fail > The code: > > -module(stringer). > -export([to_string/1,sample/0]). > > -define(stringer(V), {stringer, V}). > > to_string({stringer, V}) when is_list(V) -> > to_string(V, nop); > to_string({stringer, V}) when is_atom(V) -> > to_string(V, nop); > to_string({stringer, _V}) -> > not_implemented. > > to_string(V, _Nop) -> > Buffer = io_lib:format("~p",[V]), > lists:flatten(Buffer). > > sample() -> > io:format("~p~n", [?stringer([1,2]):to_string()]), > io:format("~p~n", [?stringer(cute_atom):to_string()]), > io:format("~p~n", [?stringer(13):to_string()]). > And the output is: > > "[1,2]" > "cute_atom" > not_implemented > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From jose.valim@REDACTED Fri Dec 13 09:27:53 2013 From: jose.valim@REDACTED (=?ISO-8859-1?Q?Jos=E9_Valim?=) Date: Fri, 13 Dec 2013 08:27:53 +0000 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> Message-ID: I have seen this question asked earlier in Stack Overflow and answered it there: http://stackoverflow.com/questions/20556472/elixir-protocols-in-erlang-a-strange-warning/20561973#20561973 I have also reported a bug to erlang-bugs this time. One final note: although parameterized modules were removed from R16, the underlying dispatch mechanism, which is used in the descried issue, is not deprecated and it won't be removed. *Jos? Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer On Fri, Dec 13, 2013 at 8:10 AM, Dmitry Kolesnikov wrote: > Hello, > > Essentially you are trying to use parametrized modules, which get > deprecated in R14/15 and dropped from R16. > See for details: > * http://www.erlang.org/news/35 > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > > This type of problems are solvable either via pattern match or currying: > > -module(stringer). > -export([stringer/1,sample/0]). > > stringer(V) when is_list(V) -> > fun() -> to_string(V, nop) end; > stringer(V) when is_atom(V) -> > fun() -> to_string(V, nop) end; > stringer(_V) -> > fun() -> not_implemented end. > > to_string(V, _Nop) -> > Buffer = io_lib:format("~p",[V]), > lists:flatten(Buffer). > > sample() -> > io:format("~p~n", [(stringer([1,2]))()]), > io:format("~p~n", [(stringer(cute_atom))()]), > io:format("~p~n", [(stringer(13))()]). > > > Best Regards, > Dmitry > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian > wrote: > > I wanted to write something like ((IStringer)object).ToString() (in C#) > in Erlang. After some studying I've learnt that Elixir has something called > Protocols that pretty much resembles the same thing of C# (in an inside-out > manner). Then I came up with this idea/code in Erlang - which is nice > enough to me like: > > ?stringer(my_val):to_string(). > > And it either returns the expected value or not_implemented atom! > > But 2 questions: > > 1 - Why nobody use this or promote things based on stateful modules in > Erlang? (OTP aside and from talking to some Erlangers they did not know > that actually OTP is built around this! So really there is a need to change > how Erlang is being taught and promoted. It's possible that I am confused.). > > 2 - Why I get this warning? That call actually never fails. > > The warning: > > stringer.erl:18: Warning: invalid module and/or function name; this call will always fail > stringer.erl:19: Warning: invalid module and/or function name; this call will always fail > stringer.erl:20: Warning: invalid module and/or function name; this call will always fail > > The code: > > -module(stringer). > -export([to_string/1,sample/0]). > > -define(stringer(V), {stringer, V}). > > to_string({stringer, V}) when is_list(V) -> > to_string(V, nop); > to_string({stringer, V}) when is_atom(V) -> > to_string(V, nop); > to_string({stringer, _V}) -> > not_implemented. > > to_string(V, _Nop) -> > Buffer = io_lib:format("~p",[V]), > lists:flatten(Buffer). > > sample() -> > io:format("~p~n", [?stringer([1,2]):to_string()]), > io:format("~p~n", [?stringer(cute_atom):to_string()]), > io:format("~p~n", [?stringer(13):to_string()]). > > And the output is: > > "[1,2]" > "cute_atom" > not_implemented > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaveh.shahbazian@REDACTED Fri Dec 13 09:25:19 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Fri, 13 Dec 2013 11:55:19 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> Message-ID: I do not thing so. Parametrized modules are different than stateful modules. Parametrized modules are deprecated and they were always provisional. Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked about them and in this same book he was promoting "coming soon" features of R17 and It's highly unlikely for them to be deprecated. Kaveh Shahbazian ?Walking on water and developing software from a specification are easy if both are frozen.? ? Edward Berard On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov wrote: > Hello, > > Essentially you are trying to use parametrized modules, which get > deprecated in R14/15 and dropped from R16. > See for details: > * http://www.erlang.org/news/35 > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > > This type of problems are solvable either via pattern match or currying: > > -module(stringer). > -export([stringer/1,sample/0]). > > stringer(V) when is_list(V) -> > fun() -> to_string(V, nop) end; > stringer(V) when is_atom(V) -> > fun() -> to_string(V, nop) end; > stringer(_V) -> > fun() -> not_implemented end. > > to_string(V, _Nop) -> > Buffer = io_lib:format("~p",[V]), > lists:flatten(Buffer). > > sample() -> > io:format("~p~n", [(stringer([1,2]))()]), > io:format("~p~n", [(stringer(cute_atom))()]), > io:format("~p~n", [(stringer(13))()]). > > > Best Regards, > Dmitry > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian > wrote: > > I wanted to write something like ((IStringer)object).ToString() (in C#) > in Erlang. After some studying I've learnt that Elixir has something called > Protocols that pretty much resembles the same thing of C# (in an inside-out > manner). Then I came up with this idea/code in Erlang - which is nice > enough to me like: > > ?stringer(my_val):to_string(). > > And it either returns the expected value or not_implemented atom! > > But 2 questions: > > 1 - Why nobody use this or promote things based on stateful modules in > Erlang? (OTP aside and from talking to some Erlangers they did not know > that actually OTP is built around this! So really there is a need to change > how Erlang is being taught and promoted. It's possible that I am confused.). > > 2 - Why I get this warning? That call actually never fails. > > The warning: > > stringer.erl:18: Warning: invalid module and/or function name; this call will always fail > stringer.erl:19: Warning: invalid module and/or function name; this call will always fail > stringer.erl:20: Warning: invalid module and/or function name; this call will always fail > > The code: > > -module(stringer). > -export([to_string/1,sample/0]). > > -define(stringer(V), {stringer, V}). > > to_string({stringer, V}) when is_list(V) -> > to_string(V, nop); > to_string({stringer, V}) when is_atom(V) -> > to_string(V, nop); > to_string({stringer, _V}) -> > not_implemented. > > to_string(V, _Nop) -> > Buffer = io_lib:format("~p",[V]), > lists:flatten(Buffer). > > sample() -> > io:format("~p~n", [?stringer([1,2]):to_string()]), > io:format("~p~n", [?stringer(cute_atom):to_string()]), > io:format("~p~n", [?stringer(13):to_string()]). > > And the output is: > > "[1,2]" > "cute_atom" > not_implemented > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaveh.shahbazian@REDACTED Fri Dec 13 09:42:31 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Fri, 13 Dec 2013 12:12:31 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> Message-ID: Thans Jos?; And the part "the underlying dispatch mechanism, which is used in the descried issue, is not deprecated and it won't be removed." really helped my mind to be in peace! Kaveh Shahbazian ?Walking on water and developing software from a specification are easy if both are frozen.? ? Edward Berard On Fri, Dec 13, 2013 at 11:57 AM, Jos? Valim < jose.valim@REDACTED> wrote: > I have seen this question asked earlier in Stack Overflow and answered it > there: > http://stackoverflow.com/questions/20556472/elixir-protocols-in-erlang-a-strange-warning/20561973#20561973 > > I have also reported a bug to erlang-bugs this time. > > One final note: although parameterized modules were removed from R16, the > underlying dispatch mechanism, which is used in the descried issue, is not > deprecated and it won't be removed. > > > > > *Jos? Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Lead Developer > > > On Fri, Dec 13, 2013 at 8:10 AM, Dmitry Kolesnikov > wrote: > >> Hello, >> >> Essentially you are trying to use parametrized modules, which get >> deprecated in R14/15 and dropped from R16. >> See for details: >> * http://www.erlang.org/news/35 >> * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf >> >> This type of problems are solvable either via pattern match or currying: >> >> -module(stringer). >> -export([stringer/1,sample/0]). >> >> stringer(V) when is_list(V) -> >> fun() -> to_string(V, nop) end; >> stringer(V) when is_atom(V) -> >> fun() -> to_string(V, nop) end; >> stringer(_V) -> >> fun() -> not_implemented end. >> >> to_string(V, _Nop) -> >> Buffer = io_lib:format("~p",[V]), >> lists:flatten(Buffer). >> >> sample() -> >> io:format("~p~n", [(stringer([1,2]))()]), >> io:format("~p~n", [(stringer(cute_atom))()]), >> io:format("~p~n", [(stringer(13))()]). >> >> >> Best Regards, >> Dmitry >> >> On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian >> wrote: >> >> I wanted to write something like ((IStringer)object).ToString() (in C#) >> in Erlang. After some studying I've learnt that Elixir has something called >> Protocols that pretty much resembles the same thing of C# (in an inside-out >> manner). Then I came up with this idea/code in Erlang - which is nice >> enough to me like: >> >> ?stringer(my_val):to_string(). >> >> And it either returns the expected value or not_implemented atom! >> >> But 2 questions: >> >> 1 - Why nobody use this or promote things based on stateful modules in >> Erlang? (OTP aside and from talking to some Erlangers they did not know >> that actually OTP is built around this! So really there is a need to change >> how Erlang is being taught and promoted. It's possible that I am confused.). >> >> 2 - Why I get this warning? That call actually never fails. >> >> The warning: >> >> stringer.erl:18: Warning: invalid module and/or function name; this call will always fail >> stringer.erl:19: Warning: invalid module and/or function name; this call will always fail >> stringer.erl:20: Warning: invalid module and/or function name; this call will always fail >> >> The code: >> >> -module(stringer). >> -export([to_string/1,sample/0]). >> >> -define(stringer(V), {stringer, V}). >> >> to_string({stringer, V}) when is_list(V) -> >> to_string(V, nop); >> to_string({stringer, V}) when is_atom(V) -> >> to_string(V, nop); >> to_string({stringer, _V}) -> >> not_implemented. >> >> to_string(V, _Nop) -> >> Buffer = io_lib:format("~p",[V]), >> lists:flatten(Buffer). >> >> sample() -> >> io:format("~p~n", [?stringer([1,2]):to_string()]), >> io:format("~p~n", [?stringer(cute_atom):to_string()]), >> io:format("~p~n", [?stringer(13):to_string()]). >> >> And the output is: >> >> "[1,2]" >> "cute_atom" >> not_implemented >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Fri Dec 13 15:02:25 2013 From: mononcqc@REDACTED (Fred Hebert) Date: Fri, 13 Dec 2013 09:02:25 -0500 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> Message-ID: <20131213140223.GB41386@ferdair.local> Hi. Despite what Joe says in his book, the history of the feature is that tuple calls, the form you're using, were kept to allow the deprecation of parametrized modules. In my humble opinion, the 'stateful module' things you're trying to accomplish for you stringification is non-intuitive and not erlangish (I would be confused by reading that in a code base). May I suggest the simpler form, without changing your module: stringer:to_string(MyValue) instead? You will notice it even saves two characters when being called over: ?stringer(MyValue):to_string(). Without including the macro definition work required, and is more idiomatic overall. To use it as a function, simply use F = fun stringer:to_string/1, F(MyValue). Regards, Fred. On 12/13, Kaveh Shahbazian wrote: > I do not thing so. Parametrized modules are different than stateful > modules. Parametrized modules are deprecated and they were always > provisional. > > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked about > them and in this same book he was promoting "coming soon" features of R17 > and It's highly unlikely for them to be deprecated. > > Kaveh Shahbazian > ?Walking on water and developing software from a specification are easy if > both are frozen.? > ? Edward Berard > > > > > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov > wrote: > > > Hello, > > > > Essentially you are trying to use parametrized modules, which get > > deprecated in R14/15 and dropped from R16. > > See for details: > > * http://www.erlang.org/news/35 > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > > > > This type of problems are solvable either via pattern match or currying: > > > > -module(stringer). > > -export([stringer/1,sample/0]). > > > > stringer(V) when is_list(V) -> > > fun() -> to_string(V, nop) end; > > stringer(V) when is_atom(V) -> > > fun() -> to_string(V, nop) end; > > stringer(_V) -> > > fun() -> not_implemented end. > > > > to_string(V, _Nop) -> > > Buffer = io_lib:format("~p",[V]), > > lists:flatten(Buffer). > > > > sample() -> > > io:format("~p~n", [(stringer([1,2]))()]), > > io:format("~p~n", [(stringer(cute_atom))()]), > > io:format("~p~n", [(stringer(13))()]). > > > > > > Best Regards, > > Dmitry > > > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian > > wrote: > > > > I wanted to write something like ((IStringer)object).ToString() (in C#) > > in Erlang. After some studying I've learnt that Elixir has something called > > Protocols that pretty much resembles the same thing of C# (in an inside-out > > manner). Then I came up with this idea/code in Erlang - which is nice > > enough to me like: > > > > ?stringer(my_val):to_string(). > > > > And it either returns the expected value or not_implemented atom! > > > > But 2 questions: > > > > 1 - Why nobody use this or promote things based on stateful modules in > > Erlang? (OTP aside and from talking to some Erlangers they did not know > > that actually OTP is built around this! So really there is a need to change > > how Erlang is being taught and promoted. It's possible that I am confused.). > > > > 2 - Why I get this warning? That call actually never fails. > > > > The warning: > > > > stringer.erl:18: Warning: invalid module and/or function name; this call will always fail > > stringer.erl:19: Warning: invalid module and/or function name; this call will always fail > > stringer.erl:20: Warning: invalid module and/or function name; this call will always fail > > > > The code: > > > > -module(stringer). > > -export([to_string/1,sample/0]). > > > > -define(stringer(V), {stringer, V}). > > > > to_string({stringer, V}) when is_list(V) -> > > to_string(V, nop); > > to_string({stringer, V}) when is_atom(V) -> > > to_string(V, nop); > > to_string({stringer, _V}) -> > > not_implemented. > > > > to_string(V, _Nop) -> > > Buffer = io_lib:format("~p",[V]), > > lists:flatten(Buffer). > > > > sample() -> > > io:format("~p~n", [?stringer([1,2]):to_string()]), > > io:format("~p~n", [?stringer(cute_atom):to_string()]), > > io:format("~p~n", [?stringer(13):to_string()]). > > > > And the output is: > > > > "[1,2]" > > "cute_atom" > > not_implemented > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From kaveh.shahbazian@REDACTED Fri Dec 13 17:56:08 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Fri, 13 Dec 2013 20:26:08 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: <20131213140223.GB41386@ferdair.local> References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: First "stringer" was a sample for (turned out it was a bad one) simulating protocols. So one could write (it can be more complicated, but whatever): test(V) -> X = ?protocolX(V), X:act1(), X:act2(), % ... X:actN(SomeArguments), OtherThings(). And act1 .. actN are members of 'protocolX'. This way it's clear that 'V' is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). BTW since I am no Erlang guru, I will follow the rules (for a foreseeable future) as you say here. Kaveh Shahbazian ?Walking on water and developing software from a specification are easy if both are frozen.? ? Edward Berard On Fri, Dec 13, 2013 at 5:32 PM, Fred Hebert wrote: > Hi. > > Despite what Joe says in his book, the history of the feature is that > tuple calls, the form you're using, were kept to allow the deprecation > of parametrized modules. > > In my humble opinion, the 'stateful module' things you're trying to > accomplish for you stringification is non-intuitive and not erlangish (I > would be confused by reading that in a code base). May I suggest the > simpler form, without changing your module: > > stringer:to_string(MyValue) > > instead? You will notice it even saves two characters when being called > over: > > ?stringer(MyValue):to_string(). > > Without including the macro definition work required, and is more > idiomatic overall. To use it as a function, simply use > > F = fun stringer:to_string/1, > F(MyValue). > > Regards, > Fred. > > On 12/13, Kaveh Shahbazian wrote: > > I do not thing so. Parametrized modules are different than stateful > > modules. Parametrized modules are deprecated and they were always > > provisional. > > > > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked about > > them and in this same book he was promoting "coming soon" features of R17 > > and It's highly unlikely for them to be deprecated. > > > > Kaveh Shahbazian > > ?Walking on water and developing software from a specification are easy > if > > both are frozen.? > > ? Edward Berard > > > > > > > > > > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov > > wrote: > > > > > Hello, > > > > > > Essentially you are trying to use parametrized modules, which get > > > deprecated in R14/15 and dropped from R16. > > > See for details: > > > * http://www.erlang.org/news/35 > > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > > > > > > This type of problems are solvable either via pattern match or > currying: > > > > > > -module(stringer). > > > -export([stringer/1,sample/0]). > > > > > > stringer(V) when is_list(V) -> > > > fun() -> to_string(V, nop) end; > > > stringer(V) when is_atom(V) -> > > > fun() -> to_string(V, nop) end; > > > stringer(_V) -> > > > fun() -> not_implemented end. > > > > > > to_string(V, _Nop) -> > > > Buffer = io_lib:format("~p",[V]), > > > lists:flatten(Buffer). > > > > > > sample() -> > > > io:format("~p~n", [(stringer([1,2]))()]), > > > io:format("~p~n", [(stringer(cute_atom))()]), > > > io:format("~p~n", [(stringer(13))()]). > > > > > > > > > Best Regards, > > > Dmitry > > > > > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian < > kaveh.shahbazian@REDACTED> > > > wrote: > > > > > > I wanted to write something like ((IStringer)object).ToString() (in C#) > > > in Erlang. After some studying I've learnt that Elixir has something > called > > > Protocols that pretty much resembles the same thing of C# (in an > inside-out > > > manner). Then I came up with this idea/code in Erlang - which is nice > > > enough to me like: > > > > > > ?stringer(my_val):to_string(). > > > > > > And it either returns the expected value or not_implemented atom! > > > > > > But 2 questions: > > > > > > 1 - Why nobody use this or promote things based on stateful modules in > > > Erlang? (OTP aside and from talking to some Erlangers they did not know > > > that actually OTP is built around this! So really there is a need to > change > > > how Erlang is being taught and promoted. It's possible that I am > confused.). > > > > > > 2 - Why I get this warning? That call actually never fails. > > > > > > The warning: > > > > > > stringer.erl:18: Warning: invalid module and/or function name; this > call will always fail > > > stringer.erl:19: Warning: invalid module and/or function name; this > call will always fail > > > stringer.erl:20: Warning: invalid module and/or function name; this > call will always fail > > > > > > The code: > > > > > > -module(stringer). > > > -export([to_string/1,sample/0]). > > > > > > -define(stringer(V), {stringer, V}). > > > > > > to_string({stringer, V}) when is_list(V) -> > > > to_string(V, nop); > > > to_string({stringer, V}) when is_atom(V) -> > > > to_string(V, nop); > > > to_string({stringer, _V}) -> > > > not_implemented. > > > > > > to_string(V, _Nop) -> > > > Buffer = io_lib:format("~p",[V]), > > > lists:flatten(Buffer). > > > > > > sample() -> > > > io:format("~p~n", [?stringer([1,2]):to_string()]), > > > io:format("~p~n", [?stringer(cute_atom):to_string()]), > > > io:format("~p~n", [?stringer(13):to_string()]). > > > > > > And the output is: > > > > > > "[1,2]" > > > "cute_atom" > > > not_implemented > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andra.dinu@REDACTED Fri Dec 13 21:28:03 2013 From: andra.dinu@REDACTED (Andra Dinu) Date: Fri, 13 Dec 2013 21:28:03 +0100 (CET) Subject: [erlang-questions] Erlang Factory SF Bay Area: Very Early Bird tickets released on Monday In-Reply-To: <36480846.416381.1386966052750.JavaMail.zimbra@erlang-solutions.com> Message-ID: <1329000944.416396.1386966483949.JavaMail.zimbra@erlang-solutions.com> Hi all, Just to let you know that on Monday 16 December 2013, after 12:00 PST we will release a batch of 40 tickets at the Very Early Bird rate of $890. The new and improved website for the Erlang Factory San Francisco Bay Area is coming out on Monday, and it will feature a first batch of over 20 speakers. Among them: *?Jos? Valim, author of the Elixir programming language and writer for Pragmatic Programmers will deliver one of the keynotes *Bruce Tate, author of 'Seven Languages in Seven Weeks' talking about getting more out of Elixir pipes *Rick Reed, software engineer at WhatsApp, will describe the challenges of scaling the Erlang/FreeBSD-based server infrastructure at WhatsApp for billions of smartphones *Brett Cameron, senior software architect with HP?s corporate Cloud Services group talking on RabbitMQ, telematics and real-time *Erik Stenman, chief scientist at Klarna, will talk about the ERTS Scheduler *Duncan McGregor, senior manager at Rackspace, will take you on a tour of LFE - a full-fledged language running on the Erlang VM *Bob Ippolito, founder and former CTO of Mochi Media and author of several open source Erlang projects such as mochiweb. Intro to Haskell for Erlangers Keep an eye on this space: http://www.erlang-factory.com/conference/SFBay2014 Cheers, Andra -- Andra Dinu Community & Social ERLANG SOLUTIONS LTD New Loom House 101 Back Church Lane London, E1 1LU United Kingdom Tel +44(0)2076550344 Mob +44(0)7983484387 www.erlang-solutions.com From n.oxyde@REDACTED Sun Dec 15 19:07:16 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Sun, 15 Dec 2013 19:07:16 +0100 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: References: <51C1F735.5040706@comcast.net> <7399173B-E72B-409C-BC0F-EDF737CAAB1A@cs.otago.ac.nz> <51C31FE4.4030100@comcast.net> <51C39FA3.5020907@comcast.net> <7B6C2A52-CBEA-4439-B886-788F780D913A@cs.otago.ac.nz> <51C3CB52.70906@comcast.net> <3ED3C4FC-2C69-45EC-9799-87D7F60AC094@cs.otago.ac.nz> <84CCF390-5221-4457-BB76-CB6FA9639DF7@gmail.com> <1a467e5a828a2d39bb1eeb2c2a25fcf7.squirrel@chasm.otago.ac.nz> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> Message-ID: <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> Hello, I?ve thought about this again and realised that there is a technical reason not to expand cond expressions to nested cases directly. That reason is scoping rules. Let?s assume we compile this expression naively to nested cases: cond X = false -> X; X = true -> X end => case X = false of true -> X; false -> case X = true of true -> X; end end. I would be *extremely* surprised that such an expression would crash with badmatch instead of returning true as it should. Regards, -- Anthony Ramine Le 9 juil. 2013 ? 00:12, Richard A. O'Keefe a ?crit : > > On 8/07/2013, at 8:35 PM, Anthony Ramine wrote: > >> No this example was just confusing, what I meant is that if you need a warning "no clause will ever match" in the case of an explicit "case foobar of true -> ok; false -> ok end" and a warning "this clause will crash" in the case of "cond foobar -> ok; true -> ok end". There is no rewording that makes the warning fit in both situations, they need to be handled separately. > > In the English text here you have an "if" with no consequent. > > case foobar of true -> ok ; false -> ok end > > Yes, it is appropriate to say "No matching clause" here. > > As for > > cond foobar -> {ok,1} ; true-> {ok,2} end > > this should *BE* > > case foobar > of true -> {ok,1} > ; false -> case true of true -> {ok,2} end > end > > and no error message is appropriate here because there > *is* a clause that will match and be selected. It is only > true that the two situations need separate handling because > one of them is not an error. > > Another not-entirely-unreasonable translation of > > cond C1 -> B1 ; ... ; Cn -> Bn end > > would be > > case (C1 andalso true) > of true -> B1 > ; false -> ... > case (Cn andalso true) > of true -> Bn > end > end > > and in this case you might just possibly get a warning from > the compiler that might just possibly actually be useful > (unlike 'this clause will crash'): you might be told > "expression cannot be Boolean". > > It could *never* be appropriate to say "this clause will crash" > for the simple reason that it's *not* the clause that would > crash but the *condition* of the clause. "This condition cannot > be Boolean" might make sense, but not the other. > From bob@REDACTED Fri Dec 13 19:06:56 2013 From: bob@REDACTED (Bob Ippolito) Date: Fri, 13 Dec 2013 10:06:56 -0800 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: I think you're a bit confused here, because your implementation of ?protocolX(?) doesn't work like Elixir protocols. The trouble with implementing this in Erlang is that in order to do it you need to have some mutable data structure in the runtime that changes based on which modules are loaded, since any module can define an implementation for some protocol. Elixir's defprotocol just creates a new module for the given protocol (e.g. 'Elixir.Enum'), and defimpl creates a separate module for each implementation of a protocol (e.g. 'Elixir.Enum.List'). Erlang simply does not have any built-in support for the kind of dispatch you're looking for. Parameterized modules were similar to what you are proposing (but not like Elixir's protocols!), but they have been deprecated. If you really feel the need to write very generic code, maybe Erlang is not the language for you. Erlang works best when you can do everything with concrete implementations. Elixir would likely fit more abstract use cases better, but note that there is some runtime performance cost for this indirection. Haskell's type classes are also quite interesting too, as the import of a type class instance doesn't propagate beyond the compilation unit so you don't have as much of a namespace issue. The compiler can also get rid of the indirection in most cases so there's not necessarily any cost for using abstractions in that universe. In any case, I can't think of a way to reasonably implement this in Erlang using idioms that mesh well with the rest of Erlang. There is no OTP standard for this kind of thing, and there isn't likely to be a good way to do it any time soon. If there was an OTP "interface" standard, surely we'd have a hook to customize what "~p" means to io_lib for our own types! But alas, we can't really even define our own abstract data types in Erlang, just type aliases over the built-in concrete types. -bob On Fri, Dec 13, 2013 at 8:56 AM, Kaveh Shahbazian < kaveh.shahbazian@REDACTED> wrote: > First "stringer" was a sample for (turned out it was a bad one) simulating > protocols. So one could write (it can be more complicated, but whatever): > > test(V) -> > X = ?protocolX(V), > X:act1(), > X:act2(), > % ... > X:actN(SomeArguments), > OtherThings(). > > And act1 .. actN are members of 'protocolX'. This way it's clear that 'V' > is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). > > BTW since I am no Erlang guru, I will follow the rules (for a foreseeable > future) as you say here. > > Kaveh Shahbazian > ?Walking on water and developing software from a specification are easy if > both are frozen.? > ? Edward Berard > > > > > On Fri, Dec 13, 2013 at 5:32 PM, Fred Hebert wrote: > >> Hi. >> >> Despite what Joe says in his book, the history of the feature is that >> tuple calls, the form you're using, were kept to allow the deprecation >> of parametrized modules. >> >> In my humble opinion, the 'stateful module' things you're trying to >> accomplish for you stringification is non-intuitive and not erlangish (I >> would be confused by reading that in a code base). May I suggest the >> simpler form, without changing your module: >> >> stringer:to_string(MyValue) >> >> instead? You will notice it even saves two characters when being called >> over: >> >> ?stringer(MyValue):to_string(). >> >> Without including the macro definition work required, and is more >> idiomatic overall. To use it as a function, simply use >> >> F = fun stringer:to_string/1, >> F(MyValue). >> >> Regards, >> Fred. >> >> On 12/13, Kaveh Shahbazian wrote: >> > I do not thing so. Parametrized modules are different than stateful >> > modules. Parametrized modules are deprecated and they were always >> > provisional. >> > >> > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked about >> > them and in this same book he was promoting "coming soon" features of >> R17 >> > and It's highly unlikely for them to be deprecated. >> > >> > Kaveh Shahbazian >> > ?Walking on water and developing software from a specification are easy >> if >> > both are frozen.? >> > ? Edward Berard >> > >> > >> > >> > >> > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov >> > wrote: >> > >> > > Hello, >> > > >> > > Essentially you are trying to use parametrized modules, which get >> > > deprecated in R14/15 and dropped from R16. >> > > See for details: >> > > * http://www.erlang.org/news/35 >> > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf >> > > >> > > This type of problems are solvable either via pattern match or >> currying: >> > > >> > > -module(stringer). >> > > -export([stringer/1,sample/0]). >> > > >> > > stringer(V) when is_list(V) -> >> > > fun() -> to_string(V, nop) end; >> > > stringer(V) when is_atom(V) -> >> > > fun() -> to_string(V, nop) end; >> > > stringer(_V) -> >> > > fun() -> not_implemented end. >> > > >> > > to_string(V, _Nop) -> >> > > Buffer = io_lib:format("~p",[V]), >> > > lists:flatten(Buffer). >> > > >> > > sample() -> >> > > io:format("~p~n", [(stringer([1,2]))()]), >> > > io:format("~p~n", [(stringer(cute_atom))()]), >> > > io:format("~p~n", [(stringer(13))()]). >> > > >> > > >> > > Best Regards, >> > > Dmitry >> > > >> > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian < >> kaveh.shahbazian@REDACTED> >> > > wrote: >> > > >> > > I wanted to write something like ((IStringer)object).ToString() (in >> C#) >> > > in Erlang. After some studying I've learnt that Elixir has something >> called >> > > Protocols that pretty much resembles the same thing of C# (in an >> inside-out >> > > manner). Then I came up with this idea/code in Erlang - which is nice >> > > enough to me like: >> > > >> > > ?stringer(my_val):to_string(). >> > > >> > > And it either returns the expected value or not_implemented atom! >> > > >> > > But 2 questions: >> > > >> > > 1 - Why nobody use this or promote things based on stateful modules in >> > > Erlang? (OTP aside and from talking to some Erlangers they did not >> know >> > > that actually OTP is built around this! So really there is a need to >> change >> > > how Erlang is being taught and promoted. It's possible that I am >> confused.). >> > > >> > > 2 - Why I get this warning? That call actually never fails. >> > > >> > > The warning: >> > > >> > > stringer.erl:18: Warning: invalid module and/or function name; this >> call will always fail >> > > stringer.erl:19: Warning: invalid module and/or function name; this >> call will always fail >> > > stringer.erl:20: Warning: invalid module and/or function name; this >> call will always fail >> > > >> > > The code: >> > > >> > > -module(stringer). >> > > -export([to_string/1,sample/0]). >> > > >> > > -define(stringer(V), {stringer, V}). >> > > >> > > to_string({stringer, V}) when is_list(V) -> >> > > to_string(V, nop); >> > > to_string({stringer, V}) when is_atom(V) -> >> > > to_string(V, nop); >> > > to_string({stringer, _V}) -> >> > > not_implemented. >> > > >> > > to_string(V, _Nop) -> >> > > Buffer = io_lib:format("~p",[V]), >> > > lists:flatten(Buffer). >> > > >> > > sample() -> >> > > io:format("~p~n", [?stringer([1,2]):to_string()]), >> > > io:format("~p~n", [?stringer(cute_atom):to_string()]), >> > > io:format("~p~n", [?stringer(13):to_string()]). >> > > >> > > And the output is: >> > > >> > > "[1,2]" >> > > "cute_atom" >> > > not_implemented >> > > >> > > _______________________________________________ >> > > erlang-questions mailing list >> > > erlang-questions@REDACTED >> > > http://erlang.org/mailman/listinfo/erlang-questions >> > > >> > > >> > > >> >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Sun Dec 15 19:49:52 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Sun, 15 Dec 2013 22:49:52 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? Message-ID: Hi. I'm trying to launch erlyvideo on Tilera 36 core machine. I've configured: ./configure --prefix=/opt/flussonic --enable-smp-support --enable-kernel-poll --disable-hipe --with-ssl --without-java then make stops with: make[2]: Entering directory `/root/otp_src_R16B02/erts/emulator' make -f tilegx-unknown-linux-gnu/Makefile TYPE=opt make[3]: Entering directory `/root/otp_src_R16B02/erts/emulator' if utils/gen_git_version tilegx-unknown-linux-gnu/gen_git_version.mk; then touch beam/erl_bif_info.c; fi gcc -Werror=return-type -g -O2 -I/root/otp_src_R16B02/erts/tilegx-unknown-linux-gnu -fno-tree-copyrename -D_GNU_SOURCE -DERTS_SMP -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -Itilegx-unknown-linux-gnu/opt/smp -Ibeam -Isys/unix -Isys/common -Itilegx-unknown-linux-gnu -Izlib -Ipcre -Ihipe -I../include -I../include/tilegx-unknown-linux-gnu -I../include/internal -I../include/internal/tilegx-unknown-linux-gnu -c sys/unix/sys.c -o obj/tilegx-unknown-linux-gnu/opt/smp/sys.o sys/unix/sys.c:412: error: expected declaration specifiers or ?...? before numeric constant sys/unix/sys.c:412: warning: data definition has no type or storage class sys/unix/sys.c:412: warning: type defaults to ?int? in declaration of ?MALLOC_USE_HASH? sys/unix/sys.c:412: warning: function declaration isn?t a prototype make[3]: *** [obj/tilegx-unknown-linux-gnu/opt/smp/sys.o] Error 1 make[3]: Leaving directory `/root/otp_src_R16B02/erts/emulator' make[2]: *** [opt] Error 2 make[2]: Leaving directory `/root/otp_src_R16B02/erts/emulator' make[1]: *** [smp] Error 2 make[1]: Leaving directory `/root/otp_src_R16B02/erts' make: *** [emulator] Error 2 This tilera computer has Centos installed with erlang R14B04. What information should I provide to find out, why does MALLOC_USE_HASH breaks compile process? -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Sun Dec 15 19:59:54 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Sun, 15 Dec 2013 10:59:54 -0800 (PST) Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: Message-ID: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> This paper: http://www.tilera.com/scm/docs/UG105-Optimization-Guide.pdf tells that: The MALLOC_USE_HASH() macro is removed. You can control the hash-for-home behavior of the heap by means of the ucache_hash kernel boot-time argument or the LD_CACHE_HASH environment variable. Should I just comment this line in sys.c or need to add some parameters for better performance? -------------- next part -------------- An HTML attachment was scrubbed... URL: From desired.mta@REDACTED Sun Dec 15 20:18:51 2013 From: desired.mta@REDACTED (=?UTF-8?Q?Motiejus_Jak=C5=A1tys?=) Date: Sun, 15 Dec 2013 20:18:51 +0100 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> Message-ID: On Sun, Dec 15, 2013 at 7:59 PM, Max Lapshin wrote: > This paper: http://www.tilera.com/scm/docs/UG105-Optimization-Guide.pdf > > tells that: > > The MALLOC_USE_HASH() macro is removed. You can control the hash-for-home > behavior > of the heap by means of the ucache_hash kernel boot-time argument or the > LD_CACHE_HASH > environment variable. > > Should I just comment this line in sys.c or need to add some parameters for > better performance? Try with a patch I just resubmitted (apparently it got lost and I forgot about it when I submitted it ~year ago): https://github.com/erlang/otp/pull/169 This is R15B02 work. I am very interested if it also helps for R16. Motiejus From kaveh.shahbazian@REDACTED Fri Dec 13 19:19:29 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Fri, 13 Dec 2013 21:49:29 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: "The trouble with implementing this in Erlang is that in order to do it you need to have some mutable data structure in the runtime that changes based on which modules are loaded"; >From this I assume you say this is not possible in Erlang but *this thing already works in Erlang* and does not mutate anything. So it is already implemented in Erlang. Now are you suggesting this is a bad practice? And should be avoided? Kaveh Shahbazian ?Walking on water and developing software from a specification are easy if both are frozen.? ? Edward Berard On Fri, Dec 13, 2013 at 9:36 PM, Bob Ippolito wrote: > I think you're a bit confused here, because your implementation of > ?protocolX(?) doesn't work like Elixir protocols. The trouble with > implementing this in Erlang is that in order to do it you need to have some > mutable data structure in the runtime that changes based on which modules > are loaded, since any module can define an implementation for some > protocol. Elixir's defprotocol just creates a new module for the given > protocol (e.g. 'Elixir.Enum'), and defimpl creates a separate module for > each implementation of a protocol (e.g. 'Elixir.Enum.List'). > > Erlang simply does not have any built-in support for the kind of dispatch > you're looking for. Parameterized modules were similar to what you are > proposing (but not like Elixir's protocols!), but they have been > deprecated. If you really feel the need to write very generic code, maybe > Erlang is not the language for you. Erlang works best when you can do > everything with concrete implementations. Elixir would likely fit more > abstract use cases better, but note that there is some runtime performance > cost for this indirection. > > Haskell's type classes are also quite interesting too, as the import of a > type class instance doesn't propagate beyond the compilation unit so you > don't have as much of a namespace issue. The compiler can also get rid of > the indirection in most cases so there's not necessarily any cost for using > abstractions in that universe. > > In any case, I can't think of a way to reasonably implement this in Erlang > using idioms that mesh well with the rest of Erlang. There is no OTP > standard for this kind of thing, and there isn't likely to be a good way to > do it any time soon. If there was an OTP "interface" standard, surely we'd > have a hook to customize what "~p" means to io_lib for our own types! But > alas, we can't really even define our own abstract data types in Erlang, > just type aliases over the built-in concrete types. > > -bob > > > > On Fri, Dec 13, 2013 at 8:56 AM, Kaveh Shahbazian < > kaveh.shahbazian@REDACTED> wrote: > >> First "stringer" was a sample for (turned out it was a bad one) >> simulating protocols. So one could write (it can be more complicated, but >> whatever): >> >> test(V) -> >> X = ?protocolX(V), >> X:act1(), >> X:act2(), >> % ... >> X:actN(SomeArguments), >> OtherThings(). >> >> And act1 .. actN are members of 'protocolX'. This way it's clear that 'V' >> is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). >> >> BTW since I am no Erlang guru, I will follow the rules (for a foreseeable >> future) as you say here. >> >> Kaveh Shahbazian >> ?Walking on water and developing software from a specification are easy >> if both are frozen.? >> ? Edward Berard >> >> >> >> >> On Fri, Dec 13, 2013 at 5:32 PM, Fred Hebert wrote: >> >>> Hi. >>> >>> Despite what Joe says in his book, the history of the feature is that >>> tuple calls, the form you're using, were kept to allow the deprecation >>> of parametrized modules. >>> >>> In my humble opinion, the 'stateful module' things you're trying to >>> accomplish for you stringification is non-intuitive and not erlangish (I >>> would be confused by reading that in a code base). May I suggest the >>> simpler form, without changing your module: >>> >>> stringer:to_string(MyValue) >>> >>> instead? You will notice it even saves two characters when being called >>> over: >>> >>> ?stringer(MyValue):to_string(). >>> >>> Without including the macro definition work required, and is more >>> idiomatic overall. To use it as a function, simply use >>> >>> F = fun stringer:to_string/1, >>> F(MyValue). >>> >>> Regards, >>> Fred. >>> >>> On 12/13, Kaveh Shahbazian wrote: >>> > I do not thing so. Parametrized modules are different than stateful >>> > modules. Parametrized modules are deprecated and they were always >>> > provisional. >>> > >>> > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked >>> about >>> > them and in this same book he was promoting "coming soon" features of >>> R17 >>> > and It's highly unlikely for them to be deprecated. >>> > >>> > Kaveh Shahbazian >>> > ?Walking on water and developing software from a specification are >>> easy if >>> > both are frozen.? >>> > ? Edward Berard >>> > >>> > >>> > >>> > >>> > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov >>> > wrote: >>> > >>> > > Hello, >>> > > >>> > > Essentially you are trying to use parametrized modules, which get >>> > > deprecated in R14/15 and dropped from R16. >>> > > See for details: >>> > > * http://www.erlang.org/news/35 >>> > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf >>> > > >>> > > This type of problems are solvable either via pattern match or >>> currying: >>> > > >>> > > -module(stringer). >>> > > -export([stringer/1,sample/0]). >>> > > >>> > > stringer(V) when is_list(V) -> >>> > > fun() -> to_string(V, nop) end; >>> > > stringer(V) when is_atom(V) -> >>> > > fun() -> to_string(V, nop) end; >>> > > stringer(_V) -> >>> > > fun() -> not_implemented end. >>> > > >>> > > to_string(V, _Nop) -> >>> > > Buffer = io_lib:format("~p",[V]), >>> > > lists:flatten(Buffer). >>> > > >>> > > sample() -> >>> > > io:format("~p~n", [(stringer([1,2]))()]), >>> > > io:format("~p~n", [(stringer(cute_atom))()]), >>> > > io:format("~p~n", [(stringer(13))()]). >>> > > >>> > > >>> > > Best Regards, >>> > > Dmitry >>> > > >>> > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian < >>> kaveh.shahbazian@REDACTED> >>> > > wrote: >>> > > >>> > > I wanted to write something like ((IStringer)object).ToString() (in >>> C#) >>> > > in Erlang. After some studying I've learnt that Elixir has something >>> called >>> > > Protocols that pretty much resembles the same thing of C# (in an >>> inside-out >>> > > manner). Then I came up with this idea/code in Erlang - which is nice >>> > > enough to me like: >>> > > >>> > > ?stringer(my_val):to_string(). >>> > > >>> > > And it either returns the expected value or not_implemented atom! >>> > > >>> > > But 2 questions: >>> > > >>> > > 1 - Why nobody use this or promote things based on stateful modules >>> in >>> > > Erlang? (OTP aside and from talking to some Erlangers they did not >>> know >>> > > that actually OTP is built around this! So really there is a need to >>> change >>> > > how Erlang is being taught and promoted. It's possible that I am >>> confused.). >>> > > >>> > > 2 - Why I get this warning? That call actually never fails. >>> > > >>> > > The warning: >>> > > >>> > > stringer.erl:18: Warning: invalid module and/or function name; this >>> call will always fail >>> > > stringer.erl:19: Warning: invalid module and/or function name; this >>> call will always fail >>> > > stringer.erl:20: Warning: invalid module and/or function name; this >>> call will always fail >>> > > >>> > > The code: >>> > > >>> > > -module(stringer). >>> > > -export([to_string/1,sample/0]). >>> > > >>> > > -define(stringer(V), {stringer, V}). >>> > > >>> > > to_string({stringer, V}) when is_list(V) -> >>> > > to_string(V, nop); >>> > > to_string({stringer, V}) when is_atom(V) -> >>> > > to_string(V, nop); >>> > > to_string({stringer, _V}) -> >>> > > not_implemented. >>> > > >>> > > to_string(V, _Nop) -> >>> > > Buffer = io_lib:format("~p",[V]), >>> > > lists:flatten(Buffer). >>> > > >>> > > sample() -> >>> > > io:format("~p~n", [?stringer([1,2]):to_string()]), >>> > > io:format("~p~n", [?stringer(cute_atom):to_string()]), >>> > > io:format("~p~n", [?stringer(13):to_string()]). >>> > > >>> > > And the output is: >>> > > >>> > > "[1,2]" >>> > > "cute_atom" >>> > > not_implemented >>> > > >>> > > _______________________________________________ >>> > > erlang-questions mailing list >>> > > erlang-questions@REDACTED >>> > > http://erlang.org/mailman/listinfo/erlang-questions >>> > > >>> > > >>> > > >>> >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questions@REDACTED >>> > http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Fri Dec 13 19:47:30 2013 From: bob@REDACTED (Bob Ippolito) Date: Fri, 13 Dec 2013 10:47:30 -0800 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: What you have implemented *is not protocols*, so the details of your implementation of "non-extensible protocols" are irrelevant. I certainly have not said that it is not possible in Erlang, because it *obviously* is possible to have protocols given that Elixir does it with the same runtime. What I have said is that it's not idiomatic to do such things, so you should probably try and solve your problems in a different way, with more concrete implementations (such as explicit passing of funs or {Module, State} tuples). As Fred said, there's a simple mechanical transformation from tuple funs (what you have called "stateful modules") to standard Erlang code. Fred's translation is slightly off though, for some reason the module name is included in the argument tuple. %% Using tuple calls (*strongly* discouraged) f(M, Arg) -> M:call(Arg). %% Without tuple calls f({M, State}, Arg) -> M:call(Arg, {M, State}). I am suggesting that what you have proposed is bad practice. There are other ways to implement exactly what you have shown with only a little bit more syntax. See http://www.erlang.org/doc/efficiency_guide/functions.html for official documentation on tuple funs. In summary: they exist and are supported by the runtime for compatibility reasons, but their implementation is slow and their use is strongly discouraged. -bob On Fri, Dec 13, 2013 at 10:19 AM, Kaveh Shahbazian < kaveh.shahbazian@REDACTED> wrote: > "The trouble with implementing this in Erlang is that in order to do it > you need to have some mutable data structure in the runtime that changes > based on which modules are loaded"; > > From this I assume you say this is not possible in Erlang but *this thing > already works in Erlang* and does not mutate anything. So it is already > implemented in Erlang. > > Now are you suggesting this is a bad practice? And should be avoided? > > Kaveh Shahbazian > ?Walking on water and developing software from a specification are easy if > both are frozen.? > ? Edward Berard > > > > > On Fri, Dec 13, 2013 at 9:36 PM, Bob Ippolito wrote: > >> I think you're a bit confused here, because your implementation of >> ?protocolX(?) doesn't work like Elixir protocols. The trouble with >> implementing this in Erlang is that in order to do it you need to have some >> mutable data structure in the runtime that changes based on which modules >> are loaded, since any module can define an implementation for some >> protocol. Elixir's defprotocol just creates a new module for the given >> protocol (e.g. 'Elixir.Enum'), and defimpl creates a separate module for >> each implementation of a protocol (e.g. 'Elixir.Enum.List'). >> >> Erlang simply does not have any built-in support for the kind of dispatch >> you're looking for. Parameterized modules were similar to what you are >> proposing (but not like Elixir's protocols!), but they have been >> deprecated. If you really feel the need to write very generic code, maybe >> Erlang is not the language for you. Erlang works best when you can do >> everything with concrete implementations. Elixir would likely fit more >> abstract use cases better, but note that there is some runtime performance >> cost for this indirection. >> >> Haskell's type classes are also quite interesting too, as the import of a >> type class instance doesn't propagate beyond the compilation unit so you >> don't have as much of a namespace issue. The compiler can also get rid of >> the indirection in most cases so there's not necessarily any cost for using >> abstractions in that universe. >> >> In any case, I can't think of a way to reasonably implement this in >> Erlang using idioms that mesh well with the rest of Erlang. There is no OTP >> standard for this kind of thing, and there isn't likely to be a good way to >> do it any time soon. If there was an OTP "interface" standard, surely we'd >> have a hook to customize what "~p" means to io_lib for our own types! But >> alas, we can't really even define our own abstract data types in Erlang, >> just type aliases over the built-in concrete types. >> >> -bob >> >> >> >> On Fri, Dec 13, 2013 at 8:56 AM, Kaveh Shahbazian < >> kaveh.shahbazian@REDACTED> wrote: >> >>> First "stringer" was a sample for (turned out it was a bad one) >>> simulating protocols. So one could write (it can be more complicated, but >>> whatever): >>> >>> test(V) -> >>> X = ?protocolX(V), >>> X:act1(), >>> X:act2(), >>> % ... >>> X:actN(SomeArguments), >>> OtherThings(). >>> >>> And act1 .. actN are members of 'protocolX'. This way it's clear that >>> 'V' is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). >>> >>> BTW since I am no Erlang guru, I will follow the rules (for >>> a foreseeable future) as you say here. >>> >>> Kaveh Shahbazian >>> ?Walking on water and developing software from a specification are easy >>> if both are frozen.? >>> ? Edward Berard >>> >>> >>> >>> >>> On Fri, Dec 13, 2013 at 5:32 PM, Fred Hebert wrote: >>> >>>> Hi. >>>> >>>> Despite what Joe says in his book, the history of the feature is that >>>> tuple calls, the form you're using, were kept to allow the deprecation >>>> of parametrized modules. >>>> >>>> In my humble opinion, the 'stateful module' things you're trying to >>>> accomplish for you stringification is non-intuitive and not erlangish (I >>>> would be confused by reading that in a code base). May I suggest the >>>> simpler form, without changing your module: >>>> >>>> stringer:to_string(MyValue) >>>> >>>> instead? You will notice it even saves two characters when being called >>>> over: >>>> >>>> ?stringer(MyValue):to_string(). >>>> >>>> Without including the macro definition work required, and is more >>>> idiomatic overall. To use it as a function, simply use >>>> >>>> F = fun stringer:to_string/1, >>>> F(MyValue). >>>> >>>> Regards, >>>> Fred. >>>> >>>> On 12/13, Kaveh Shahbazian wrote: >>>> > I do not thing so. Parametrized modules are different than stateful >>>> > modules. Parametrized modules are deprecated and they were always >>>> > provisional. >>>> > >>>> > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked >>>> about >>>> > them and in this same book he was promoting "coming soon" features of >>>> R17 >>>> > and It's highly unlikely for them to be deprecated. >>>> > >>>> > Kaveh Shahbazian >>>> > ?Walking on water and developing software from a specification are >>>> easy if >>>> > both are frozen.? >>>> > ? Edward Berard >>>> > >>>> > >>>> > >>>> > >>>> > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov >>>> > wrote: >>>> > >>>> > > Hello, >>>> > > >>>> > > Essentially you are trying to use parametrized modules, which get >>>> > > deprecated in R14/15 and dropped from R16. >>>> > > See for details: >>>> > > * http://www.erlang.org/news/35 >>>> > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf >>>> > > >>>> > > This type of problems are solvable either via pattern match or >>>> currying: >>>> > > >>>> > > -module(stringer). >>>> > > -export([stringer/1,sample/0]). >>>> > > >>>> > > stringer(V) when is_list(V) -> >>>> > > fun() -> to_string(V, nop) end; >>>> > > stringer(V) when is_atom(V) -> >>>> > > fun() -> to_string(V, nop) end; >>>> > > stringer(_V) -> >>>> > > fun() -> not_implemented end. >>>> > > >>>> > > to_string(V, _Nop) -> >>>> > > Buffer = io_lib:format("~p",[V]), >>>> > > lists:flatten(Buffer). >>>> > > >>>> > > sample() -> >>>> > > io:format("~p~n", [(stringer([1,2]))()]), >>>> > > io:format("~p~n", [(stringer(cute_atom))()]), >>>> > > io:format("~p~n", [(stringer(13))()]). >>>> > > >>>> > > >>>> > > Best Regards, >>>> > > Dmitry >>>> > > >>>> > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian < >>>> kaveh.shahbazian@REDACTED> >>>> > > wrote: >>>> > > >>>> > > I wanted to write something like ((IStringer)object).ToString() (in >>>> C#) >>>> > > in Erlang. After some studying I've learnt that Elixir has >>>> something called >>>> > > Protocols that pretty much resembles the same thing of C# (in an >>>> inside-out >>>> > > manner). Then I came up with this idea/code in Erlang - which is >>>> nice >>>> > > enough to me like: >>>> > > >>>> > > ?stringer(my_val):to_string(). >>>> > > >>>> > > And it either returns the expected value or not_implemented atom! >>>> > > >>>> > > But 2 questions: >>>> > > >>>> > > 1 - Why nobody use this or promote things based on stateful modules >>>> in >>>> > > Erlang? (OTP aside and from talking to some Erlangers they did not >>>> know >>>> > > that actually OTP is built around this! So really there is a need >>>> to change >>>> > > how Erlang is being taught and promoted. It's possible that I am >>>> confused.). >>>> > > >>>> > > 2 - Why I get this warning? That call actually never fails. >>>> > > >>>> > > The warning: >>>> > > >>>> > > stringer.erl:18: Warning: invalid module and/or function name; this >>>> call will always fail >>>> > > stringer.erl:19: Warning: invalid module and/or function name; this >>>> call will always fail >>>> > > stringer.erl:20: Warning: invalid module and/or function name; this >>>> call will always fail >>>> > > >>>> > > The code: >>>> > > >>>> > > -module(stringer). >>>> > > -export([to_string/1,sample/0]). >>>> > > >>>> > > -define(stringer(V), {stringer, V}). >>>> > > >>>> > > to_string({stringer, V}) when is_list(V) -> >>>> > > to_string(V, nop); >>>> > > to_string({stringer, V}) when is_atom(V) -> >>>> > > to_string(V, nop); >>>> > > to_string({stringer, _V}) -> >>>> > > not_implemented. >>>> > > >>>> > > to_string(V, _Nop) -> >>>> > > Buffer = io_lib:format("~p",[V]), >>>> > > lists:flatten(Buffer). >>>> > > >>>> > > sample() -> >>>> > > io:format("~p~n", [?stringer([1,2]):to_string()]), >>>> > > io:format("~p~n", [?stringer(cute_atom):to_string()]), >>>> > > io:format("~p~n", [?stringer(13):to_string()]). >>>> > > >>>> > > And the output is: >>>> > > >>>> > > "[1,2]" >>>> > > "cute_atom" >>>> > > not_implemented >>>> > > >>>> > > _______________________________________________ >>>> > > erlang-questions mailing list >>>> > > erlang-questions@REDACTED >>>> > > http://erlang.org/mailman/listinfo/erlang-questions >>>> > > >>>> > > >>>> > > >>>> >>>> > _______________________________________________ >>>> > erlang-questions mailing list >>>> > erlang-questions@REDACTED >>>> > http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.justinek@REDACTED Sun Dec 15 20:51:31 2013 From: denis.justinek@REDACTED (Denis Justinek) Date: Sun, 15 Dec 2013 20:51:31 +0100 Subject: [erlang-questions] Debugger hangs In-Reply-To: References: Message-ID: Hello. Has anyone found a solution to this problem? It can also be reproduced on OS X 10.8 / 10.9 : Resizing the debugger window freezes the GUI and makes it unresponsive. -- Denis 2013/9/3 Yves S. Garret > Hello, > > I'm running this on a Mac OS X 10.7.5. I have release 16B01. Whenever I > start up the debugger > and then increase the size of the windows (by dragging the borders), the > whole setup just hangs. It > doesn't come back to me, but sits there and doesn't do anything. > > Has anyone else had this problem? How did you get around it? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zambal@REDACTED Fri Dec 13 20:23:00 2013 From: zambal@REDACTED (Vincent Siliakus) Date: Fri, 13 Dec 2013 20:23:00 +0100 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning Message-ID: If you want to simulate Elixir's protocols in Erlang in a (arguably) more idiomatic way, you could do something like this: % Enumerable protocol API -module(enumerable). -export([behaviour_info/1, map/2]). -callback map(F :: fun(), T :: any()) -> any(). map(F, T) -> Mod = element(1, T), Mod:map(F, T). ------------------------------------ % Enumerable protocol implementation 1 -module(mytype_1). -export([new/1, map/2]). -behaviour(enumerable). -record(mytype_1, { list }). new(List) -> #mytype_1{ list = List }. map(F, #mytype_1{ list = L }) -> #mytype_1{ list = lists:map(F, L) }. ------------------------------------ % Enumerable protocol implementation 2 -module(mytype_2). -export([new/1, map/2]). -behaviour(enumerable). -record(mytype_2, { array }). new(List) -> #mytype_2{ array = array:from_list(List) }. map(F, #mytype_2{ array = A }) -> #mytype_2{ array = array:map(fun(_I, X) -> F(X) end, A) }. ------------------------------------ 1> T = mytype_1:new([1,2,3,4]). {mytype_1, [1,2,3,4]} 2> enumerable:map(fun(X) -> X + X end, T). {mytype_1, [2, 4, 6, 8]} I didn't try to compile the above, so it may contain typo's, but I guess you get the idea I'm getting at. -vincent From mononcqc@REDACTED Fri Dec 13 19:18:50 2013 From: mononcqc@REDACTED (Fred Hebert) Date: Fri, 13 Dec 2013 13:18:50 -0500 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: <20131213181848.GC41386@ferdair.local> The old parametrized module form can literally be translated from f(M, SomeArg) -> M:call(SomeArg). into: f({M,State}, SomeArg) -> M:call(SomeArg, State). It is more verbose, but will not come at any cost in terms of genericity and will not mess up tracing and anything else the way parametrized modules used to. You are right, however, that Erlang doesn't really have a thing like protocols, which are a pretty neat feature in languages that can provide a solid implementation for them. Regards, Fred. On 12/13, Bob Ippolito wrote: > I think you're a bit confused here, because your implementation of > ?protocolX(?) doesn't work like Elixir protocols. The trouble with > implementing this in Erlang is that in order to do it you need to have some > mutable data structure in the runtime that changes based on which modules > are loaded, since any module can define an implementation for some > protocol. Elixir's defprotocol just creates a new module for the given > protocol (e.g. 'Elixir.Enum'), and defimpl creates a separate module for > each implementation of a protocol (e.g. 'Elixir.Enum.List'). > > Erlang simply does not have any built-in support for the kind of dispatch > you're looking for. Parameterized modules were similar to what you are > proposing (but not like Elixir's protocols!), but they have been > deprecated. If you really feel the need to write very generic code, maybe > Erlang is not the language for you. Erlang works best when you can do > everything with concrete implementations. Elixir would likely fit more > abstract use cases better, but note that there is some runtime performance > cost for this indirection. > > Haskell's type classes are also quite interesting too, as the import of a > type class instance doesn't propagate beyond the compilation unit so you > don't have as much of a namespace issue. The compiler can also get rid of > the indirection in most cases so there's not necessarily any cost for using > abstractions in that universe. > > In any case, I can't think of a way to reasonably implement this in Erlang > using idioms that mesh well with the rest of Erlang. There is no OTP > standard for this kind of thing, and there isn't likely to be a good way to > do it any time soon. If there was an OTP "interface" standard, surely we'd > have a hook to customize what "~p" means to io_lib for our own types! But > alas, we can't really even define our own abstract data types in Erlang, > just type aliases over the built-in concrete types. > > -bob > > > > On Fri, Dec 13, 2013 at 8:56 AM, Kaveh Shahbazian < > kaveh.shahbazian@REDACTED> wrote: > > > First "stringer" was a sample for (turned out it was a bad one) simulating > > protocols. So one could write (it can be more complicated, but whatever): > > > > test(V) -> > > X = ?protocolX(V), > > X:act1(), > > X:act2(), > > % ... > > X:actN(SomeArguments), > > OtherThings(). > > > > And act1 .. actN are members of 'protocolX'. This way it's clear that 'V' > > is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). > > > > BTW since I am no Erlang guru, I will follow the rules (for a foreseeable > > future) as you say here. > > > > Kaveh Shahbazian > > ?Walking on water and developing software from a specification are easy if > > both are frozen.? > > ? Edward Berard > > > > > > > > > > On Fri, Dec 13, 2013 at 5:32 PM, Fred Hebert wrote: > > > >> Hi. > >> > >> Despite what Joe says in his book, the history of the feature is that > >> tuple calls, the form you're using, were kept to allow the deprecation > >> of parametrized modules. > >> > >> In my humble opinion, the 'stateful module' things you're trying to > >> accomplish for you stringification is non-intuitive and not erlangish (I > >> would be confused by reading that in a code base). May I suggest the > >> simpler form, without changing your module: > >> > >> stringer:to_string(MyValue) > >> > >> instead? You will notice it even saves two characters when being called > >> over: > >> > >> ?stringer(MyValue):to_string(). > >> > >> Without including the macro definition work required, and is more > >> idiomatic overall. To use it as a function, simply use > >> > >> F = fun stringer:to_string/1, > >> F(MyValue). > >> > >> Regards, > >> Fred. > >> > >> On 12/13, Kaveh Shahbazian wrote: > >> > I do not thing so. Parametrized modules are different than stateful > >> > modules. Parametrized modules are deprecated and they were always > >> > provisional. > >> > > >> > Joe Armstrong in Programming Erlang (2nd Edition, Page 418) talked about > >> > them and in this same book he was promoting "coming soon" features of > >> R17 > >> > and It's highly unlikely for them to be deprecated. > >> > > >> > Kaveh Shahbazian > >> > ?Walking on water and developing software from a specification are easy > >> if > >> > both are frozen.? > >> > ? Edward Berard > >> > > >> > > >> > > >> > > >> > On Fri, Dec 13, 2013 at 11:40 AM, Dmitry Kolesnikov > >> > wrote: > >> > > >> > > Hello, > >> > > > >> > > Essentially you are trying to use parametrized modules, which get > >> > > deprecated in R14/15 and dropped from R16. > >> > > See for details: > >> > > * http://www.erlang.org/news/35 > >> > > * http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > >> > > > >> > > This type of problems are solvable either via pattern match or > >> currying: > >> > > > >> > > -module(stringer). > >> > > -export([stringer/1,sample/0]). > >> > > > >> > > stringer(V) when is_list(V) -> > >> > > fun() -> to_string(V, nop) end; > >> > > stringer(V) when is_atom(V) -> > >> > > fun() -> to_string(V, nop) end; > >> > > stringer(_V) -> > >> > > fun() -> not_implemented end. > >> > > > >> > > to_string(V, _Nop) -> > >> > > Buffer = io_lib:format("~p",[V]), > >> > > lists:flatten(Buffer). > >> > > > >> > > sample() -> > >> > > io:format("~p~n", [(stringer([1,2]))()]), > >> > > io:format("~p~n", [(stringer(cute_atom))()]), > >> > > io:format("~p~n", [(stringer(13))()]). > >> > > > >> > > > >> > > Best Regards, > >> > > Dmitry > >> > > > >> > > On Dec 13, 2013, at 8:31 AM, Kaveh Shahbazian < > >> kaveh.shahbazian@REDACTED> > >> > > wrote: > >> > > > >> > > I wanted to write something like ((IStringer)object).ToString() (in > >> C#) > >> > > in Erlang. After some studying I've learnt that Elixir has something > >> called > >> > > Protocols that pretty much resembles the same thing of C# (in an > >> inside-out > >> > > manner). Then I came up with this idea/code in Erlang - which is nice > >> > > enough to me like: > >> > > > >> > > ?stringer(my_val):to_string(). > >> > > > >> > > And it either returns the expected value or not_implemented atom! > >> > > > >> > > But 2 questions: > >> > > > >> > > 1 - Why nobody use this or promote things based on stateful modules in > >> > > Erlang? (OTP aside and from talking to some Erlangers they did not > >> know > >> > > that actually OTP is built around this! So really there is a need to > >> change > >> > > how Erlang is being taught and promoted. It's possible that I am > >> confused.). > >> > > > >> > > 2 - Why I get this warning? That call actually never fails. > >> > > > >> > > The warning: > >> > > > >> > > stringer.erl:18: Warning: invalid module and/or function name; this > >> call will always fail > >> > > stringer.erl:19: Warning: invalid module and/or function name; this > >> call will always fail > >> > > stringer.erl:20: Warning: invalid module and/or function name; this > >> call will always fail > >> > > > >> > > The code: > >> > > > >> > > -module(stringer). > >> > > -export([to_string/1,sample/0]). > >> > > > >> > > -define(stringer(V), {stringer, V}). > >> > > > >> > > to_string({stringer, V}) when is_list(V) -> > >> > > to_string(V, nop); > >> > > to_string({stringer, V}) when is_atom(V) -> > >> > > to_string(V, nop); > >> > > to_string({stringer, _V}) -> > >> > > not_implemented. > >> > > > >> > > to_string(V, _Nop) -> > >> > > Buffer = io_lib:format("~p",[V]), > >> > > lists:flatten(Buffer). > >> > > > >> > > sample() -> > >> > > io:format("~p~n", [?stringer([1,2]):to_string()]), > >> > > io:format("~p~n", [?stringer(cute_atom):to_string()]), > >> > > io:format("~p~n", [?stringer(13):to_string()]). > >> > > > >> > > And the output is: > >> > > > >> > > "[1,2]" > >> > > "cute_atom" > >> > > not_implemented > >> > > > >> > > _______________________________________________ > >> > > erlang-questions mailing list > >> > > erlang-questions@REDACTED > >> > > http://erlang.org/mailman/listinfo/erlang-questions > >> > > > >> > > > >> > > > >> > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://erlang.org/mailman/listinfo/erlang-questions > >> > >> > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > From gustav.simonsson@REDACTED Sat Dec 14 20:08:21 2013 From: gustav.simonsson@REDACTED (Gustav Simonsson) Date: Sat, 14 Dec 2013 20:08:21 +0100 Subject: [erlang-questions] Any examples of use of Erlang in systems where safety is key requirement In-Reply-To: References: Message-ID: "DO-178C, Software Considerations in Airborne Systems and Equipment Certification" Hmm. Close enough? http://www.youtube.com/watch?v=96UzSHyp0F8 Cheers, Gustav Simonsson On Sat, Dec 7, 2013 at 3:41 PM, Natesh Manikoth wrote: > Hello list, > Standards such as DO-178C (for level A,B,C) would preclude the use of > Erlang. Are there any examples of use of Erlang in such environments even > in cases where the software is not safety critical (but might be > categorized as supporting safety critical systems - say in an advisory type > system). > > Thanks > Natesh > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jose.valim@REDACTED Sun Dec 15 21:35:28 2013 From: jose.valim@REDACTED (=?ISO-8859-1?Q?Jos=E9_Valim?=) Date: Sun, 15 Dec 2013 20:35:28 +0000 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: <20131213181848.GC41386@ferdair.local> References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> <20131213181848.GC41386@ferdair.local> Message-ID: > > It is more verbose, but will not come at any cost in terms of genericity > and will not mess up tracing and anything else the way parametrized > modules used to. > > You are right, however, that Erlang doesn't really have a thing like > protocols, which are a pretty neat feature in languages that can provide > a solid implementation for them. > Right. The parameterized module is not related to Elixir protocols at all. The parameterized module here doesn't offer any benefit over a direct dispatch. As Fred said, it only messes up stacktraces and what you have at the end is still ad-hoc polymorphism (via guards). I want to clarify this is not how Elixir protocols work. Vincent's example is a good approximation but we are able to optimize it quite well. Once you build a release the cost of a protocol dispatch is quite low: it costs a pattern match (which you would have anyway) and one extra remote call. *Jos? Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Sun Dec 15 21:46:01 2013 From: peerst@REDACTED (Peer Stritzinger) Date: Sun, 15 Dec 2013 21:46:01 +0100 Subject: [erlang-questions] How to get at data_dir from all/0 and groups/0 callbacks in common_test Message-ID: I'd like to auto-generate my testcases from the files found in the data_dir. Unfortunately I don't get passed a Config in my all/0 and groups/0 testsuite callbacks. Is there another way of obtaining the path to data_dir in these callbacks? Or is it considered bad form to generate testcases from the files in data_dir (I could still iterate over the files in data_dir in single testcases whicht would do the same but have much worse reporting) Cheers, -- Peer From max.lapshin@REDACTED Sun Dec 15 21:47:22 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 16 Dec 2013 00:47:22 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> Message-ID: I've just commented out line MALLOC_USE_HASH(1); and it helped. So your patches are ok for this board. -------------- next part -------------- An HTML attachment was scrubbed... URL: From desired.mta@REDACTED Sun Dec 15 22:01:39 2013 From: desired.mta@REDACTED (=?UTF-8?B?TW90aWVqdXMgSmFrxaF0eXM=?=) Date: Sun, 15 Dec 2013 22:01:39 +0100 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> Message-ID: <52AE18B3.9070402@gmail.com> 2013.12.15 21:47, Max Lapshin ra??: > I've just commented out line MALLOC_USE_HASH(1); and it helped. So your > patches are ok for this board. Are you using TileMDE2 or TileMDE3? Did you cross-compile? If you did cross-compile, did GCC accept this line (first patch in the pull request)? -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off Please write your findings in the pull request as well - it will probably help to merge it. Motiejus From serge@REDACTED Sun Dec 15 22:39:19 2013 From: serge@REDACTED (Serge Aleynikov) Date: Sun, 15 Dec 2013 16:39:19 -0500 Subject: [erlang-questions] Binary Erlang External Term serialization in Javascript Message-ID: Since websockets nowadays support binary data, I implemented binary Erlang External Term serialization, so that term_to_binary(Term) can be decoded into Javascript objects and vice versa. I'd like to share this example that illustrates the experiment: https://github.com/saleyn/erws_example The Javascript file (used by the example above) with encoding/decoding logic: https://github.com/saleyn/erlb.js (this is an early beta version) This is a more-or-less belated answer to the question raised by Joe in this thread: http://erlang.org/pipermail/erlang-questions/2011-November/062477.html Regards, Serge -------------- next part -------------- An HTML attachment was scrubbed... URL: From z@REDACTED Sun Dec 15 23:37:28 2013 From: z@REDACTED (Danil Zagoskin) Date: Mon, 16 Dec 2013 02:37:28 +0400 Subject: [erlang-questions] Binary Erlang External Term serialization in Javascript In-Reply-To: References: Message-ID: Is it refactored bert.js from Nitrogen? Files seem to have common lines: https://github.com/nitrogen/nitrogen_core/blob/master/www/bert.js 2013/12/16 Serge Aleynikov > Since websockets nowadays support binary data, I implemented binary Erlang > External Term serialization, so that term_to_binary(Term) can be decoded > into Javascript objects and vice versa. > > I'd like to share this example that illustrates the experiment: > > https://github.com/saleyn/erws_example > > The Javascript file (used by the example above) with encoding/decoding > logic: > https://github.com/saleyn/erlb.js > (this is an early beta version) > > This is a more-or-less belated answer to the question raised by Joe in > this thread: > http://erlang.org/pipermail/erlang-questions/2011-November/062477.html > > Regards, > > Serge > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- --------------------------------------------- ????? ???????? | +7 906 064 20 47 | z@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From desired.mta@REDACTED Sun Dec 15 23:56:23 2013 From: desired.mta@REDACTED (=?UTF-8?Q?Motiejus_Jak=C5=A1tys?=) Date: Sun, 15 Dec 2013 23:56:23 +0100 Subject: [erlang-questions] Binary Erlang External Term serialization in Javascript In-Reply-To: References: Message-ID: On Sun, Dec 15, 2013 at 10:39 PM, Serge Aleynikov wrote: > Since websockets nowadays support binary data, I implemented binary Erlang > External Term serialization, so that term_to_binary(Term) can be decoded > into Javascript objects and vice versa. > > I'd like to share this example that illustrates the experiment: > > https://github.com/saleyn/erws_example Are you going to use it practically? If yes, my rant below. I remember Joe's opinion (from Stockholm EUC keynote last year?). Imprecise quote from memory: "if everyone could speak Swedish as well as native language, we all could talk to each other". No interpreters: just convert your native sentence to Swedish, speak out, the recipient converts Swedish to native, understands, replies ... all is good. The whole idea (and your project) pushes towards "Swedish=Erlang Term Format". This is all nice, but has a big IF: since this concerns communication between heterogenous computer systems, how are you going to convince enterprisey mainstream guys to talk to you via BERT? If all they know is XML (SOAP!), JSON (front-end) or HDF (CERN guys) or stuff like that. I believe in an approach piqi is trying to do: an interpreter which can speak much of the popular languages *and* your mother tongue. It's different, as it forces a schema (unlike BERT). However, for data exchange we need a schema anyway. Not meaning to offend/criticize. What you did is nice. Your project just reminded me an unanswered question. Motiejus From serge@REDACTED Mon Dec 16 01:11:26 2013 From: serge@REDACTED (Serge Aleynikov) Date: Sun, 15 Dec 2013 19:11:26 -0500 Subject: [erlang-questions] Binary Erlang External Term serialization in Javascript In-Reply-To: References: Message-ID: Though I did start it off with Bert, it ended up being nearly a complete rewrite. I plan to complete a couple of unfinished tasks such as dealing with big integers (at least up to 2^53), and add test cases. Contributions are welcome. On Sun, Dec 15, 2013 at 5:37 PM, Danil Zagoskin wrote: > Is it refactored bert.js from Nitrogen? > Files seem to have common lines: > https://github.com/nitrogen/nitrogen_core/blob/master/www/bert.js > > > 2013/12/16 Serge Aleynikov > >> Since websockets nowadays support binary data, I implemented binary >> Erlang External Term serialization, so that term_to_binary(Term) can be >> decoded into Javascript objects and vice versa. >> >> I'd like to share this example that illustrates the experiment: >> >> https://github.com/saleyn/erws_example >> >> The Javascript file (used by the example above) with encoding/decoding >> logic: >> https://github.com/saleyn/erlb.js >> (this is an early beta version) >> >> This is a more-or-less belated answer to the question raised by Joe in >> this thread: >> http://erlang.org/pipermail/erlang-questions/2011-November/062477.html >> >> Regards, >> >> Serge >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > --------------------------------------------- > ????? ???????? | +7 906 064 20 47 | z@REDACTED > -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge@REDACTED Mon Dec 16 01:25:44 2013 From: serge@REDACTED (Serge Aleynikov) Date: Sun, 15 Dec 2013 19:25:44 -0500 Subject: [erlang-questions] Binary Erlang External Term serialization in Javascript In-Reply-To: References: Message-ID: Fortunately (oh no! :-O) not everyone is concerned about talking to mainstream enterprise. If you have a server component implemented in Erlang, why incur the trouble of dealing with a text-based protocol (JSON, XML, etc), if the other end can happily deal with native Erlang binary (de)serialization? Ssince this method has lower overhead than JSON, and seems to bring Javascript a step closer to Erlang, I can think of many cases where I'd use this approach for writing Web GUIs using websockets which need asynchronous messaging, and need to display very dynamic data initiated by server. On Sun, Dec 15, 2013 at 5:56 PM, Motiejus Jak?tys wrote: > On Sun, Dec 15, 2013 at 10:39 PM, Serge Aleynikov > wrote: > > Since websockets nowadays support binary data, I implemented binary > Erlang > > External Term serialization, so that term_to_binary(Term) can be decoded > > into Javascript objects and vice versa. > > > > I'd like to share this example that illustrates the experiment: > > > > https://github.com/saleyn/erws_example > > Are you going to use it practically? If yes, my rant below. > > > I remember Joe's opinion (from Stockholm EUC keynote last year?). > Imprecise quote from memory: "if everyone could speak Swedish as well > as native language, we all could talk to each other". No interpreters: > just convert your native sentence to Swedish, speak out, the recipient > converts Swedish to native, understands, replies ... all is good. > > The whole idea (and your project) pushes towards "Swedish=Erlang Term > Format". This is all nice, but has a big IF: since this concerns > communication between heterogenous computer systems, how are you going > to convince enterprisey mainstream guys to talk to you via BERT? If > all they know is XML (SOAP!), JSON (front-end) or HDF (CERN guys) or > stuff like that. > > I believe in an approach piqi is trying to do: an interpreter which > can speak much of the popular languages *and* your mother tongue. It's > different, as it forces a schema (unlike BERT). However, for data > exchange we need a schema anyway. > > Not meaning to offend/criticize. What you did is nice. Your project > just reminded me an unanswered question. > > > Motiejus > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Mon Dec 16 03:52:36 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 16 Dec 2013 06:52:36 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: <52AE18B3.9070402@gmail.com> References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: I don't know how to cross-compile =( This machine is: # uname -a Linux myhostname 3.4.68-MDE-4.2.1.167093 #1 SMP Fri Nov 15 19:16:29 EST 2013 tilegx tilegx tilegx GNU/Linux # cat /proc/cpuinfo cpu count : 36 cpu list : 0-35 model name : tilegx flags : cpu MHz : 1200.000000 bogomips : 2400.00 processor : 0 processor : 1 ... Not too much info about it =(( -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Dec 16 04:08:11 2013 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 16 Dec 2013 16:08:11 +1300 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: Message-ID: <4AA09EA9-685B-44EB-9F90-21869FFE8F01@cs.otago.ac.nz> On 13/12/2013, at 7:31 PM, Kaveh Shahbazian wrote: > I wanted to write something like ((IStringer)object).ToString() (in C#) in Erlang. Can you make it a little bit clearer exactly what it is you need to do? There is a fundamental distinction between the way something like object.toString() works in OO languages to_string(Object) works in Erlang: - in the OO languages the "object" is in charge of what .toString() means - in Erlang, the _function_ is in charge of what to_string() means. > Then I came up with this idea/code in Erlang - which is nice enough to me like: > > ?stringer(my_val):to_string(). > > 1 - Why nobody use this or promote things based on stateful modules in Erlang? Where do you get "stateful" from? An Erlang parameterised module is a *value*. In this case, "my_val" is *still* not in charge of what to_string does. In any case, one way to begin to understand parameterised modules in Erlang is to start by thinking of -module(foo, {X,Y,Z}). -export([to_string/0]). to_string() -> as if it were something not entirely unlike -module(foo). -export([new/1,to_string/1]). new({X,Y,Z}) -> {foo,X,Y,Z}. to_string(This = {foo,X,Y,Z}) -> ... There is, in short, no fundamental theoretical or practical difference between stringer(my_val):to_string() and stringer:to_string(my_val). Anything you can do with the first you can CERTAINLY do with the second. If you want to simulate OO in Erlang, (1) lie down until the feeling passes off; (2) if the condition persists, see a doctor (of CS); (3) if the cure is unsuccessful, represent an "object" by a tuple {tag,Funs,Data} where Funs is a tuple of functions shared by a number of instances (yes, it's a vtable), and write to_string(Obj = {_,{...,TS...},...}) -> TS(Obj). I am deadly serious about (1). When you using ((IStringer)object).to_string() you are literally saying I don't know and I don't care what object is as long as it conforms to the IStringer interface. I don't know and I don't care what the .to_string() method does as long as it has the right kind of arguments and results; it could reformat my hard drive, it could send threatening messages to the president of the USA, it could burn down the local hospital, I really really DON'T CARE. If that's not what you mean, then perhaps you'd better write your code another way, even in C#. Any time you pass around something with pluggable behaviour, ideally you need a strong type-AND-EFFECT system that lets you limit the damage that can be done, or at the least you need comments saying what is supposed to be allowed. I'm actually serious about (2) as well: see if you can find a copy of "Why Joe Hates OO" by our very own Joe Armstrong. (For the record, I am not an anti-OO bigot. I have spent way too much of my time building a Smalltalk system I'm generally quite pleased with to be _that_. But I have come to dread not knowing what an argument will do if I poke it, especially in a multithreading context.) > (OTP aside and from talking to some Erlangers they did not know that actually OTP is built around this! They didn't know it because it isn't true. For a long time Erlang didn't have parameterised modules, then it did as an experiment, and now it doesn't again. OTP managed without them and does again. > So really there is a need to change how Erlang is being taught and promoted. It's possible that I am confused.). If you find yourself struggling to do things the language X way in language Y, it's generally a better to look for an _idiomatic_ way to solve the underlying problem in language Y than to try to warp language Y into acting like language X. Just recently I've seen a horrible example of a Prolog system being warped to be more like JavaScript, to the applause of people who haven't thought about the benefits of being able to use other Prolog systems as well... As one example, it's not unknown for an Erlang module that defines a data type to export a format/1 and maybe format/2 for converting an instance to a string or writing it to a stream. Using snorkelwhacker:format(Monster) makes it clear that Monster is supposed to be the kind of thing that the snorkelwhacker module knows about; this might be one of several things. From desired.mta@REDACTED Mon Dec 16 09:09:26 2013 From: desired.mta@REDACTED (=?UTF-8?Q?Motiejus_Jak=C5=A1tys?=) Date: Mon, 16 Dec 2013 09:09:26 +0100 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: On Mon, Dec 16, 2013 at 3:52 AM, Max Lapshin wrote: > I don't know how to cross-compile =( You don't have to if it works out of the box. However, if you feel like it, $ERL_TOP/xcomp/README.md has the details. It's only slightly different from normal otp build. > This machine is: > > # uname -a > Linux myhostname 3.4.68-MDE-4.2.1.167093 #1 SMP Fri Nov 15 19:16:29 EST 2013 > tilegx tilegx tilegx GNU/Linux > > # cat /proc/cpuinfo > cpu count : 36 > cpu list : 0-35 > model name : tilegx > flags : > cpu MHz : 1200.000000 > bogomips : 2400.00 > That looks like TileMDE4. Even newer version than I tried. I will update the pull request. -- Motiejus Jak?tys From max.lapshin@REDACTED Mon Dec 16 09:48:34 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 16 Dec 2013 12:48:34 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: Ok, I've launched erlyvideo on this tilera. >From the first sight it is fast enough for network streaming. Just like 4-core Intel Core i3. Will try to reach throughput higher than 5 Gbit/s -------------- next part -------------- An HTML attachment was scrubbed... URL: From langxianzhe@REDACTED Mon Dec 16 10:33:55 2013 From: langxianzhe@REDACTED (=?GB2312?B?wMnPzM7k?=) Date: Mon, 16 Dec 2013 17:33:55 +0800 Subject: [erlang-questions] About etop question Message-ID: Hi all, I need your help. In recently days, i found our server consume a lot of memory. For example, I only type erl command in the shell. It is about to consume 4G memory. I try to monitor with etop toos. Then i met a new question which the Memory column display some stars[1]. Thanks for any idea. My Enviromment is? FreeBSD meda076 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@REDACTED:/usr/obj/usr/src/sys/GENERIC amd64 Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:24:24] [rq:24] [async-threads:0] [hipe] [kernel-poll:false] [1] Load: cpu 57 Memory: total 22822275 binary 358077 procs 1216 processes17988800 code 12438 runq 0 atom 1285 ets 260260 Pid Name or Initial Func Time Reds Memory MsgQ Current Function ---------------------------------------------------------------------------------------- <5149.1319.0> re_cache 263608 224355 11744 0 inflector:re_cache_l <5149.114.0> proc_lib:init_p/5 79164 19759 1801616 0 gen_server:loop/6 <5149.2869.2> trends_db:update_cac 56983 52371******** 0 gen:do_call/4 <5149.266.0> proc_lib:init_p/5 49117 19523******** 0 gen_server:loop/6 <5149.56.0> boss_db_pool 30201 56476 67752 0 gen_fsm:loop/7 <5149.1101.0> mnesia_tm 7193 21880******** 0 mnesia_tm:doit_loop/ <5149.84.0> proc_lib:init_p/5 5984 15656******** 0 gen_server:loop/6 <5149.456.0> proc_lib:init_p/5 4507 19988 1801616 0 gen_server:loop/6 <5149.602.0> proc_lib:init_p/5 4152 16802 1113992 0 gen:do_call/4 <5149.894.0> proc_lib:init_p/5 4126 15461******** 0 gen_server:loop/6 ======================================================================================== Cheers, Jason -- ??????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Mon Dec 16 11:26:18 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 16 Dec 2013 11:26:18 +0100 Subject: [erlang-questions] About etop question In-Reply-To: References: Message-ID: On Mon, Dec 16, 2013 at 10:33 AM, ??? wrote: > In recently days, i found our server consume a lot of memory. For example, > I only type erl command in the shell. It is about to consume 4G memory. I > try to monitor with etop toos. Then i met a new question which the Memory > column display some stars[1]. It is the formatting code which notes it cannot represent the size of the number. Usually because the call to io_lib:format specifies a given number, N, of characters and the numbers representation is too big to fit into N characters. Good libraries/tricks for hunting these kinds of problems: * install an alarm_handler and run mem_sup. Report stuff about the Pid using too much memory. * Use Fred Hebert's `recon` library (ferd/recon on Github). -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Mon Dec 16 11:32:52 2013 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Mon, 16 Dec 2013 11:32:52 +0100 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> References: <51C1F735.5040706@comcast.net> <7399173B-E72B-409C-BC0F-EDF737CAAB1A@cs.otago.ac.nz> <51C31FE4.4030100@comcast.net> <51C39FA3.5020907@comcast.net> <7B6C2A52-CBEA-4439-B886-788F780D913A@cs.otago.ac.nz> <51C3CB52.70906@comcast.net> <3ED3C4FC-2C69-45EC-9799-87D7F60AC094@cs.otago.ac.nz> <84CCF390-5221-4457-BB76-CB6FA9639DF7@gmail.com> <1a467e5a828a2d39bb1eeb2c2a25fcf7.squirrel@chasm.otago.ac.nz> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> Message-ID: <52AED6D4.70605@gmail.com> On 2013-12-15 19:07 , Anthony Ramine wrote: > Hello, > > I?ve thought about this again and realised that there is a technical reason not to expand cond expressions to nested cases directly. That reason is scoping rules. > > Let?s assume we compile this expression naively to nested cases: > > cond X = false -> X; > X = true -> X > end > > => > > case X = false of > true -> X; > false -> > case X = true of > true -> X; > end > end. > > I would be *extremely* surprised that such an expression would crash with badmatch instead of returning true as it should. > > Regards, > Yes, these complications are the reasons why cond never got implemented beyond experimenting with the expansion you showed above. It needs clearly specified scoping rules, and support in all tools above the Core Erlang level. And nobody seemed to have the time to do that. /Richard From n.oxyde@REDACTED Mon Dec 16 11:56:12 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Mon, 16 Dec 2013 11:56:12 +0100 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: <52AED6D4.70605@gmail.com> References: <51C1F735.5040706@comcast.net> <7399173B-E72B-409C-BC0F-EDF737CAAB1A@cs.otago.ac.nz> <51C31FE4.4030100@comcast.net> <51C39FA3.5020907@comcast.net> <7B6C2A52-CBEA-4439-B886-788F780D913A@cs.otago.ac.nz> <51C3CB52.70906@comcast.net> <3ED3C4FC-2C69-45EC-9799-87D7F60AC094@cs.otago.ac.nz> <84CCF390-5221-4457-BB76-CB6FA9639DF7@gmail.com> <1a467e5a828a2d39bb1eeb2c2a25fcf7.squirrel@chasm.otago.ac.nz> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> <52AED6D4.70605@gmail.com> Message-ID: It?s done finished yet, but I?m on it: https://github.com/nox/otp/tree/cond -- Anthony Ramine Le 16 d?c. 2013 ? 11:32, Richard Carlsson a ?crit : > On 2013-12-15 19:07 , Anthony Ramine wrote: >> Hello, >> >> I?ve thought about this again and realised that there is a technical reason not to expand cond expressions to nested cases directly. That reason is scoping rules. >> >> Let?s assume we compile this expression naively to nested cases: >> >> cond X = false -> X; >> X = true -> X >> end >> >> => >> >> case X = false of >> true -> X; >> false -> >> case X = true of >> true -> X; >> end >> end. >> >> I would be *extremely* surprised that such an expression would crash with badmatch instead of returning true as it should. >> >> Regards, >> > > Yes, these complications are the reasons why cond never got implemented beyond experimenting with the expansion you showed above. It needs clearly specified scoping rules, and support in all tools above the Core Erlang level. And nobody seemed to have the time to do that. > > /Richard From n.oxyde@REDACTED Mon Dec 16 12:00:35 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Mon, 16 Dec 2013 12:00:35 +0100 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: References: <51C1F735.5040706@comcast.net> <7399173B-E72B-409C-BC0F-EDF737CAAB1A@cs.otago.ac.nz> <51C31FE4.4030100@comcast.net> <51C39FA3.5020907@comcast.net> <7B6C2A52-CBEA-4439-B886-788F780D913A@cs.otago.ac.nz> <51C3CB52.70906@comcast.net> <3ED3C4FC-2C69-45EC-9799-87D7F60AC094@cs.otago.ac.nz> <84CCF390-5221-4457-BB76-CB6FA9639DF7@gmail.com> <1a467e5a828a2d39bb1eeb2c2a25fcf7.squirrel@chasm.otago.ac.nz> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> <52AED6D4.70605@gmail.com> Message-ID: That should have been ? it?s not finished yet ?. -- Anthony Ramine Le 16 d?c. 2013 ? 11:56, Anthony Ramine a ?crit : > It?s done finished yet, but I?m on it: > > https://github.com/nox/otp/tree/cond > > -- > Anthony Ramine > > Le 16 d?c. 2013 ? 11:32, Richard Carlsson a ?crit : > >> On 2013-12-15 19:07 , Anthony Ramine wrote: >>> Hello, >>> >>> I?ve thought about this again and realised that there is a technical reason not to expand cond expressions to nested cases directly. That reason is scoping rules. >>> >>> Let?s assume we compile this expression naively to nested cases: >>> >>> cond X = false -> X; >>> X = true -> X >>> end >>> >>> => >>> >>> case X = false of >>> true -> X; >>> false -> >>> case X = true of >>> true -> X; >>> end >>> end. >>> >>> I would be *extremely* surprised that such an expression would crash with badmatch instead of returning true as it should. >>> >>> Regards, >>> >> >> Yes, these complications are the reasons why cond never got implemented beyond experimenting with the expansion you showed above. It needs clearly specified scoping rules, and support in all tools above the Core Erlang level. And nobody seemed to have the time to do that. >> >> /Richard > From max.lapshin@REDACTED Mon Dec 16 12:00:44 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 16 Dec 2013 15:00:44 +0400 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: References: <51C1F735.5040706@comcast.net> <7399173B-E72B-409C-BC0F-EDF737CAAB1A@cs.otago.ac.nz> <51C31FE4.4030100@comcast.net> <51C39FA3.5020907@comcast.net> <7B6C2A52-CBEA-4439-B886-788F780D913A@cs.otago.ac.nz> <51C3CB52.70906@comcast.net> <3ED3C4FC-2C69-45EC-9799-87D7F60AC094@cs.otago.ac.nz> <84CCF390-5221-4457-BB76-CB6FA9639DF7@gmail.com> <1a467e5a828a2d39bb1eeb2c2a25fcf7.squirrel@chasm.otago.ac.nz> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> <52AED6D4.70605@gmail.com> Message-ID: Frankly speaking, it is the way that if should been done =( It is a good feature! -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Mon Dec 16 12:28:51 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Mon, 16 Dec 2013 12:28:51 +0100 Subject: [erlang-questions] Matthew Sackman's "cut" proposal In-Reply-To: <71EF216F-1EF9-4854-8E2A-C3717FD2B805@cs.otago.ac.nz> References: <47580784-36BB-42C1-B6B5-A040EB2762CC@cs.otago.ac.nz> <71EF216F-1EF9-4854-8E2A-C3717FD2B805@cs.otago.ac.nz> Message-ID: A couple of days ago I had an idea of a syntax that may fit Erlang for partial application. 1/ I wanted something not like cuts, where you have to look very hard to determine the function arity (e.g. count the ? _ ? in ? foo(X, _) ?. 2/ I wanted to limit the partial application to trailing arguments, not pass them into arbitrary places like in Elixir where they do stuff like &(foo(&1, X)). My proposition is: fun F(A1, .., Am)/N. Which compiles down to: fun (Am+1, .., An) -> F(A1, .., Am, Am+1, .., An) end. This is loosely inspired from Prolog?s higher order predicates. Pros: 1/ There is an explicit ?fun? token which clearly shows a fun is produced here, compared with the implicit enclosing scope of foo(X, _). 2/ There is an explicit arity at the end, compared with the implicit arity of the number of holes in other cut proposals. 3/ It is inspired from the ancestor of Erlang. 4/ That may require a change to the AST, which would be a good occasion to unify the various ?fun? AST nodes. 5/ Implementation is *way more* straightforward than the original cut proposal. Cons: 1/ Should N be the arity of the resulting fun, or the arity of the partially applied function with *all* its arguments included? That may be confusing. 2/ That might require a change to the AST, breaking backwards-compatibility. I am posting this for people to tell me why I am wrong to think this is a good idea. Regards, -- Anthony Ramine Le 12 juil. 2011 ? 05:57, Richard O'Keefe a ?crit : > > On 12/07/2011, at 1:15 PM, Tim Watson wrote: >> >>> As an occasional Haskell and SML programmer, I am certainly not >>> against Curried functions. What I *am* against is an approach which >>> is ugly, confusing, and almost never applicable. >>> >> >> Can't disagree with you there. >> >>> If Erlang syntax were generalised to >>> >>> ends_with(X)(Y) -> string:equal(string:right(Y, length(X)), X). >>> >>> we could eliminate those three tokens. >>> >>> What's more, we could do that *WITHOUT* any weird restrictions on >>> - whether pattern matching is allowed in the fun >>> - the form of the fun body >>> - where the arguments appear in the fun body >>> - the order in which the arguments appear in the fun body. >>> and *WITHOUT* >>> - any weird non-intention-revealing tokens, whether '_' or '?' >>> >> >> Yes but you have to admit, it does look a bit odd. > > Yes, but that is precisely because it looks just like other languages > that do Curried functions. > > ends_with (x) (y) = rtake y (length x) == x > > is perfectly good Haskell, assuming an rtake function, and > > fun ends_with (x) (y) = > List.drop (y, length y - length x) = x > > is perfectly good SML, or would be if it didn't crash when y is > shorter than x. > >> Why can't I just >> use the variable 'Y' and let the compiler figure out that the function >> signature needs to change? > > Because it is only in toy examples that a compiler *could* figure out > *how* the function signature needs to change. > >>> If you want to do Haskell-like things, it doesn't make sense not >>> to do it in a Haskell-like way, and that is to say that >>> >>> ()()...() -> >>> >>> is equivalent to >>> >>> () -> >>> fun () -> >>> ... >>> fun () -> >>> >>> end >>> ... >>> end >>> >>> *NO* new tokens! >>> *NO* weird restrictions! >>> Good consistency with the way Clean and ML and Haskell do it. >>> *NO* changes elsewhere in the language. >>> >> >> Great - is it going to get through the eep process? Do we need to vote >> on it, contribute (e.g., test proposed patches, etc) or whatever? > > I don't have time to write up an EEP today, but I'll see what I can do. > The nice thing about it is that it's entirely in the front end; the > rest of the compiler doesn't need to know anything about it. > >> >>> Let's see what we have to do now: >>> >>> c(F1, F2) -> fun (X) -> F2(F1(X)) end. >>> c(F1, F2, F3) -> fun (X) -> F3(F2(F1(X))) end. >>> c(F1, F2, F3, F4) -> fun (X) -> F4(F3(F2(F1(X)))) end. >>> >>> doodle(X) -> >>> F = c(fun do_thing/1, >>> fun calculate_next_thing/1, >>> fun get_bored_of_typing_result_x, >>> fun start_getting_annoyed_with_lazy_programmers/1), >>> {ok, F(X)}. >>> >>> Nope, not hard. Trivial, in fact. >> >> Boilerplate. > > No, library code, done *ONCE*. > The only "boilerplate" would be the > -import(compose, [c/4]). % plus any others you want > line. > > It would, in fact, have precisely the same status as function > composition in Haskell and SML. Library code. > >>> The question is, in a language without static types, how do you >>> tell the difference between an intentional foo/2 meaning a function >>> and an erroneous foo/2 that should have been Foo/2, with Foo a >>> variable bound to a number. >> >> We're never going to get static types in Erlang, so I think the answer >> is that you'd end up with a failing unit or integration test case. Not >> sure how to do a "raised eyebrow" smiley. > > We *have* optional static types in Erlang, but you're right that they > will probably never be mandatory. > > Testing and static checking are complementary tools. > We need both. Thank goodness we *have* both in Erlang. > >> The compiler knows full well that ()/ evaluates >> to a fun!? > > Only if preceded by 'fun'. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From ari.brandeis.king@REDACTED Mon Dec 16 15:48:34 2013 From: ari.brandeis.king@REDACTED (Ari King) Date: Mon, 16 Dec 2013 09:48:34 -0500 Subject: [erlang-questions] Erlang Basics: Reading File Content Message-ID: I've just started with Erlang and to learn/practice I'm attempting to put together a simple TCP server that reads data from a file and writes it to a socket. So far I've put together some code to read the data (combination of ascii, binary, control characters). But since (as I understand) Erlang doesn't have a return mechanism, how do I read a line of data and return it to be written to the socket? Right now, the code just recursively collects the data. -module(mock_tcp). -export([start/1]). start([Ip, Port, Filename]) -> io:format("Server available at ~w on port ~w. Reading from ~w.", [Ip, Port, Filename]), {ok, Device) = file:open(Filename, read), try get_data(Device) after file:close(Device) end. get_data(Device) -> case io:get_line(Device) of {ok, Data} -> [Data | get_data(Device)]; eof -> [] end. Thanks. Ari -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Mon Dec 16 16:48:51 2013 From: bob@REDACTED (Bob Ippolito) Date: Mon, 16 Dec 2013 10:48:51 -0500 Subject: [erlang-questions] Erlang Basics: Reading File Content In-Reply-To: References: Message-ID: The last expression of a function is what that function returns. Are you trying to stream the file to the socket a line at a time, or are you trying to read the entire file and then write its contents to the socket en masse? For the former, you would simply have get_data take two arguments, a Device and Socket. When you read anything but eof from the device you would write the Data to Socket and then tail-recurse (`get_data(Device, Socket)` not a list). The eof case would simply return ok. For the latter case you could use your implementation of get_data as-is, and write its result to Socket. Either way, there's not usually a need to use try/after to close a Port (such as a file or socket) in exceptional situations. The Port is linked to the process and will automatically be closed when the process dies. You should of course still close it in normal situations so that the file descriptor is reclaimed at the intended moment (perhaps immediately on eof). -bob On Mon, Dec 16, 2013 at 9:48 AM, Ari King wrote: > I've just started with Erlang and to learn/practice I'm attempting to put > together a simple TCP server that reads data from a file and writes it to a > socket. So far I've put together some code to read the data (combination of > ascii, binary, control characters). But since (as I understand) Erlang > doesn't have a return mechanism, how do I read a line of data and return it > to be written to the socket? Right now, the code just recursively collects > the data. > > -module(mock_tcp). > -export([start/1]). > > start([Ip, Port, Filename]) -> > io:format("Server available at ~w on port ~w. Reading from ~w.", > [Ip, Port, Filename]), > {ok, Device) = file:open(Filename, read), > try get_data(Device) > after file:close(Device) > end. > > get_data(Device) -> > case io:get_line(Device) of > {ok, Data} -> [Data | get_data(Device)]; > eof -> [] > end. > > Thanks. > > Ari > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eriksoe@REDACTED Mon Dec 16 18:33:01 2013 From: eriksoe@REDACTED (=?ISO-8859-1?Q?Erik_S=F8e_S=F8rensen?=) Date: Mon, 16 Dec 2013 18:33:01 +0100 Subject: [erlang-questions] Erlang Basics: Reading File Content In-Reply-To: References: Message-ID: Two questions: 1) Do the files always contain text content? If no, then "get_line()" would probably be a bad idea; using file:read/2 to read N bytes is a better bet. Also, open the file in 'binary' mode. 2) Do you expect the files to always be small? If yes, then file:read_file/1 is nice and easy to use: it reads the entire file up and gives you the content in form of a binary. Only in rare usecases would I find it necessary to read the entire file on a line-by-line basis, as your code so far does. Simple file serving would be both simpler and faster by keeping the file data in binary form. (If there needs to be done some line-ending transformation, or if the file is a pipe or similar in which the data appears slowly, line-by-line, e.g. a log, then it's of course another matter.) With file:read_file/1, it'd be simple: {ok,Data} = file:read_file(Filename), % write Data to socket With file:read/2 in a read-it-all loop (close to what you've written, but in essence replaceable by read_file), you'd have something like: try get_data(Device) of Data -> % write Data to socket after file:close(Device) end. ... -define(BLOCK_SIZE, 4096). get_data(Device) -> case file:read(Device, ?BLOCK_SIZE) of {ok, Data} -> [Data | get_data(Device)]; eof -> [] end. (Or the tail recursive equivalent.) Note the "try-of" construct, which is peculiar to Erlang, but very handy - it's like the try Data = get_data(Device), % write Data to socket after ... end. you'd probably write (with other syntax, of course) in other languages, except that only exceptions in the get_data() call will be caught; the "of..." clause won't be covered by the exception handler. (This is the kind of thing you probably won't think about before you learn that such a construct exists - and from then on you'll find it lacking from the languages which don't have it...) And finally, with file:read/2 in a transfer-a-chunk-at-a-time loop, it'd be: try transfer_data(Device, Socket) after file:close(Device) end. ... -define(BLOCK_SIZE, 4096). transfer_data(Device, Socket)) -> case file:read(Device, ?BLOCK_SIZE) of {ok, Data} -> % Write Data to Socket transfer_data(Device, Socket) eof -> ok end. OK, this response is long enough by now. I hope the answer helps :-) /Erik 2013/12/16 Ari King > I've just started with Erlang and to learn/practice I'm attempting to put > together a simple TCP server that reads data from a file and writes it to a > socket. So far I've put together some code to read the data (combination of > ascii, binary, control characters). But since (as I understand) Erlang > doesn't have a return mechanism, how do I read a line of data and return it > to be written to the socket? Right now, the code just recursively collects > the data. > > -module(mock_tcp). > -export([start/1]). > > start([Ip, Port, Filename]) -> > io:format("Server available at ~w on port ~w. Reading from ~w.", > [Ip, Port, Filename]), > {ok, Device) = file:open(Filename, read), > try get_data(Device) > after file:close(Device) > end. > > get_data(Device) -> > case io:get_line(Device) of > {ok, Data} -> [Data | get_data(Device)]; > eof -> [] > end. > > Thanks. > > Ari > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eriksoe@REDACTED Mon Dec 16 18:47:24 2013 From: eriksoe@REDACTED (=?ISO-8859-1?Q?Erik_S=F8e_S=F8rensen?=) Date: Mon, 16 Dec 2013 18:47:24 +0100 Subject: [erlang-questions] Matthew Sackman's "cut" proposal Message-ID: Disclaimer 1: I haven't followed the "cut"/partial application discussion up until now. Disclaimer 2: Surface syntax bikeshed! Anyway, what I'm really responding to is these parts: """ fun F(A1, .., Am)/N. 1/ Should N be the arity of the resulting fun, or the arity of the partially applied function with *all* its arguments included? That may be confusing. """ by noticing that the confusion would (for most people) go away (at least in the "inclusive or exclusive?" respect) if the syntax was fun F(A1, .., Am)+K (in which case N=m+K, obviously). I know that (as far as I'm aware) the plus sign has not hitherto been associated with function syntax, and there may be any number of historical reasons to not to it this way (of which RO'K perhaps can provide a few :-)), but then again the slash also doubles as an arithmetic operator. New meaning - new symbol - potential for less confusion overall. /Erik 2013/12/16 Anthony Ramine > A couple of days ago I had an idea of a syntax that may fit Erlang for > partial application. > > 1/ I wanted something not like cuts, where you have to look very hard to > determine the function arity (e.g. count the ? _ ? in ? foo(X, _) ?. > 2/ I wanted to limit the partial application to trailing arguments, not > pass them into arbitrary places like in Elixir where they do stuff like > &(foo(&1, X)). > > My proposition is: > > fun F(A1, .., Am)/N. > > Which compiles down to: > > fun (Am+1, .., An) -> F(A1, .., Am, Am+1, .., An) end. > > This is loosely inspired from Prolog?s higher order predicates. > > Pros: > > 1/ There is an explicit ?fun? token which clearly shows a fun is produced > here, compared with the implicit enclosing scope of foo(X, _). > 2/ There is an explicit arity at the end, compared with the implicit arity > of the number of holes in other cut proposals. > 3/ It is inspired from the ancestor of Erlang. > 4/ That may require a change to the AST, which would be a good occasion to > unify the various ?fun? AST nodes. > 5/ Implementation is *way more* straightforward than the original cut > proposal. > > Cons: > > 1/ Should N be the arity of the resulting fun, or the arity of the > partially applied function with *all* its arguments included? That may be > confusing. > 2/ That might require a change to the AST, breaking > backwards-compatibility. > > I am posting this for people to tell me why I am wrong to think this is a > good idea. > > Regards, > > -- > Anthony Ramine > > Le 12 juil. 2011 ? 05:57, Richard O'Keefe a ?crit : > > > > > On 12/07/2011, at 1:15 PM, Tim Watson wrote: > >> > >>> As an occasional Haskell and SML programmer, I am certainly not > >>> against Curried functions. What I *am* against is an approach which > >>> is ugly, confusing, and almost never applicable. > >>> > >> > >> Can't disagree with you there. > >> > >>> If Erlang syntax were generalised to > >>> > >>> ends_with(X)(Y) -> string:equal(string:right(Y, length(X)), X). > >>> > >>> we could eliminate those three tokens. > >>> > >>> What's more, we could do that *WITHOUT* any weird restrictions on > >>> - whether pattern matching is allowed in the fun > >>> - the form of the fun body > >>> - where the arguments appear in the fun body > >>> - the order in which the arguments appear in the fun body. > >>> and *WITHOUT* > >>> - any weird non-intention-revealing tokens, whether '_' or '?' > >>> > >> > >> Yes but you have to admit, it does look a bit odd. > > > > Yes, but that is precisely because it looks just like other languages > > that do Curried functions. > > > > ends_with (x) (y) = rtake y (length x) == x > > > > is perfectly good Haskell, assuming an rtake function, and > > > > fun ends_with (x) (y) = > > List.drop (y, length y - length x) = x > > > > is perfectly good SML, or would be if it didn't crash when y is > > shorter than x. > > > >> Why can't I just > >> use the variable 'Y' and let the compiler figure out that the function > >> signature needs to change? > > > > Because it is only in toy examples that a compiler *could* figure out > > *how* the function signature needs to change. > > > >>> If you want to do Haskell-like things, it doesn't make sense not > >>> to do it in a Haskell-like way, and that is to say that > >>> > >>> ()()...() -> > >>> > >>> is equivalent to > >>> > >>> () -> > >>> fun () -> > >>> ... > >>> fun () -> > >>> > >>> end > >>> ... > >>> end > >>> > >>> *NO* new tokens! > >>> *NO* weird restrictions! > >>> Good consistency with the way Clean and ML and Haskell do it. > >>> *NO* changes elsewhere in the language. > >>> > >> > >> Great - is it going to get through the eep process? Do we need to vote > >> on it, contribute (e.g., test proposed patches, etc) or whatever? > > > > I don't have time to write up an EEP today, but I'll see what I can do. > > The nice thing about it is that it's entirely in the front end; the > > rest of the compiler doesn't need to know anything about it. > > > >> > >>> Let's see what we have to do now: > >>> > >>> c(F1, F2) -> fun (X) -> F2(F1(X)) end. > >>> c(F1, F2, F3) -> fun (X) -> F3(F2(F1(X))) end. > >>> c(F1, F2, F3, F4) -> fun (X) -> F4(F3(F2(F1(X)))) end. > >>> > >>> doodle(X) -> > >>> F = c(fun do_thing/1, > >>> fun calculate_next_thing/1, > >>> fun get_bored_of_typing_result_x, > >>> fun start_getting_annoyed_with_lazy_programmers/1), > >>> {ok, F(X)}. > >>> > >>> Nope, not hard. Trivial, in fact. > >> > >> Boilerplate. > > > > No, library code, done *ONCE*. > > The only "boilerplate" would be the > > -import(compose, [c/4]). % plus any others you want > > line. > > > > It would, in fact, have precisely the same status as function > > composition in Haskell and SML. Library code. > > > >>> The question is, in a language without static types, how do you > >>> tell the difference between an intentional foo/2 meaning a function > >>> and an erroneous foo/2 that should have been Foo/2, with Foo a > >>> variable bound to a number. > >> > >> We're never going to get static types in Erlang, so I think the answer > >> is that you'd end up with a failing unit or integration test case. Not > >> sure how to do a "raised eyebrow" smiley. > > > > We *have* optional static types in Erlang, but you're right that they > > will probably never be mandatory. > > > > Testing and static checking are complementary tools. > > We need both. Thank goodness we *have* both in Erlang. > > > >> The compiler knows full well that ()/ evaluates > >> to a fun!? > > > > Only if preceded by 'fun'. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Mon Dec 16 20:39:35 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Mon, 16 Dec 2013 20:39:35 +0100 Subject: [erlang-questions] Matthew Sackman's "cut" proposal In-Reply-To: References: Message-ID: <0E4DCA2A-1CEC-4100-9470-2DCE6B702CB4@gmail.com> True, it may be sugar. But it is certainly not saccharine. While it may look like fun map(do_stuff())/1 and fun (_2) -> map(do_stuff(), _2) end are equivalent, they aren?t. The returned closure in my proposal closes over the pre-supplied arguments, not anything else. This means the code expands to: _1 = do_stuff(), fun (_2) -> map(_1, _2) end. The pre-supplied arguments are evaluated at the abstraction site, not when the returned closure is called. This also avoids a whole set of ambiguities caused by the introduction of a new scope. All things said, I am not usually for syntax sugar and I would not care if such a proposal were to be rejected. I will probably implement it anyway, to play with it. I do not like your ?+? proposal. I reused ?/? only because it is already abused for funs. Regards, -- Anthony Ramine Le 16 d?c. 2013 ? 18:47, Erik S?e S?rensen a ?crit : > Disclaimer 2: Surface syntax bikeshed! From a.brandon.clark@REDACTED Mon Dec 16 20:49:17 2013 From: a.brandon.clark@REDACTED (Brandon Clark) Date: Mon, 16 Dec 2013 11:49:17 -0800 Subject: [erlang-questions] Debugger hangs In-Reply-To: References: Message-ID: I've had this same problem since R15. I see two issues. First, the debugger hangs when you run it using the Quartz-enabled version of "wish" that comes with OS X. Second, the port handler hasn't been upgraded to accommodate wish 8.6, so even if you install a new Tk port, Erlang will still prefer Apple's wish unless you do something to coerce it. This an ugly solution, but here's how I made the debugger usable on Mac OS X: 1. Install the x11 variant of the Tk port, ("port install tk +x11"). This will install wish as /opt/local/bin/wish8.6. If you run /opt/local/bin/wish8.6 from the command line and either of these icons appears, then you're still using Quartz; uninstall Tk and try again: [image: Inline image 1] [image: Inline image 3] You should see only the app icon for the X11 server, e.g: [image: Inline image 2] 2. Make sure your PATH lists /opt/local/bin before /usr/bin. 3. Create a symlink to trick the port handler into using the new port. sudo ln -s /opt/local/bin/wish8.6 /opt/local/bin/wish85 Here's why it's necessary: When starting wish, the port handler (/opt/local/lib/erlang/lib/gs-1.5.15.2/src/gstk_port_handler.erl) looks for these executables in order: 46 -define(WISHNAMES, ["wish85","wish8.5", 47 "wish84","wish8.4", 48 "wish83","wish8.3", 49 "wish82","wish8.2", 50 "wish"]). Notice that wish 8.6 isn't in the list. That's why it always finds the Apple version first. If your path places /opt/local/bin before /usr/bin, creating the symlink will cause it to find the upgraded wish8.6 first. If you don't like the symlink solution, you can also modify the code. Edit /opt/local/lib/erlang/lib/gs-1.5.15.2/src/gstk_port_handler.erl, and change WISHLIST to include wish8.6: 46 -define(WISHNAMES, ["wish8.6","wish85","wish8.5", 47 "wish84","wish8.4", 48 "wish83","wish8.3", 49 "wish82","wish8.2", 50 "wish"]). Or you can simply re-order the list to cause it to respect whatever version of "wish" comes first in your path. This is probably more elegant: 46 -define(WISHNAMES, ["wish","wish85","wish8.5", 47 "wish84","wish8.4", 48 "wish83","wish8.3", 49 "wish82","wish8.2"]). When you're done editing, then: cd /opt/local/lib/erlang/lib/gs-1.5.15.2/ rebar compile And that's it. You should have a debugger now. ~BC On Sun, Dec 15, 2013 at 11:51 AM, Denis Justinek wrote: > Hello. > > Has anyone found a solution to this problem? > > It can also be reproduced on OS X 10.8 / 10.9 : Resizing the debugger > window freezes the GUI and makes it unresponsive. > > -- > > Denis > > 2013/9/3 Yves S. Garret > >> Hello, >> >> I'm running this on a Mac OS X 10.7.5. I have release 16B01. Whenever I >> start up the debugger >> and then increase the size of the windows (by dragging the borders), the >> whole setup just hangs. It >> doesn't come back to me, but sits there and doesn't do anything. >> >> Has anyone else had this problem? How did you get around it? >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2013-12-16 at 11.33.45 AM.png Type: image/png Size: 7640 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2013-12-16 at 11.23.16 AM.png Type: image/png Size: 6972 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 2013-12-16 at 11.45.59 AM.png Type: image/png Size: 6426 bytes Desc: not available URL: From s.j.thompson@REDACTED Mon Dec 16 22:19:27 2013 From: s.j.thompson@REDACTED (Simon Thompson) Date: Mon, 16 Dec 2013 21:19:27 +0000 Subject: [erlang-questions] SBLP 2014 - Preliminary Call for Papers Message-ID: PRELIMINARY CALL FOR PAPERS 18th Brazilian Symposium on Programming Languages (SBLP 2014) A member of CBSoft joint conference http://www.ic.ufal.br/evento/cbsoft2014/ to be held in Maceio, Brazil. CBSoft dates are September 28, 2014 to October 3, 2014 (SBLP dates are yet to be decided.) IMPORTANT DATES Paper abstract submission: May 2nd, 2014 Full paper submission: May 9th, 2014 Notification of acceptance: June 13th, 2014 Final papers due: July 4th, 2014 INTRODUCTION The 18th Brazilian Symposium on Programming Languages, SBLP 2014, will be held in Maceio, a beautiful cite in the Northeastern part of Brazil. The conference will happen between September 28th and October 3rd, 2014. SBLP provides a venue for researchers and practitioners interested in the fundamental principles and innovations in the design and implementation of programming languages and systems. SBLP 2014 invites authors to contribute with technical papers related (but not limited) to: * Program generation and transformation, including domain-specific languages and model-driven development in the context of programming languages. * Programming paradigms and styles, including functional, object-oriented, aspect-oriented, scripting languages, real-time, service-oriented, multithreaded, parallel, and distributed programming. * Formal semantics and theoretical foundations, including denotational, operational, algebraic and categorical. * Program analysis and verification, including type systems, static analysis and abstract interpretation. * Programming language design and implementation, including new programming models, programming language environments, compilation and interpretation techniques. SUBMISSIONS Contributions should be written in Portuguese or English. Papers should fall into one of two different categories: full papers, with at most 15 pages, or short papers, with at most 5 pages. Full papers submitted in English will be published in a volume of Lecture Notes in Computer Science (LNCS), by Springer. For this reason, all papers must be prepared using the LNCS template, available at http://www.springer.com/computer/lncs?SGWID=0-164-6-793341-0. We encourage the submission of short papers reporting partial results of on-going master dissertations or doctoral theses. All accepted papers will be published in the conference proceedings distributed in a digital media by the CBSOFT organizers. Submissions should be done through the SBLP 2014 page at EasyChair, which is available at http://www.easychair.org/conferences/?conf=sblp2014. As in previous editions, a journal's special issue, with selected papers from accepted contributions, is anticipated. Selected papers from the 2003 to the 2008 editions of SBLP were published in special issues of the Journal of Universal Computer Science, by Springer. The post-proceedings of SBLP from 2009 to 2012, also with selected papers from the conference, have been published as special issues of Science of Computer Programming, by Elsevier. KEYNOTE SPEAKERS Louis-Noel Pouchet, University of California Los Angeles Fabrice Rastello, INRIA PROGRAMME CHAIR Fernando Magno Quintao Pereira, UFMG PROGRAMME COMMITTEE Alberto Pardo, Universidad de la Rep?blica Alex Garcia, IME Alvaro Moreira, Federal University of Rio Grande do Sul Andre Rauber Du Bois, Federal University of Pelotas Carlos Camar?o, Federal University of Minas Gerais Christiano Braga, Fluminense Federal University Fabio Mascarenhas, Federal University of Rio de Janeiro Fernando Pereira, Federal University of Minas Gerais Fernando Castor, Federal University of Pernambuco Francisco Carvalho-Junior, Federal University of Ceara Hans-Wolfgang Loidl, Heriot-Watt University Jo?o Saraiva, University of Minho Joao F. Ferreira, Teesside University Louis-Noel Pouchet, University of California, Los Angeles Lucilia Figueiredo, Federal University of Ouro Preto Luis Barbosa, University of Minho Manuel A. Martins, University of Aveiro Marcello Bonsangue, Leiden University Marcelo Maia, Federal University of Uberl?ndia Marcelo D'Amorim, Federal University of Pernambuco Mariza Bigonha, Federal University of Minas Gerais Martin Musicante, Federal University of Rio Grande do Norte Noemi Rodriguez, PUC-Rio Peter Mosses, Swansea University Rafael Lins, Federal University of Pernambuco Renato Cerqueira, PUC-Rio Roberto Bigonha, Federal University of Minas Gerais Rodrigo Geraldo, Federal University of Ouro Preto Sandro Rigo, State University of Campinas S?rgio Medeiros, Federal University of Sergipe Simon Thompson, University of Kent Varmo Vene, University of Tartu Simon Thompson | Professor of Logic and Computation School of Computing | University of Kent | Canterbury, CT2 7NF, UK s.j.thompson@REDACTED | M +44 7986 085754 | W www.cs.kent.ac.uk/~sjt From kaveh.shahbazian@REDACTED Mon Dec 16 21:24:17 2013 From: kaveh.shahbazian@REDACTED (Kaveh Shahbazian) Date: Mon, 16 Dec 2013 23:54:17 +0330 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: <4AA09EA9-685B-44EB-9F90-21869FFE8F01@cs.otago.ac.nz> References: <4AA09EA9-685B-44EB-9F90-21869FFE8F01@cs.otago.ac.nz> Message-ID: Not really; I did not want to simulate OO in Erlang (BTW Erlang feels perfectly OO to me; maybe in a very irrelevant way). I just used C# sample to convey something similar to what I wanted to do - which as I've mentioned in other email turned out to be a horrible sample. I wanted to do this: test(V) -> X = ?protocolX(V), X:act1(), X:act2(), % ... X:actN(SomeArguments), OtherThings(). Which as Bob described is not a good (or rather great) idea to use in Erlang for one that calling functions on tuples add more levels of redirection that can affect the performance in not so pleasant ways. I am not an Erlang guru but I really like the environment and currently I lean toward Elixir more than Erlang; because it has macros! And I know I should not macros on a daily basis, but just knowing they are there and possible is ultra comforting. Kaveh Shahbazian ?Walking on water and developing software from a specification are easy if both are frozen.? ? Edward Berard On Mon, Dec 16, 2013 at 6:38 AM, Richard A. O'Keefe wrote: > > On 13/12/2013, at 7:31 PM, Kaveh Shahbazian wrote: > > > I wanted to write something like ((IStringer)object).ToString() (in C#) > in Erlang. > > Can you make it a little bit clearer exactly what it is you > need to do? > > There is a fundamental distinction between the way > something like > object.toString() > works in OO languages > to_string(Object) > works in Erlang: > - in the OO languages the "object" is in charge of what > .toString() means > - in Erlang, the _function_ is in charge of what to_string() > means. > > Then I came up with this idea/code in Erlang - which is nice enough to > me like: > > > > ?stringer(my_val):to_string(). > > > > 1 - Why nobody use this or promote things based on stateful modules in > Erlang? > > Where do you get "stateful" from? An Erlang parameterised module > is a *value*. > > In this case, "my_val" is *still* not in charge of what to_string > does. > > In any case, one way to begin to understand parameterised modules > in Erlang is to start by thinking of > > -module(foo, {X,Y,Z}). > -export([to_string/0]). > to_string() -> > > as if it were something not entirely unlike > > -module(foo). > -export([new/1,to_string/1]). > new({X,Y,Z}) -> {foo,X,Y,Z}. > to_string(This = {foo,X,Y,Z}) -> ... > > There is, in short, no fundamental theoretical or practical difference > between > > stringer(my_val):to_string() > > and > > stringer:to_string(my_val). > > Anything you can do with the first you can CERTAINLY do with the second. > > If you want to simulate OO in Erlang, > (1) lie down until the feeling passes off; > (2) if the condition persists, see a doctor (of CS); > (3) if the cure is unsuccessful, > represent an "object" by a tuple > {tag,Funs,Data} > where Funs is a tuple of functions shared by a number of > instances (yes, it's a vtable), and write > > to_string(Obj = {_,{...,TS...},...}) -> > TS(Obj). > > I am deadly serious about (1). > > When you using ((IStringer)object).to_string() > you are literally saying > > I don't know and I don't care what object > is as long as it conforms to the IStringer > interface. I don't know and I don't care > what the .to_string() method does as long > as it has the right kind of arguments and > results; it could reformat my hard drive, > it could send threatening messages to the > president of the USA, it could burn down > the local hospital, I really really DON'T > CARE. > > If that's not what you mean, then perhaps you'd better write > your code another way, even in C#. Any time you pass around > something with pluggable behaviour, ideally you need a strong > type-AND-EFFECT system that lets you limit the damage that > can be done, or at the least you need comments saying what is > supposed to be allowed. > > I'm actually serious about (2) as well: see if you can find > a copy of "Why Joe Hates OO" by our very own Joe Armstrong. > > (For the record, I am not an anti-OO bigot. I have spent way > too much of my time building a Smalltalk system I'm generally > quite pleased with to be _that_. But I have come to dread > not knowing what an argument will do if I poke it, especially > in a multithreading context.) > > > (OTP aside and from talking to some Erlangers they did not know that > actually OTP is built around this! > > They didn't know it because it isn't true. For a long time Erlang > didn't have parameterised modules, then it did as an experiment, > and now it doesn't again. OTP managed without them and does again. > > > > So really there is a need to change how Erlang is being taught and > promoted. It's possible that I am confused.). > > If you find yourself struggling to do things the language X way > in language Y, it's generally a better to look for an _idiomatic_ > way to solve the underlying problem in language Y than to try to > warp language Y into acting like language X. Just recently I've > seen a horrible example of a Prolog system being warped to be > more like JavaScript, to the applause of people who haven't > thought about the benefits of being able to use other Prolog > systems as well... > > As one example, it's not unknown for an Erlang module that > defines a data type to export a format/1 and maybe format/2 > for converting an instance to a string or writing it to a > stream. Using > > snorkelwhacker:format(Monster) > > makes it clear that Monster is supposed to be the kind of thing > that the snorkelwhacker module knows about; this might be one of > several things. -------------- next part -------------- An HTML attachment was scrubbed... URL: From donpedrothird@REDACTED Mon Dec 16 23:39:19 2013 From: donpedrothird@REDACTED (John Doe) Date: Tue, 17 Dec 2013 02:39:19 +0400 Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility Message-ID: At the moment it is impossible to run crypto app from Erlang R16+ on recent Centos versions (6.4 or newer) and likely on newer versions of Fedora and RHEL as well. openssl 1.0.1 is installed. Unable to load crypto library. Failed with error: "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m'" Crypto from R15B03 works with no problems -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt@REDACTED Tue Dec 17 01:20:48 2013 From: matt@REDACTED (Matt Lewandowsky) Date: Mon, 16 Dec 2013 16:20:48 -0800 Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: References: Message-ID: The RHEL OpenSSL changes have been a subject of conversation on a variety of lists lately. http://rhn.redhat.com/errata/RHBA-2013-1751.html is (I believe) the appropriate errata for what you are seeing and Red Hat?s current packages should correct it. If CentOS has the same packages as what is available via RHN, it might be interesting to know what happens if you roll back your OpenSSL package a month or so (to before the FIPS changes). It?s entirely possible that there are still issues which need RH Bugzilla entries. I haven?t built Erlang on an RHEL 6 clone since the OpenSSL changes have occurred. However, crypto seemed to work fine the last time I did. (I?d say about 6 weeks ago.) --Matt -- Matt Lewandowsky Big Geek Greenviolet matt@REDACTED http://www.greenviolet.net +1 415 578 5782 (US) +44 844 484 8254 (UK) From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of John Doe Sent: Monday, 16 December, 2013 14:39 To: erlang-questions@REDACTED Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility At the moment it is impossible to run crypto app from Erlang R16+ on recent Centos versions (6.4 or newer) and likely on newer versions of Fedora and RHEL as well. openssl 1.0.1 is installed. Unable to load crypto library. Failed with error: "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m'" Crypto from R15B03 works with no problems -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 6569 bytes Desc: not available URL: From atulindore2@REDACTED Tue Dec 17 01:59:36 2013 From: atulindore2@REDACTED (Atul Goyal) Date: Tue, 17 Dec 2013 06:29:36 +0530 Subject: [erlang-questions] Erlang Basics: Reading File Content Message-ID: File IO is one thing I really love in Erlang. Especially with sockets , we can use : file:sendfile/2 (http://www.erlang.org/doc/man/file.html#sendfile-2) for example : somefunction()-> .... .... {ok,Sock}=gen_tcp:connect( Ip , Port , []) , .... .... {ok,Bytes_sent} = file:sendfile(Filename , Sock) .... .... Of course you can add some error checking code to it :). > > Message: 4 > Date: Mon, 16 Dec 2013 09:48:34 -0500 > From: Ari King > To: erlang-questions@REDACTED > Subject: [erlang-questions] Erlang Basics: Reading File Content > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > I've just started with Erlang and to learn/practice I'm attempting to put > together a simple TCP server that reads data from a file and writes it to a > socket. So far I've put together some code to read the data (combination of > ascii, binary, control characters). But since (as I understand) Erlang > doesn't have a return mechanism, how do I read a line of data and return it > to be written to the socket? Right now, the code just recursively collects > the data. > > -module(mock_tcp). > -export([start/1]). > > start([Ip, Port, Filename]) -> > io:format("Server available at ~w on port ~w. Reading from ~w.", [Ip, > Port, Filename]), > {ok, Device) = file:open(Filename, read), > try get_data(Device) > after file:close(Device) > end. > > get_data(Device) -> > case io:get_line(Device) of > {ok, Data} -> [Data | get_data(Device)]; > eof -> [] > end. > > Thanks. > > Ari > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: From mayamatakeshi@REDACTED Tue Dec 17 02:31:30 2013 From: mayamatakeshi@REDACTED (mayamatakeshi) Date: Tue, 17 Dec 2013 10:31:30 +0900 Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: References: Message-ID: Actually, it seems the problem is with the new openssl package. Before its release (CentOS 6.5), it was OK to build erlang R16XXX on CentOS 6.4. Small discussion from the yaws-list: http://sourceforge.net/mailarchive/message.php?msg_id=31759076 On Tue, Dec 17, 2013 at 9:20 AM, Matt Lewandowsky wrote: > The RHEL OpenSSL changes have been a subject of conversation on a variety > of lists lately. > > > > http://rhn.redhat.com/errata/RHBA-2013-1751.html is (I believe) the > appropriate errata for what you are seeing and Red Hat?s current packages > should correct it. If CentOS has the same packages as what is available via > RHN, it might be interesting to know what happens if you roll back your > OpenSSL package a month or so (to before the FIPS changes). It?s entirely > possible that there are still issues which need RH Bugzilla entries. > > > > I haven?t built Erlang on an RHEL 6 clone since the OpenSSL changes have > occurred. However, crypto seemed to work fine the last time I did. (I?d say > about 6 weeks ago.) > > > > --Matt > > > > -- > > Matt Lewandowsky > > Big Geek > > Greenviolet > > matt@REDACTED http://www.greenviolet.net > > +1 415 578 5782 (US) +44 844 484 8254 (UK) > > > > *From:* erlang-questions-bounces@REDACTED [mailto: > erlang-questions-bounces@REDACTED] *On Behalf Of *John Doe > *Sent:* Monday, 16 December, 2013 14:39 > *To:* erlang-questions@REDACTED > *Subject:* [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ > incompatibility > > > > At the moment it is impossible to run crypto app from Erlang R16+ on > recent Centos versions (6.4 or newer) and likely on newer versions of > Fedora and RHEL as well. > > openssl 1.0.1 is installed. > > > > Unable to load crypto library. Failed with error: > > "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: > EC_GROUP_new_curve_GF2m'" > > > > > > Crypto from R15B03 works with no problems > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anthonym@REDACTED Tue Dec 17 03:23:01 2013 From: anthonym@REDACTED (Anthony Molinaro) Date: Mon, 16 Dec 2013 18:23:01 -0800 Subject: [erlang-questions] About etop question In-Reply-To: References: Message-ID: <20131217022301.GA92219@alumni.caltech.edu> Also, you might consider https://github.com/mazenharake/entop it does a really good job and doesn't have the formatting issues that I've had with etop. -Anthony On Mon, Dec 16, 2013 at 11:26:18AM +0100, Jesper Louis Andersen wrote: > On Mon, Dec 16, 2013 at 10:33 AM, ????????? wrote: > > > In recently days, i found our server consume a lot of memory. For example, > > I only type erl command in the shell. It is about to consume 4G memory. I > > try to monitor with etop toos. Then i met a new question which the Memory > > column display some stars[1]. > > > It is the formatting code which notes it cannot represent the size of the > number. Usually because the call to io_lib:format specifies a given number, > N, of characters and the numbers representation is too big to fit into N > characters. > > Good libraries/tricks for hunting these kinds of problems: > > * install an alarm_handler and run mem_sup. Report stuff about the Pid > using too much memory. > * Use Fred Hebert's `recon` library (ferd/recon on Github). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ------------------------------------------------------------------------ Anthony Molinaro From Arne.Bachmann@REDACTED Tue Dec 17 09:45:00 2013 From: Arne.Bachmann@REDACTED (Arne.Bachmann@REDACTED) Date: Tue, 17 Dec 2013 08:45:00 +0000 Subject: [erlang-questions] ODBC module missing since R16B03 on Windows 64bit Message-ID: Just wanted to report a bug - couldn't find a bug tracker for Erlang releases. I noticed that the official installer otp_win64_R16B03.exe (otp 5.10.4) doesn't install the odbc modules anymore - looks like a bug since the odbc directory is only partially filled. I could reproduce this on two Windows 7 computers and went back to R16B02 (5.10.3), which has it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Tue Dec 17 10:21:53 2013 From: peerst@REDACTED (Peer Stritzinger) Date: Tue, 17 Dec 2013 10:21:53 +0100 Subject: [erlang-questions] ODBC module missing since R16B03 on Windows 64bit References: Message-ID: On 2013-12-17 08:45:00 +0000, said: > Just wanted to report a bug ? couldn?t find a bug tracker for Erlang releases. > ? > I noticed that the official installer otp_win64_R16B03.exe (otp 5.10.4) > doesn?t install the odbc modules anymore ? looks like a bug since the > odbc directory is only partially filled. > I could reproduce this on two Windows 7 computers and went back to > R16B02 (5.10.3), which has it. FYI: there is a separate bug reporting mailing list: http://erlang.org/mailman/listinfo/erlang-bugs Cheers, -- Peer From donpedrothird@REDACTED Tue Dec 17 10:52:40 2013 From: donpedrothird@REDACTED (Evgeny M) Date: Tue, 17 Dec 2013 01:52:40 -0800 (PST) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: References: Message-ID: <9ceb4f67-e0ef-4353-bda3-92fe3956b654@googlegroups.com> Yeah, I see Seems like the latest openssl does not announce anymore elliptic curves which are not supported. And crypto fails to start even if it does not use these curves. I'd say this is quite serious problem, as about half of cheap VPS/Dedicated servers are run on Centos - this is the only distro supported by CPanel afaik. Suddenly as more and more hosting companies start roll on the latest Centos, their clients will not be able to use recent erlang with crypto no more. I think crypto should be patched so that it could be started even if some functionality from openssl is not available. ???????, 17 ??????? 2013 ?., 4:20:48 UTC+4 ???????????? Matt Lewandowsky ???????: > > The RHEL OpenSSL changes have been a subject of conversation on a variety > of lists lately. > > > > http://rhn.redhat.com/errata/RHBA-2013-1751.html is (I believe) the > appropriate errata for what you are seeing and Red Hat?s current packages > should correct it. If CentOS has the same packages as what is available via > RHN, it might be interesting to know what happens if you roll back your > OpenSSL package a month or so (to before the FIPS changes). It?s entirely > possible that there are still issues which need RH Bugzilla entries. > > > > I haven?t built Erlang on an RHEL 6 clone since the OpenSSL changes have > occurred. However, crypto seemed to work fine the last time I did. (I?d say > about 6 weeks ago.) > > > > --Matt > > > > -- > > Matt Lewandowsky > > Big Geek > > Greenviolet > > ma...@REDACTED http://www.greenviolet.net > > +1 415 578 5782 (US) +44 844 484 8254 (UK) > > > > *From:* erlang-quest...@REDACTED [mailto: > erlang-questions-bounces@REDACTED ] *On Behalf Of *John Doe > *Sent:* Monday, 16 December, 2013 14:39 > *To:* erlang-q...@REDACTED > *Subject:* [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ > incompatibility > > > > At the moment it is impossible to run crypto app from Erlang R16+ on > recent Centos versions (6.4 or newer) and likely on newer versions of > Fedora and RHEL as well. > > openssl 1.0.1 is installed. > > > > Unable to load crypto library. Failed with error: > > "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: > EC_GROUP_new_curve_GF2m'" > > > > > > Crypto from R15B03 works with no problems > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aschultz@REDACTED Tue Dec 17 15:50:34 2013 From: aschultz@REDACTED (Andreas Schultz) Date: Tue, 17 Dec 2013 15:50:34 +0100 (CET) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: References: Message-ID: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> Hi, ----- Original Message ----- > At the moment it is impossible to run crypto app from Erlang R16+ on recent > Centos versions (6.4 or newer) and likely on newer versions of Fedora and > RHEL as well. > openssl 1.0.1 is installed. > > Unable to load crypto library. Failed with error: > "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: > EC_GROUP_new_curve_GF2m'" That is not an Erlang problem itself. The binary Erlang packet you installed was build on an system that had a OpenSSL with EC support enabled while the system you are trying to install one, has OpenSSL with EC support disabled. So basically the Erlang packet was build on an incompatible build host. IMHO, you should report this as a bug to the package builder you got the Erlang package from. Regards Andreas > > > Crypto from R15B03 works with no problems > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- -- Dipl. Inform. Andreas Schultz From aschultz@REDACTED Tue Dec 17 15:52:54 2013 From: aschultz@REDACTED (Andreas Schultz) Date: Tue, 17 Dec 2013 15:52:54 +0100 (CET) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: <9ceb4f67-e0ef-4353-bda3-92fe3956b654@googlegroups.com> References: <9ceb4f67-e0ef-4353-bda3-92fe3956b654@googlegroups.com> Message-ID: <1695712605.8289.1387291974061.JavaMail.zimbra@tpip.net> Hi, ----- Original Message ----- > Yeah, I see > Seems like the latest openssl does not announce anymore elliptic curves which > are not supported. No, that is Centos/Redhat stupidity. OpenSSL by default does EC, but Redhat choose to disabled EC so that the NSA can better spy on you. Andreas > And crypto fails to start even if it does not use these > curves. > I'd say this is quite serious problem, as about half of cheap VPS/Dedicated > servers are run on Centos - this is the only distro supported by CPanel > afaik. Suddenly as more and more hosting companies start roll on the latest > Centos, their clients will not be able to use recent erlang with crypto no > more. > > I think crypto should be patched so that it could be started even if some > functionality from openssl is not available. > > > ???????, 17 ??????? 2013 ?., 4:20:48 UTC+4 ???????????? Matt Lewandowsky > ???????: > > > > > The RHEL OpenSSL changes have been a subject of conversation on a variety of > lists lately. > > > > http://rhn.redhat.com/errata/RHBA-2013-1751.html is (I believe) the > appropriate errata for what you are seeing and Red Hat?s current packages > should correct it. If CentOS has the same packages as what is available via > RHN, it might be interesting to know what happens if you roll back your > OpenSSL package a month or so (to before the FIPS changes). It?s entirely > possible that there are still issues which need RH Bugzilla entries. > > > > I haven?t built Erlang on an RHEL 6 clone since the OpenSSL changes have > occurred. However, crypto seemed to work fine the last time I did. (I?d say > about 6 weeks ago.) > > > > --Matt > > > > -- > > Matt Lewandowsky > > Big Geek > > Greenviolet > > ma...@REDACTED http://www.greenviolet.net > > +1 415 578 5782 (US) +44 844 484 8254 (UK) > > > > > From: erlang-quest...@REDACTED [mailto: erlang-questions-bounces@REDACTED > ] On Behalf Of John Doe > Sent: Monday, 16 December, 2013 14:39 > To: erlang-q...@REDACTED > Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ > incompatibility > > > > > > At the moment it is impossible to run crypto app from Erlang R16+ on recent > Centos versions (6.4 or newer) and likely on newer versions of Fedora and > RHEL as well. > > > openssl 1.0.1 is installed. > > > > > > Unable to load crypto library. Failed with error: > > > "load_failed, Failed to load NIF library: 'crypto.so: undefined symbol: > EC_GROUP_new_curve_GF2m'" > > > > > > > > > Crypto from R15B03 works with no problems > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- -- Dipl. Inform. Andreas Schultz From donpedrothird@REDACTED Tue Dec 17 16:56:59 2013 From: donpedrothird@REDACTED (Evgeny M) Date: Tue, 17 Dec 2013 07:56:59 -0800 (PST) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> References: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> Message-ID: <8aa2cc82-a25a-4fb6-896e-5c51ec7903cd@googlegroups.com> >That is not an Erlang problem itself. The binary Erlang packet you installed >was build on an system that had a OpenSSL with EC support enabled while the >system you are trying to install one, has OpenSSL with EC support disabled. Nope, I compiled erlang from sources, and it throws the error in crypto:start(). Seems like ./configure does not detect missing curves. >No, that is Centos/Redhat stupidity. OpenSSL by default does EC, but Redhat choose >to disabled EC so that the NSA can better spy on you. Sure it's not erlang fault, but still do we really want to ditch half of potential user base? Or suggest everyone to install outdated R15, as it still works? -------------- next part -------------- An HTML attachment was scrubbed... URL: From aschultz@REDACTED Tue Dec 17 17:15:35 2013 From: aschultz@REDACTED (Andreas Schultz) Date: Tue, 17 Dec 2013 17:15:35 +0100 (CET) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: <8aa2cc82-a25a-4fb6-896e-5c51ec7903cd@googlegroups.com> References: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> <8aa2cc82-a25a-4fb6-896e-5c51ec7903cd@googlegroups.com> Message-ID: <979231231.8709.1387296935531.JavaMail.zimbra@tpip.net> Hi, ----- Original Message ----- > > > >That is not an Erlang problem itself. The binary Erlang packet you > installed > >was build on an system that had a OpenSSL with EC support enabled while > the > >system you are trying to install one, has OpenSSL with EC support > disabled. > > Nope, I compiled erlang from sources, and it throws the error in > crypto:start(). Seems like ./configure does not detect missing curves. configure has nothing to do with it. When openssl is configured and build a file named opensslconf.h is generated (on Ubuntu it's installed to /usr/include/x86_64-linux-gnu/openssl/opensslconf.h) That file is indirectly included though the other openssl headers and specifies at compile time what ciphers are supported. That your Erlang was compiled with EC support when your openssl seems to be missing support for it, means that that config header must be broken. Would be great to know how that happened. Andreas > >No, that is Centos/Redhat stupidity. OpenSSL by default does EC, but > Redhat choose > > >to disabled EC so that the NSA can better spy on you. > > Sure it's not erlang fault, but still do we really want to ditch half of > potential user base? Or suggest everyone to install outdated R15, as it > still works? > > -- -- Dipl. Inform. Andreas Schultz From aschultz@REDACTED Tue Dec 17 17:36:53 2013 From: aschultz@REDACTED (Andreas Schultz) Date: Tue, 17 Dec 2013 17:36:53 +0100 (CET) Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: <979231231.8709.1387296935531.JavaMail.zimbra@tpip.net> References: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> <8aa2cc82-a25a-4fb6-896e-5c51ec7903cd@googlegroups.com> <979231231.8709.1387296935531.JavaMail.zimbra@tpip.net> Message-ID: <1175921809.8819.1387298213335.JavaMail.zimbra@tpip.net> Hi, Found it, Centos 6.5 disables EC only partly. Most EC functions are there, only the support for GF2m curves has been disabled (that means all the sectXXXr1 and r2 curves won't work). The corresponding OpenSSL define OPENSSL_NO_EC2M is set. The simplest (untested) workaround would be to put a "-DOPENSSL_NO_EC=1" into CFLAGS, e.g.: CFLAGS="-DOPENSSL_NO_EC=1" ./configure Alternatively, you could edit lib/crypto/c_src/crypto.c and change: #if OPENSSL_VERSION_NUMBER >= 0x009080ffL \ && !defined(OPENSSL_NO_EC) \ && !defined(OPENSSL_NO_ECDH) \ && !defined(OPENSSL_NO_ECDSA) # define HAVE_EC #endif to #if OPENSSL_VERSION_NUMBER >= 0x009080ffL \ && !defined(OPENSSL_NO_EC) \ && !defined(OPENSSL_NO_EC2M) \ && !defined(OPENSSL_NO_ECDH) \ && !defined(OPENSSL_NO_ECDSA) # define HAVE_EC #endif Both will disable EC completely. Andreas ----- Original Message ----- > Hi, > > ----- Original Message ----- > > > > > > >That is not an Erlang problem itself. The binary Erlang packet you > > installed > > >was build on an system that had a OpenSSL with EC support enabled while > > the > > >system you are trying to install one, has OpenSSL with EC support > > disabled. > > > > Nope, I compiled erlang from sources, and it throws the error in > > crypto:start(). Seems like ./configure does not detect missing curves. > > configure has nothing to do with it. When openssl is configured and build > a file named opensslconf.h is generated (on Ubuntu it's installed to > /usr/include/x86_64-linux-gnu/openssl/opensslconf.h) > > That file is indirectly included though the other openssl headers and > specifies at compile time what ciphers are supported. That your Erlang > was compiled with EC support when your openssl seems to be missing > support for it, means that that config header must be broken. > > Would be great to know how that happened. > > Andreas > > > >No, that is Centos/Redhat stupidity. OpenSSL by default does EC, but > > Redhat choose > > > > >to disabled EC so that the NSA can better spy on you. > > > > Sure it's not erlang fault, but still do we really want to ditch half of > > potential user base? Or suggest everyone to install outdated R15, as it > > still works? > > > > > > -- > -- > Dipl. Inform. > Andreas Schultz > -- -- Dipl. Inform. Andreas Schultz From matt@REDACTED Tue Dec 17 17:37:26 2013 From: matt@REDACTED (Matt Lewandowsky) Date: Tue, 17 Dec 2013 08:37:26 -0800 Subject: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility In-Reply-To: <979231231.8709.1387296935531.JavaMail.zimbra@tpip.net> References: <585283438.8283.1387291834265.JavaMail.zimbra@tpip.net> <8aa2cc82-a25a-4fb6-896e-5c51ec7903cd@googlegroups.com> <979231231.8709.1387296935531.JavaMail.zimbra@tpip.net> Message-ID: Hi, It happened because he built with an OpenSSL which doesn?t incorporate Red Hat's errata, most likely. This was an issue with a great many products for all of like a week or two while the broken packages were being delivered. ? It's not Erlang's fault. And Red Hat fixed their packages. The only two likely options are that the distro (or, more likely, system) does not have the current packages; or, there is a new bug which needs to be filed with Red Hat (less likely).? --Matt -- Matt Lewandowsky Big Geek Greenviolet matt@REDACTED http://www.greenviolet.net +1 415 578 5782 (US) +44 844 484 8254 (UK) Sent from my BlackBerry 10 smartphone. From: Andreas Schultz Sent: Tuesday, December 17, 2013 08:15 To: Evgeny M Cc: erlang-programming@REDACTED; erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang Crypto R16+ and Centos 6.4+ incompatibility Hi, ----- Original Message ----- > > > >That is not an Erlang problem itself. The binary Erlang packet you > installed > >was build on an system that had a OpenSSL with EC support enabled while > the > >system you are trying to install one, has OpenSSL with EC support > disabled. > > Nope, I compiled erlang from sources, and it throws the error in > crypto:start(). Seems like ./configure does not detect missing curves. configure has nothing to do with it. When openssl is configured and build a file named opensslconf.h is generated (on Ubuntu it's installed to /usr/include/x86_64-linux-gnu/openssl/opensslconf.h) That file is indirectly included though the other openssl headers and specifies at compile time what ciphers are supported. That your Erlang was compiled with EC support when your openssl seems to be missing support for it, means that that config header must be broken. Would be great to know how that happened. Andreas > >No, that is Centos/Redhat stupidity. OpenSSL by default does EC, but > Redhat choose > > >to disabled EC so that the NSA can better spy on you. > > Sure it's not erlang fault, but still do we really want to ditch half of > potential user base? Or suggest everyone to install outdated R15, as it > still works? > > -- -- Dipl. Inform. Andreas Schultz _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ari.brandeis.king@REDACTED Tue Dec 17 19:53:37 2013 From: ari.brandeis.king@REDACTED (Ari King) Date: Tue, 17 Dec 2013 13:53:37 -0500 Subject: [erlang-questions] Simple TCP Server Message-ID: Hi, The code below results in "init terminating in do_boot." Seemingly the problem is on line 5, does anyone see what is wrong with it? Additionally, I'm trying to pass the port in as a command line argument, but for some reason it doesn't work and I need to hardcode it. -module(mock_tcp). -export([start/1]). start([Port, Filename]) -> {ok, Listen} = gen_tcp:listen(Port, [binary]), spawn(fun() -> connect(Listen, Filename) end), io:format("Server available on port ~w. Reading from file ~w.", [Port, Filename]). connect(Listen, Filename) -> {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> connect(Listen, Filename) end), {ok, Device} = file:open(Filename, read), get_data(Device, Socket). get_data(Device, Socket) -> case io:get_line(Device) of {ok, Data} -> gen_tcp:send(Socket, Data), get_data(Device, Socket); eof -> file:close(Device), gen_tcp:close(Socket) end. Thanks. -Ari -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Tue Dec 17 20:49:43 2013 From: bob@REDACTED (Bob Ippolito) Date: Tue, 17 Dec 2013 11:49:43 -0800 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: Message-ID: What's the full traceback? How are you attempting to execute this? Are you starting inets first? On Tuesday, December 17, 2013, Ari King wrote: > Hi, > > The code below results in "init terminating in do_boot." Seemingly the > problem is on line 5, does anyone see what is wrong with it? Additionally, > I'm trying to pass the port in as a command line argument, but for some > reason it doesn't work and I need to hardcode it. > > -module(mock_tcp). > -export([start/1]). > > start([Port, Filename]) -> > {ok, Listen} = gen_tcp:listen(Port, [binary]), > spawn(fun() -> connect(Listen, Filename) end), > io:format("Server available on port ~w. Reading from file ~w.", [Port, > Filename]). > > connect(Listen, Filename) -> > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> connect(Listen, Filename) end), > {ok, Device} = file:open(Filename, read), > get_data(Device, Socket). > > get_data(Device, Socket) -> > case io:get_line(Device) of > {ok, Data} -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket); > eof -> > file:close(Device), > gen_tcp:close(Socket) > end. > > Thanks. > > -Ari > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Tue Dec 17 20:59:07 2013 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Tue, 17 Dec 2013 11:59:07 -0800 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: Message-ID: You might want to add a {reuseaddr, true} option to the listening socket options. If this doesn't help, try actually logging the result of gen_tcp:listen/2 before matching it, this would be much faster to figure out. On Tue, Dec 17, 2013 at 10:53 AM, Ari King wrote: > Hi, > > The code below results in "init terminating in do_boot." Seemingly the > problem is on line 5, does anyone see what is wrong with it? Additionally, > I'm trying to pass the port in as a command line argument, but for some > reason it doesn't work and I need to hardcode it. > > -module(mock_tcp). > -export([start/1]). > > start([Port, Filename]) -> > {ok, Listen} = gen_tcp:listen(Port, [binary]), > spawn(fun() -> connect(Listen, Filename) end), > io:format("Server available on port ~w. Reading from file ~w.", [Port, > Filename]). > > connect(Listen, Filename) -> > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> connect(Listen, Filename) end), > {ok, Device} = file:open(Filename, read), > get_data(Device, Socket). > > get_data(Device, Socket) -> > case io:get_line(Device) of > {ok, Data} -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket); > eof -> > file:close(Device), > gen_tcp:close(Socket) > end. > > Thanks. > > -Ari > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best regards, Dmitry Demeshchuk -------------- next part -------------- An HTML attachment was scrubbed... URL: From fly@REDACTED Tue Dec 17 22:54:57 2013 From: fly@REDACTED (Fred Youhanaie) Date: Tue, 17 Dec 2013 21:54:57 +0000 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: Message-ID: <52B0C831.9020903@anydata.co.uk> To add to the other suggestions: 0. Does it work if you run it from the erlang shell? 1. If you're starting it with "erl -s ..." then the port number will be passed as atom, rather than integer! So you'll need to convert to integer. 2. In the get_date() you probably meant to use file:read_line/1, rather than io:get_line/1. Cheers f. On 17/12/13 18:53, Ari King wrote: > Hi, > > The code below results in "init terminating in do_boot." Seemingly the > problem is on line 5, does anyone see what is wrong with it? Additionally, > I'm trying to pass the port in as a command line argument, but for some > reason it doesn't work and I need to hardcode it. > > -module(mock_tcp). > -export([start/1]). > > start([Port, Filename]) -> > {ok, Listen} = gen_tcp:listen(Port, [binary]), > spawn(fun() -> connect(Listen, Filename) end), > io:format("Server available on port ~w. Reading from file ~w.", [Port, > Filename]). > > connect(Listen, Filename) -> > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> connect(Listen, Filename) end), > {ok, Device} = file:open(Filename, read), > get_data(Device, Socket). > > get_data(Device, Socket) -> > case io:get_line(Device) of > {ok, Data} -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket); > eof -> > file:close(Device), > gen_tcp:close(Socket) > end. > > Thanks. > > -Ari From ok@REDACTED Wed Dec 18 02:58:41 2013 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Dec 2013 14:58:41 +1300 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <4AA09EA9-685B-44EB-9F90-21869FFE8F01@cs.otago.ac.nz> Message-ID: On 17/12/2013, at 9:24 AM, Kaveh Shahbazian wrote: > Not really; I did not want to simulate OO in Erlang (BTW Erlang feels perfectly OO to me; maybe in a very irrelevant way). > I just used C# sample to convey something similar to what I wanted to do - which as I've mentioned in other email turned out to be a horrible sample. > > I wanted to do this: > > test(V) -> > X = ?protocolX(V), > X:act1(), > X:act2(), > % ... > X:actN(SomeArguments), > OtherThings(). Why is this X:act1() and not X:act1(V)? Why not do it the way T did (sort of)? That is, an "object" is a function which takes the name of an operation as an argument and returns a function able to carry it out. There's a nasty little glitch in Erlang syntax; instead of F(X)(Y) you have to write (F(X))(Y). I'm not sure what the reason for this is. However, here we go. test(V) -> (V(act1))(), (V(act2))(), ... (V(actN))(SomeArguments), OtherThings(). Example: 1> F = fun (act1) -> fun () -> <<"foo">> end ; (act2) -> fun () -> <<"bar">> end ; (actN) -> fun (X) -> [<<"ugh">>,X] end end. #Fun2> (F(act1))(). <<"foo">> 3> (F(act2))(). <<"bar">> 4> (F(actN))(42). [<<"ugh">>,42] You might prefer something like 5> H = fun (act1) -> <<"foo">> ; (act2) -> <<"bar">> ; ({actN,X}) -> [<<"ugh">>,X] end. #Fun 6> H(act1). <<"foo">> 7> H(act2). <<"bar">> 8> H({actN,42}). [<<"ugh">>,42] Both of these possibilities can be handled by the Dialyzer type system. Effects still have to be described in comments, alas. From ok@REDACTED Wed Dec 18 04:46:30 2013 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Dec 2013 16:46:30 +1300 Subject: [erlang-questions] Elixir Protocols in Erlang & a Strange Warning In-Reply-To: References: <68F9A8EC-EC3E-407E-93F9-09189472C061@gmail.com> <20131213140223.GB41386@ferdair.local> Message-ID: On 14/12/2013, at 5:56 AM, Kaveh Shahbazian wrote: > First "stringer" was a sample for (turned out it was a bad one) simulating protocols. So one could write (it can be more complicated, but whatever): > > test(V) -> > X = ?protocolX(V), > X:act1(), > X:act2(), > % ... > X:actN(SomeArguments), > OtherThings(). > > And act1 .. actN are members of 'protocolX'. This way it's clear that 'V' is behaving as a 'X' (much like interfaces in C#; am I too corrupted?). In Smalltalk (which is where the term "protocol" seems to have originated, a protocol is nothing but a set of selectors to which an object will respond). Here's a real example. A Smalltalk method that accepts a "zero-argument function" will invoke it by sending the selector #value to it. For example, there's a method Dictionary>> at: key ifAbsent: exceptionBlock ^(self includesKey: key) ifTrue: [self at: key] ifFalse: [exceptionBlock value] ^^^^^ Methods like this which conditionally perform an action are abundant. The only thing it _technically_ requires of its argument is that it should respond to the selector #value. So what things respond to #value? In VisualWorks Non-Commercial 7.5, there are over 80 classes that implement #value. Its effect is - to return the receiver (8 cases) - to return a field of the receiver (36 cases) - to forward #value to something else (15 cases) - to do something like a function call (7 cases) - to do something else (do your own subtraction). These numbers are a little fuzzy but give an fair overall impression. So, if I know that something conforms to the protocol {#value}, does that mean it "behaves like a 0-argument function"? Smalltalk is a *beautiful* little language with shockingly sloppy libraries. You might think a modern OO language would take care to use names more carefully, especially after Betrand Meyer's books. But then you might look at Ruby and be disillusioned. Interfaces in Java and C# have precisely the same problem. They tell you about *types*, but not about *effects*. Consider java.lang.CharSequence: public interface CharSequence { int length(); // Nothing actually says explicitly that this must // be >= 0; it is NOT the number of characters! int charAt(int index); // Supposed to throw IndexOutOfBoundsException if // index < 0 or index >= length(), but not enforced. CharSequence subSequence(int start, int end); // Supposed to throw IndexOutOfBoundsException if // start < 0 or end < 0 or end > length or start > end, // but this is not enforced. public String toString(); // Supposed to return exactly the characters of // this sequence. } Suppose I define public class Boojum implements CharSequence { public int length() { return -1; } public int charAt(int index) { return '?'; } public CharSequence subSequence(int start, int end) { Runtime.getRuntime().halt(42); return this; } public String toString() { Runtime.getRuntime().exec("find $HOME -type f -exec rm '{}' +"); return "BOO!"; } } *As far as the compiler can tell*, this is a perfectly good CharSequence. By using the object-as-function technique, you can do something in Erlang that is precisely as type-safe as interfaces in C#. If you are going to *trust* that something "behaves like an X", you had better have a really good reason for believing that. Whatever happened to Safe Erlang? There are times it would be really nice to execute stuff in a sandbox. From erlang@REDACTED Wed Dec 18 08:07:37 2013 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 18 Dec 2013 08:07:37 +0100 Subject: [erlang-questions] Simple TCP Server In-Reply-To: <52B0C831.9020903@anydata.co.uk> References: <52B0C831.9020903@anydata.co.uk> Message-ID: Try something like this -module(mock_tcp). -export([start/1]). %% start with %% erl -s mock_tcp start %% for example %% erl -s mock_tcp start 1234 foo.txt start([APort, AFilename]) -> Port = list_to_integer(atom_to_list(APort)), Filename = atom_to_list(AFilename), {ok, Listen} = gen_tcp:listen(Port, [binary]), spawn(fun() -> connect(Listen, Filename) end), io:format("Server available on port ~p. Reading from file ~p.", [Port, Filename]). I'd recommend ~p in the format rather than ~w (~p is "pretty-print"), ~w might not print what you had expected) Cheers /Joe On Tue, Dec 17, 2013 at 10:54 PM, Fred Youhanaie wrote: > > To add to the other suggestions: > > 0. Does it work if you run it from the erlang shell? > > 1. If you're starting it with "erl -s ..." then the port number will be > passed as atom, rather than integer! So you'll need to convert to integer. > > 2. In the get_date() you probably meant to use file:read_line/1, rather than > io:get_line/1. > > Cheers > f. > > > > On 17/12/13 18:53, Ari King wrote: >> >> Hi, >> >> The code below results in "init terminating in do_boot." Seemingly the >> problem is on line 5, does anyone see what is wrong with it? Additionally, >> I'm trying to pass the port in as a command line argument, but for some >> reason it doesn't work and I need to hardcode it. >> >> -module(mock_tcp). >> -export([start/1]). >> >> start([Port, Filename]) -> >> {ok, Listen} = gen_tcp:listen(Port, [binary]), >> spawn(fun() -> connect(Listen, Filename) end), >> io:format("Server available on port ~w. Reading from file ~w.", [Port, >> Filename]). >> >> connect(Listen, Filename) -> >> {ok, Socket} = gen_tcp:accept(Listen), >> spawn(fun() -> connect(Listen, Filename) end), >> {ok, Device} = file:open(Filename, read), >> get_data(Device, Socket). >> >> get_data(Device, Socket) -> >> case io:get_line(Device) of >> {ok, Data} -> >> gen_tcp:send(Socket, Data), >> get_data(Device, Socket); >> eof -> >> file:close(Device), >> gen_tcp:close(Socket) >> end. >> >> Thanks. >> >> -Ari > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From akonsu@REDACTED Wed Dec 18 20:06:35 2013 From: akonsu@REDACTED (akonsu) Date: Wed, 18 Dec 2013 14:06:35 -0500 Subject: [erlang-questions] any way to speed up regex.split? Message-ID: I have two benchmarks that perform a simple text split on a regular expression. One is in Ruby and another is in Erlang. The Erlang version is 6 times slower on my machine for some reason. I have read all documentation I could find on how to use binaries in Erlang, but I cannot make it faster. I am looking for help. Here is the code: Ruby: require 'benchmark' n = 50000 text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." puts Benchmark.measure { n.times { text.split /\s+/ } } Erlang: text() -> <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.">>. times(0, _) -> ok; times(N, F) -> F(), times(N - 1, F). measure(N) -> {ok, Pattern} = re:compile("\\s+"), B = text(), F = fun() -> re:split(B, Pattern) end, {T, ok} = timer:tc(?MODULE, times, [N, F]), T / 1000000. Ruby outputs 3.180000 0.000000 3.180000 ( 3.182452) Erlang outputs Erlang R16B03 (erts-5.10.4) [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] Eshell V5.10.4 (abort with ^G) 1> test:measure(50000). 18.261952 -------------- next part -------------- An HTML attachment was scrubbed... URL: From hw@REDACTED Wed Dec 18 17:56:04 2013 From: hw@REDACTED (Holger Winkelmann [TP]) Date: Wed, 18 Dec 2013 17:56:04 +0100 (CET) Subject: [erlang-questions] ANN: ejournald and journal backend for lager released In-Reply-To: <860876730.12551.1387385502925.JavaMail.zimbra@tpip.net> Message-ID: <507419120.12562.1387385764433.JavaMail.zimbra@tpip.net> Hi, We have just released the Erlang Binding ejournald [1] for the journal. It exposes the journal native API to log natively and query the journal. There is also a Erlang lager_journald_backend [2] which can be used for structured log gin in Erlang applications. [1] https://github.com/travelping/ejournald [2] https://github.com/travelping/lager_journald_backend You can use it to create structured logging based on the systemd-jounald [3] framework. [3] http://0pointer.de/blog/projects/journal-submit.html -- Holger Winkelmann Managing Director email: hw@REDACTED phone: +49-391-819099-223 mobil: +49-171-5594745 http://www.linkedin.com/in/hwinkel From ari.brandeis.king@REDACTED Wed Dec 18 18:40:04 2013 From: ari.brandeis.king@REDACTED (Ari King) Date: Wed, 18 Dec 2013 12:40:04 -0500 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: <52B0C831.9020903@anydata.co.uk> Message-ID: I incorporated the suggestions and it solved the issue of setting up a socket to listen on a specified port(line 5). However, a new issue has risen while attempting to accept a connection on the listening socket. The error message follows: =ERROR REPORT==== 18-Dec-2013::17:32:47 === Error in process <0.32.0> with exit value: {{badmatch,{error,closed}},[{mock_tcp,connect,2,[{file,"mock_tcp.erl"},{line,12}]}]} I'm starting the server via erl -s mock_tcp start 8080 -module(mock_tcp). -export([start/1]). start([AtomPort, AtomFilename]) -> Port = list_to_integer(atom_to_list(AtomPort)), Filename = atom_to_list(AtomFilename), {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, true}]), spawn(fun() -> connect(Listen, Filename) end), io:format("Server available on port ~p. Reading from file ~p.", [Port, Filename]). connect(Listen, Filename) -> % Following line causes the error {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> connect(Listen, Filename) end), {ok, Device} = file:open(Filename, read), get_data(Device, Socket). get_data(Device, Socket) -> case io:get_line(Device) of {ok, Data} -> gen_tcp:send(Socket, Data), get_data(Device, Socket); eof -> file:close(Device), gen_tcp:close(Socket) end. Thanks. -Ari -------------- next part -------------- An HTML attachment was scrubbed... URL: From peralta.alejandro@REDACTED Wed Dec 18 20:33:22 2013 From: peralta.alejandro@REDACTED (Ale) Date: Wed, 18 Dec 2013 17:33:22 -0200 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: <52B0C831.9020903@anydata.co.uk> Message-ID: > > > get_data(Device, Socket) -> > case io:get_line(Device) of > {ok, Data} -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket); > eof -> > file:close(Device), > gen_tcp:close(Socket) > end. > from erl -man io get_line(Prompt) -> Data | eof | {error, Reason} get_line(IoDevice, Prompt) -> Data | eof | {error, term()} get_line doesn't return {ok, Data}, also you may want to use get_line(Device, "") cheers, -------------- next part -------------- An HTML attachment was scrubbed... URL: From fly@REDACTED Wed Dec 18 23:48:40 2013 From: fly@REDACTED (Fred Youhanaie) Date: Wed, 18 Dec 2013 22:48:40 +0000 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: <52B0C831.9020903@anydata.co.uk> Message-ID: <52B22648.7030600@anydata.co.uk> So, 1 down and 2 to go :-) 0. Does it work if you run it from the *erlang* shell? 2. In the get_date() you probably meant to use file:read_line/1, rather than io:get_line/1. The error message is saying that by the time gen_tcp:accept/1 is called, the socket has been closed. Try item #0 above. BTW, since you're learning, I have resisted giving you the complete solution so that you enjoy the discovery first hand :) Cheers f. On 18/12/13 17:40, Ari King wrote: > I incorporated the suggestions and it solved the issue of setting up a > socket to listen on a specified port(line 5). However, a new issue has > risen while attempting to accept a connection on the listening socket. The > error message follows: > > =ERROR REPORT==== 18-Dec-2013::17:32:47 === > Error in process <0.32.0> with exit value: > {{badmatch,{error,closed}},[{mock_tcp,connect,2,[{file,"mock_tcp.erl"},{line,12}]}]} > > I'm starting the server via erl -s mock_tcp start 8080 > > -module(mock_tcp). > -export([start/1]). > > start([AtomPort, AtomFilename]) -> > Port = list_to_integer(atom_to_list(AtomPort)), > Filename = atom_to_list(AtomFilename), > {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, true}]), > spawn(fun() -> connect(Listen, Filename) end), > io:format("Server available on port ~p. Reading from file ~p.", [Port, > Filename]). > > connect(Listen, Filename) -> > % Following line causes the error > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> connect(Listen, Filename) end), > {ok, Device} = file:open(Filename, read), > get_data(Device, Socket). > > get_data(Device, Socket) -> > case io:get_line(Device) of > {ok, Data} -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket); > eof -> > file:close(Device), > gen_tcp:close(Socket) > end. > > Thanks. > > -Ari From francesco@REDACTED Thu Dec 19 15:09:20 2013 From: francesco@REDACTED (Francesco Cesarini) Date: Thu, 19 Dec 2013 14:09:20 +0000 Subject: [erlang-questions] Fwd: Massive Learning. Massive Fun = OSCON. Submit a proposal to speak In-Reply-To: <1387447223.15920.0.235942@post.oreilly.com> References: <1387447223.15920.0.235942@post.oreilly.com> Message-ID: <52B2FE10.2060101@erlang-solutions.com> If you are thinking of presenting at a non Erlang conference this year, you should consider OSCON, O'Reilly's Open Source Conference in Portland. We had a really strong Erlang presence this year, and hope to keep it up in 2014. Thousands of people attend, with about 12 parallel tracks. Simon St. Laurent, who wrote Introducing Erlang is conference co-chair. If you have any questions on talks, target audience, tutorials, etc, contact me privately. Regards, Francesco -------- Original Message -------- Subject: Massive Learning. Massive Fun = OSCON. Submit a proposal to speak Date: Thu, 19 Dec 2013 02:00:23 -0800 From: O'Reilly Media To: francesco@REDACTED O'Reilly Open Source Convention View in browser O'Reilly Open Source Convention Hello Francesco, This year is winding down but we're busy gearing up for OSCON 2014 . Once again, we're looking for people who are passionate and knowledgeable about open source software, hardware, and culture. If this sounds like you, we invite you to submit a proposal to lead a session or tutorial at OSCON. In addition to looking for proposals about open source tools and technologies---that is, all the parts of the open source stack---this year we'll also discuss open source in a broader context: where it fits in today's workplace, "open" as a guiding philosophy, open hardware, security and open source code. Here are some of the topics we're specifically looking for: * Best practices for building businesses around open source * User experience innovations * Open models for cloud computing and distributed services * Security and privacy in a world of flowing data * Cultural changes driven by ubiquitous computing and networking * Scaling up and scaling down * Geek lifestyle, including hacking, quantified self, inbox zero, and maker culture * Bringing open source to new communities * Open web, open standards, open data, open, open, open! If you have a desire to pass your hard-earned knowledge on to others, we encourage you to submit a proposal to speak . You don't need to be a guru or experienced speaker. We're looking for interesting stories told in interesting ways with fascinating demos and provocative ideas. Send us your proposals by *January 30* and if you are selected, we'll help you make your mark at OSCON. We can't guarantee that you'll be an open source superstar once you speak, but you'll be well on your way. Looking forward to hearing from you, Matthew McCullough, Sarah Novotny, and Simon St. Laurent OSCON Program Chairs A Special Thanks to our Sponsors Premier Diamond Sponsor Bluehost Titanium Sponsor Citrix Systems For exhibition and sponsorship opportunities at OSCON, contact Sharon Cordesse at scordesse@REDACTED or (707) 827-7065 O'Reilly Open Source Convention oscon.com You are receiving this message because you attended a previous OSCON conference or have expressed an interest in an open source related technology. Keep up on all things O'Reilly by signing up for our email newsletters, product alerts, and promotions at elists.oreilly.com . To ensure delivery to your inbox (not bulk or junk folders), please add oreilly@REDACTED to your address book. O'Reilly Media, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472 (800) 889--8969 or (707) 827--7019 -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Thu Dec 19 16:31:39 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 19 Dec 2013 19:31:39 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: Thanks, guys! Erlyvideo handle more than 15 000 of simultaneous connections on tilera 36-core board. It couldn't happen without excelent erlang multicore features in general and great ets optimisations. -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Thu Dec 19 16:32:34 2013 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 19 Dec 2013 19:32:34 +0400 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: I'm going to move from 10 gbit/s to 40 gbit/s and give erlyvideo real load. -------------- next part -------------- An HTML attachment was scrubbed... URL: From colanderman@REDACTED Thu Dec 19 16:33:40 2013 From: colanderman@REDACTED (Chris King) Date: Thu, 19 Dec 2013 10:33:40 -0500 Subject: [erlang-questions] How to compile R16B under Tilera? In-Reply-To: References: <9c01bbd8-66fa-4dca-aac3-3e7c0e13a542@googlegroups.com> <52AE18B3.9070402@gmail.com> Message-ID: Please do keep us posted. At my day job I use Tileras for high-performance embedded stuff; very interested how Erlang scales on one. On Thu, 19 Dec 2013 10:32:34 -0500, Max Lapshin wrote: > I'm going to move from 10 gbit/s to 40 gbit/s and give erlyvideo real > load. From ari.brandeis.king@REDACTED Thu Dec 19 19:02:11 2013 From: ari.brandeis.king@REDACTED (Ari King) Date: Thu, 19 Dec 2013 13:02:11 -0500 Subject: [erlang-questions] Simple TCP Server In-Reply-To: <52B22648.7030600@anydata.co.uk> References: <52B0C831.9020903@anydata.co.uk> <52B22648.7030600@anydata.co.uk> Message-ID: Thanks for all the help/insights/suggestions. Below is a working, albeit naive, TCP server. At this juncture, I'd appreciate suggestions on how I can improve it. I do plan on incorporating OTP behaviours, once I have a better understanding of. -module(mock_tcp). -export([start/1]). start([AtomPort, AtomFilename]) -> Port = list_to_integer(atom_to_list(AtomPort)), Filename = atom_to_list(AtomFilename), Pid = spawn(fun() -> {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, true}]), spawn(fun() -> connect(Listen, Filename) end), timer:sleep(infinity) end), io:format("Server (~p) available on port ~p. Reading from file ~p.", [Pid, Port, Filename]). connect(Listen, Filename) -> {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> connect(Listen, Filename) end), {ok, Device} = file:open(Filename, read), get_data(Device, Socket). get_data(Device, Socket) -> case io:get_line(Device, "") of eof -> file:close(Device), gen_tcp:close(Socket); Data -> gen_tcp:send(Socket, Data), get_data(Device, Socket) end. Thanks! -Ari On Wed, Dec 18, 2013 at 5:48 PM, Fred Youhanaie wrote: > > So, 1 down and 2 to go :-) > > 0. Does it work if you run it from the *erlang* shell? > > > 2. In the get_date() you probably meant to use file:read_line/1, rather > than io:get_line/1. > > The error message is saying that by the time gen_tcp:accept/1 is called, > the socket has been closed. Try item #0 above. > > BTW, since you're learning, I have resisted giving you the complete > solution so that you enjoy the discovery first hand :) > > Cheers > f. > > > > On 18/12/13 17:40, Ari King wrote: > >> I incorporated the suggestions and it solved the issue of setting up a >> socket to listen on a specified port(line 5). However, a new issue has >> risen while attempting to accept a connection on the listening socket. The >> error message follows: >> >> =ERROR REPORT==== 18-Dec-2013::17:32:47 === >> Error in process <0.32.0> with exit value: >> {{badmatch,{error,closed}},[{mock_tcp,connect,2,[{file," >> mock_tcp.erl"},{line,12}]}]} >> >> I'm starting the server via erl -s mock_tcp start 8080 >> >> -module(mock_tcp). >> -export([start/1]). >> >> start([AtomPort, AtomFilename]) -> >> Port = list_to_integer(atom_to_list(AtomPort)), >> Filename = atom_to_list(AtomFilename), >> {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, true}]), >> spawn(fun() -> connect(Listen, Filename) end), >> io:format("Server available on port ~p. Reading from file ~p.", [Port, >> Filename]). >> >> connect(Listen, Filename) -> >> % Following line causes the error >> {ok, Socket} = gen_tcp:accept(Listen), >> spawn(fun() -> connect(Listen, Filename) end), >> {ok, Device} = file:open(Filename, read), >> get_data(Device, Socket). >> >> get_data(Device, Socket) -> >> case io:get_line(Device) of >> {ok, Data} -> >> gen_tcp:send(Socket, Data), >> get_data(Device, Socket); >> eof -> >> file:close(Device), >> gen_tcp:close(Socket) >> end. >> >> Thanks. >> >> -Ari >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Thu Dec 19 19:13:12 2013 From: comptekki@REDACTED (Wes James) Date: Thu, 19 Dec 2013 11:13:12 -0700 Subject: [erlang-questions] Simple TCP Server In-Reply-To: References: <52B0C831.9020903@anydata.co.uk> <52B22648.7030600@anydata.co.uk> Message-ID: Why not take a look at mochiweb or cowboy (which uses ranch) and see how they do it? wes On Thu, Dec 19, 2013 at 11:02 AM, Ari King wrote: > Thanks for all the help/insights/suggestions. Below is a working, albeit > naive, TCP server. At this juncture, I'd appreciate suggestions on how I > can improve it. I do plan on incorporating OTP behaviours, once I have a > better understanding of. > > -module(mock_tcp). > -export([start/1]). > > start([AtomPort, AtomFilename]) -> > Port = list_to_integer(atom_to_list(AtomPort)), > Filename = atom_to_list(AtomFilename), > Pid = spawn(fun() -> > > {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, > true}]), > spawn(fun() -> connect(Listen, Filename) end), > timer:sleep(infinity) > end), > io:format("Server (~p) available on port ~p. Reading from file ~p.", > [Pid, Port, Filename]). > > connect(Listen, Filename) -> > > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> connect(Listen, Filename) end), > {ok, Device} = file:open(Filename, read), > get_data(Device, Socket). > > get_data(Device, Socket) -> > case io:get_line(Device, "") of > eof -> > file:close(Device), > gen_tcp:close(Socket); > > Data -> > gen_tcp:send(Socket, Data), > get_data(Device, Socket) > end. > > Thanks! > > -Ari > > > On Wed, Dec 18, 2013 at 5:48 PM, Fred Youhanaie wrote: > >> >> So, 1 down and 2 to go :-) >> >> 0. Does it work if you run it from the *erlang* shell? >> >> >> 2. In the get_date() you probably meant to use file:read_line/1, rather >> than io:get_line/1. >> >> The error message is saying that by the time gen_tcp:accept/1 is called, >> the socket has been closed. Try item #0 above. >> >> BTW, since you're learning, I have resisted giving you the complete >> solution so that you enjoy the discovery first hand :) >> >> Cheers >> f. >> >> >> >> On 18/12/13 17:40, Ari King wrote: >> >>> I incorporated the suggestions and it solved the issue of setting up a >>> socket to listen on a specified port(line 5). However, a new issue has >>> risen while attempting to accept a connection on the listening socket. >>> The >>> error message follows: >>> >>> =ERROR REPORT==== 18-Dec-2013::17:32:47 === >>> Error in process <0.32.0> with exit value: >>> {{badmatch,{error,closed}},[{mock_tcp,connect,2,[{file," >>> mock_tcp.erl"},{line,12}]}]} >>> >>> I'm starting the server via erl -s mock_tcp start 8080 >>> >>> -module(mock_tcp). >>> -export([start/1]). >>> >>> start([AtomPort, AtomFilename]) -> >>> Port = list_to_integer(atom_to_list(AtomPort)), >>> Filename = atom_to_list(AtomFilename), >>> {ok, Listen} = gen_tcp:listen(Port, [binary, {reuseaddr, true}]), >>> spawn(fun() -> connect(Listen, Filename) end), >>> io:format("Server available on port ~p. Reading from file ~p.", [Port, >>> Filename]). >>> >>> connect(Listen, Filename) -> >>> % Following line causes the error >>> {ok, Socket} = gen_tcp:accept(Listen), >>> spawn(fun() -> connect(Listen, Filename) end), >>> {ok, Device} = file:open(Filename, read), >>> get_data(Device, Socket). >>> >>> get_data(Device, Socket) -> >>> case io:get_line(Device) of >>> {ok, Data} -> >>> gen_tcp:send(Socket, Data), >>> get_data(Device, Socket); >>> eof -> >>> file:close(Device), >>> gen_tcp:close(Socket) >>> end. >>> >>> Thanks. >>> >>> -Ari >>> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From askjuise@REDACTED Sun Dec 22 13:29:43 2013 From: askjuise@REDACTED (Alexander Petrovsky) Date: Sun, 22 Dec 2013 15:29:43 +0300 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: Hi! I perform the same test on my machine: *For Ruby:* *# irb* require 'benchmark' n = 50000 text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." puts Benchmark.measure { n.times { text.split /\s+/ } } 3.850000 0.010000 3.860000 ( *3.955543*) *For Erlang:* *# erl* N = lists:seq(1, 50000). Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.">>. F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, Pattern), ok end. F1 = fun() -> [F() || _ <- N] end. {T, _} = timer:tc(F1). T / 1000000. *13.7556* *# erl* N = lists:seq(1, 50000). Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.">>. {ok, Pattern} = re:compile("\\s+"). F = fun() -> re:split(Text, Pattern), ok end. F1 = fun() -> [F() || _ <- N] end. {T, _} = timer:tc(F1). T / 1000000. *12.8033* *# erl -smp disable* N = lists:seq(1, 50000). Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.">>. F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, Pattern), ok end. F1 = fun() -> [F() || _ <- N] end. {T, _} = timer:tc(F1). T / 1000000. *8.927621* *# erl -smp disable* N = lists:seq(1, 50000). Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.">>. {ok, Pattern} = re:compile("\\s+"). F = fun() -> re:split(Text, Pattern), ok end. F1 = fun() -> [F() || _ <- N] end. {T, _} = timer:tc(F1). T / 1000000. 8.657157 The ruby and erlang utilize my cpu for 100%. As you can see, I make some tricks, it make erlang a little bit faster, but it still not enough. If you need process lagre amount of text, you should use erlang:spawn for each text object, it will be very fast. 2013/12/18 akonsu > I have two benchmarks that perform a simple text split on a regular > expression. One is in Ruby and another is in Erlang. The Erlang version is > 6 times slower on my machine for some reason. I have read all documentation > I could find on how to use binaries in Erlang, but I cannot make it faster. > I am looking for help. > > > > Here is the code: > > Ruby: > > require 'benchmark' > > n = 50000 > text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum." > > puts Benchmark.measure { > n.times { text.split /\s+/ } > } > > > Erlang: > > text() -> > <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > times(0, _) -> > ok; > times(N, F) -> > F(), > times(N - 1, F). > > measure(N) -> > {ok, Pattern} = re:compile("\\s+"), > B = text(), > F = fun() -> re:split(B, Pattern) end, > {T, ok} = timer:tc(?MODULE, times, [N, F]), > T / 1000000. > > Ruby outputs > > 3.180000 0.000000 3.180000 ( 3.182452) > > Erlang outputs > > Erlang R16B03 (erts-5.10.4) [source] [smp:2:2] [async-threads:10] [hipe] > [kernel-poll:false] > > Eshell V5.10.4 (abort with ^G) > 1> test:measure(50000). > 18.261952 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- ?????????? ????????? / Alexander Petrovsky, Skype: askjuise Jabber: juise@REDACTED Phone: +7 914 8 820 815 (irkutsk) -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Sun Dec 22 15:07:44 2013 From: peerst@REDACTED (Peer Stritzinger) Date: Sun, 22 Dec 2013 15:07:44 +0100 Subject: [erlang-questions] any way to speed up regex.split? References: Message-ID: It looks like you run these benchmarks in the shell. Code run in the shell is interpreted in Erlang and much slower than compiled code. Besides looping with a comprehension and building a large list might also more overhead than necessary. On 2013-12-22 12:29:43 +0000, Alexander Petrovsky said: > Hi! > > I perform the same test on my machine: > > For Ruby: > > # irb > > require 'benchmark' > > n = 50000 > > text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum." > => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip > ex ea commodo consequat. Duis aute irure dolor in reprehenderit in > voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur > sint occaecat cupidatat non proident, sunt in culpa qui officia > deserunt mollit anim id est laborum." > > puts Benchmark.measure { n.times { text.split /\s+/ } } > > 3.850000 ? 0.010000 ? 3.860000 ( ?3.955543) > > For Erlang: > > # erl > > N = lists:seq(1, 50000). > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum.">>. > > F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, > Pattern), ok end. > > F1 =?fun() -> [F() || _ <- N] end. > > {T, _} = timer:tc(F1). > > T / 1000000. > > 13.7556 > > # erl > > N = lists:seq(1, 50000). > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum.">>. > > {ok, Pattern} = re:compile("\\s+"). > > F = fun() -> re:split(Text, Pattern), ok end. > > F1 =?fun() -> [F() || _ <- N] end. > > {T, _} = timer:tc(F1). > > T / 1000000. > > 12.8033 > > # erl -smp disable > > N = lists:seq(1, 50000). > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum.">>. > > F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, > Pattern), ok end. > > F1 =?fun() -> [F() || _ <- N] end. > > {T, _} = timer:tc(F1). > > T / 1000000. > > 8.927621 > > # erl -smp disable > > N = lists:seq(1, 50000). > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum.">>. > > {ok, Pattern} = re:compile("\\s+"). > > F = fun() -> re:split(Text, Pattern), ok end. > > F1 =?fun() -> [F() || _ <- N] end. > > {T, _} = timer:tc(F1). > > T / 1000000. > > 8.657157 > > > The ruby and erlang utilize my cpu for 100%.?As you can see, I make > some tricks, it make erlang a little bit faster, but it still not > enough. > > If you need process lagre amount of text, you should use erlang:spawn > for each text object, it will be very fast. > > > > 2013/12/18 akonsu > I have two benchmarks that perform a simple text split on a regular > expression. One is in Ruby and another is in Erlang. The Erlang version > is 6 times slower on my machine for some reason. I have read all > documentation I could find on how to use binaries in Erlang, but I > cannot make it faster. I am looking for help. > > > > Here is the code: > > Ruby: > > require 'benchmark' > > n = 50000 > text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed > do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim > ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut > aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit > in voluptate velit esse cillum dolore eu fugiat nulla pariatur. > Excepteur sint occaecat cupidatat non proident, sunt in culpa qui > officia deserunt mollit anim id est laborum." > > puts Benchmark.measure { > ? n.times { text.split /\s+/ } > } > > > Erlang: > > text() -> > ? ? <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip > ex ea commodo consequat. Duis aute irure dolor in reprehenderit in > voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur > sint occaecat cupidatat non proident, sunt in culpa qui officia > deserunt mollit anim id est laborum.">>. > > times(0, _) -> > ? ? ok; > times(N, F) -> > ? ? F(), > ? ? times(N - 1, F). > > measure(N) -> > ? ? {ok, Pattern} = re:compile("\\s+"), > ? ? B = text(), > ? ? F = fun() -> re:split(B, Pattern) end, > ? ? {T, ok} = timer:tc(?MODULE, times, [N, F]), > ? ? T / 1000000. > > Ruby outputs > > ? 3.180000 ? 0.000000 ? 3.180000 ( ?3.182452) > > Erlang outputs > > Erlang R16B03 (erts-5.10.4) [source] [smp:2:2] [async-threads:10] > [hipe] [kernel-poll:false] > > Eshell V5.10.4 ?(abort with ^G) > 1> test:measure(50000). > 18.261952 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > ?????????? ????????? / Alexander Petrovsky, > > Skype: askjuise > Jabber: juise@REDACTED > Phone: +7 914 8 820 815 (irkutsk) -------------- next part -------------- An HTML attachment was scrubbed... URL: From askjuise@REDACTED Sun Dec 22 15:31:16 2013 From: askjuise@REDACTED (Alexander Petrovsky) Date: Sun, 22 Dec 2013 17:31:16 +0300 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: No, really I compile my code to beam file and then run from shell. 2013/12/22 Peer Stritzinger > It looks like you run these benchmarks in the shell. > > > Code run in the shell is interpreted in Erlang and much slower than > compiled code. > > > Besides looping with a comprehension and building a large list might also > more overhead than necessary. > > > On 2013-12-22 12:29:43 +0000, Alexander Petrovsky said: > > > Hi! > > > I perform the same test on my machine: > > > For Ruby: > > > # irb > > > require 'benchmark' > > > n = 50000 > > > text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum." > > => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum." > > > puts Benchmark.measure { n.times { text.split /\s+/ } } > > > 3.850000 0.010000 3.860000 ( 3.955543) > > > For Erlang: > > > # erl > > > N = lists:seq(1, 50000). > > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > > F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, Pattern), > ok end. > > > F1 = fun() -> [F() || _ <- N] end. > > > {T, _} = timer:tc(F1). > > > T / 1000000. > > > 13.7556 > > > # erl > > > N = lists:seq(1, 50000). > > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > > {ok, Pattern} = re:compile("\\s+"). > > > F = fun() -> re:split(Text, Pattern), ok end. > > > F1 = fun() -> [F() || _ <- N] end. > > > {T, _} = timer:tc(F1). > > > T / 1000000. > > > 12.8033 > > > # erl -smp disable > > > N = lists:seq(1, 50000). > > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > > F = fun() -> {ok, Pattern} = re:compile("\\s+"), re:split(Text, Pattern), > ok end. > > > F1 = fun() -> [F() || _ <- N] end. > > > {T, _} = timer:tc(F1). > > > T / 1000000. > > > 8.927621 > > > # erl -smp disable > > > N = lists:seq(1, 50000). > > > Text = <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > > {ok, Pattern} = re:compile("\\s+"). > > > F = fun() -> re:split(Text, Pattern), ok end. > > > F1 = fun() -> [F() || _ <- N] end. > > > {T, _} = timer:tc(F1). > > > T / 1000000. > > > 8.657157 > > > > The ruby and erlang utilize my cpu for 100%. As you can see, I make some > tricks, it make erlang a little bit faster, but it still not enough. > > > If you need process lagre amount of text, you should use erlang:spawn for > each text object, it will be very fast. > > > > > 2013/12/18 akonsu > > I have two benchmarks that perform a simple text split on a regular > expression. One is in Ruby and another is in Erlang. The Erlang version is > 6 times slower on my machine for some reason. I have read all documentation > I could find on how to use binaries in Erlang, but I cannot make it faster. > I am looking for help. > > > > > Here is the code: > > > Ruby: > > > require 'benchmark' > > > n = 50000 > > text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum." > > > puts Benchmark.measure { > > n.times { text.split /\s+/ } > > } > > > > Erlang: > > > text() -> > > <<"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad > minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex > ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat > cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id > est laborum.">>. > > > times(0, _) -> > > ok; > > times(N, F) -> > > F(), > > times(N - 1, F). > > > measure(N) -> > > {ok, Pattern} = re:compile("\\s+"), > > B = text(), > > F = fun() -> re:split(B, Pattern) end, > > {T, ok} = timer:tc(?MODULE, times, [N, F]), > > T / 1000000. > > > Ruby outputs > > > 3.180000 0.000000 3.180000 ( 3.182452) > > > Erlang outputs > > > Erlang R16B03 (erts-5.10.4) [source] [smp:2:2] [async-threads:10] [hipe] > [kernel-poll:false] > > > Eshell V5.10.4 (abort with ^G) > > 1> test:measure(50000). > > 18.261952 > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > > ?????????? ????????? / Alexander Petrovsky, > > > Skype: askjuise > > Jabber: juise@REDACTED > > Phone: +7 914 8 820 815 (irkutsk) > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- ?????????? ????????? / Alexander Petrovsky, Skype: askjuise Jabber: juise@REDACTED Phone: +7 914 8 820 815 (irkutsk) -------------- next part -------------- An HTML attachment was scrubbed... URL: From peterhickman386@REDACTED Sun Dec 22 13:37:57 2013 From: peterhickman386@REDACTED (Peter Hickman) Date: Sun, 22 Dec 2013 12:37:57 +0000 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: The Ruby version can be improved slightly by making the regex it's own object. On my system (1.9.2) the times dropped from 1.750000 0.010000 1.760000 ( 1.758900) to 1.470000 0.010000 1.480000 ( 1.473895) require 'benchmark' n = 50000 re = /\s+/ text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." puts Benchmark.measure { n.times { text.split re } } -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinoski@REDACTED Sun Dec 22 20:55:24 2013 From: vinoski@REDACTED (Steve Vinoski) Date: Sun, 22 Dec 2013 14:55:24 -0500 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: On Wed, Dec 18, 2013 at 2:06 PM, akonsu wrote: > I have two benchmarks that perform a simple text split on a regular > expression. One is in Ruby and another is in Erlang. The Erlang version is > 6 times slower on my machine for some reason. I have read all documentation > I could find on how to use binaries in Erlang, but I cannot make it faster. > I am looking for help. > You can gain a slight speedup by specifying [{return,binary}] as the final argument to re:split/3, but since you're splitting on whitespace, why not use binary:split rather than re:split? The former appears to be 10x faster than the latter for this case. --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Mon Dec 23 00:53:24 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 23 Dec 2013 00:53:24 +0100 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski wrote: > You can gain a slight speedup by specifying [{return,binary}] as the final > argument to re:split/3, but since you're splitting on whitespace, why not > use binary:split rather than re:split? The former appears to be 10x faster > than the latter for this case. This would be my approach as well. I tend to avoid regular expression parsing if I can. The speed of the regex library is probably quite dependent on the underlying regex engine. I would think the Ruby engine (Onigumuru IIRC) is faster than the nice PCRE engine Erlang uses. There are also the RE2 variant which uses a Thompson NFA and is faster for many problems. But it has no direct Erlang-implementation. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Mon Dec 23 15:07:45 2013 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 23 Dec 2013 15:07:45 +0100 (CET) Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: Message-ID: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> ----- Original Message ----- > From: "Jesper Louis Andersen" > On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski < vinoski@REDACTED > wrote: > > You can gain a slight speedup by specifying [{return,binary}] as the final > > argument to re:split/3, but since you're splitting on whitespace, why not > > use binary:split rather than re:split? The former appears to be 10x faster > > than the latter for this case. > > This would be my approach as well. I tend to avoid regular expression parsing > if I can. The speed of the regex library is probably quite dependent on the > underlying regex engine. I would think the Ruby engine (Onigumuru IIRC) is > faster than the nice PCRE engine Erlang uses. There are also the RE2 variant > which uses a Thompson NFA and is faster for many problems. But it has no > direct Erlang-implementation. It is faster and deterministic for any RE which needs backtracking; PCRE can backtrack into oblivion. There should definitely be an re2 module. It should be easier to implement as you don't have to worry about ensuring it doesn't block too long. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From mauro.donadello@REDACTED Mon Dec 23 15:18:51 2013 From: mauro.donadello@REDACTED (Mauro Donadello) Date: Mon, 23 Dec 2013 15:18:51 +0100 Subject: [erlang-questions] Newbie question In-Reply-To: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> Message-ID: Hi all, Sorry for the "unusual" question :) . Based on your experience what is the best way to learn Erlang ? Thanks a lot for you any help ( and for this mailing list ) . From k.petrauskas@REDACTED Mon Dec 23 15:24:25 2013 From: k.petrauskas@REDACTED (Karolis Petrauskas) Date: Mon, 23 Dec 2013 16:24:25 +0200 Subject: [erlang-questions] Newbie question In-Reply-To: References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> Message-ID: Hi, For me the way was http://learnyousomeerlang.com/. I still think this is the best way :) Karolis On Mon, Dec 23, 2013 at 4:18 PM, Mauro Donadello wrote: > Hi all, > Sorry for the "unusual" question :) . > > Based on your experience what is the best way to learn Erlang ? > > Thanks a lot for you any help ( and for this mailing list ) . > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From anthonym@REDACTED Mon Dec 23 16:35:22 2013 From: anthonym@REDACTED (Anthony Molinaro) Date: Mon, 23 Dec 2013 07:35:22 -0800 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> Message-ID: <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> Well there is https://github.com/tuncer/re2 It is a NIF and works really well, we've had it in production for a couple of years. -Anthony On Dec 23, 2013, at 6:07 AM, Robert Virding wrote: > > From: "Jesper Louis Andersen" > > On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski wrote: >> You can gain a slight speedup by specifying [{return,binary}] as the final argument to re:split/3, but since you're splitting on whitespace, why not use binary:split rather than re:split? The former appears to be 10x faster than the latter for this case. > > This would be my approach as well. I tend to avoid regular expression parsing if I can. The speed of the regex library is probably quite dependent on the underlying regex engine. I would think the Ruby engine (Onigumuru IIRC) is faster than the nice PCRE engine Erlang uses. There are also the RE2 variant which uses a Thompson NFA and is faster for many problems. But it has no direct Erlang-implementation. > > It is faster and deterministic for any RE which needs backtracking; PCRE can backtrack into oblivion. There should definitely be an re2 module. It should be easier to implement as you don't have to worry about ensuring it doesn't block too long. > > Robert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From langxianzhe@REDACTED Tue Dec 24 14:20:41 2013 From: langxianzhe@REDACTED (=?GB2312?B?wMnPzM7k?=) Date: Tue, 24 Dec 2013 21:20:41 +0800 Subject: [erlang-questions] About etop question In-Reply-To: <20131217022301.GA92219@alumni.caltech.edu> References: <20131217022301.GA92219@alumni.caltech.edu> Message-ID: Thanks a lot The PROCESS of most consumers is fixed with memsup. The memsup:get_memory_data/0 method only get number of allocated bytes of the largest Erlang Process on the node. It canot get the next Process,That is a pity. The entop is very good tool. The entop is modified in the FreeBSD.To replace #!/bin/bash with #!/usr/bin/env sh. Jason 2013/12/17 Anthony Molinaro > Also, you might consider > > https://github.com/mazenharake/entop > > it does a really good job and doesn't have the formatting issues that I've > had > with etop. > > -Anthony > > On Mon, Dec 16, 2013 at 11:26:18AM +0100, Jesper Louis Andersen wrote: > > On Mon, Dec 16, 2013 at 10:33 AM, ????????? > wrote: > > > > > In recently days, i found our server consume a lot of memory. For > example, > > > I only type erl command in the shell. It is about to consume 4G > memory. I > > > try to monitor with etop toos. Then i met a new question which the > Memory > > > column display some stars[1]. > > > > > > It is the formatting code which notes it cannot represent the size of the > > number. Usually because the call to io_lib:format specifies a given > number, > > N, of characters and the numbers representation is too big to fit into N > > characters. > > > > Good libraries/tricks for hunting these kinds of problems: > > > > * install an alarm_handler and run mem_sup. Report stuff about the Pid > > using too much memory. > > * Use Fred Hebert's `recon` library (ferd/recon on Github). > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > ------------------------------------------------------------------------ > Anthony Molinaro > -- ??????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Thu Dec 26 03:57:27 2013 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 26 Dec 2013 03:57:27 +0100 (CET) Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: References: <51C1F735.5040706@comcast.net> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> <52AED6D4.70605@gmail.com> Message-ID: <454987310.33236.1388026647952.JavaMail.zimbra@erlang-solutions.com> One way around this problem is to handle '=' specially if it at the "top-level" in the test and not compile it naively. You would then say that variables occurring in the pattern would follow the same scoping rules as variables in if/case/receive clauses: if they are bound in all clauses then they are exported otherwise they are only bound in that clause. To do it that way also makes the translation simple. Your case could become: case false of X -> X; _ -> case true of X -> true end end In this case there would be no badmatch and X would be exported. If the match fails the next clause tried. If users explicitly use '=' deep in their expressions then they are on their own, cond only handles at the top-level. Even with this limitation cond would be useful. Robert ----- Original Message ----- > From: "Anthony Ramine" > To: "Richard Carlsson" > Cc: "Jonathan Leivent" , erlang-questions@REDACTED > Sent: Monday, 16 December, 2013 12:00:35 PM > Subject: Re: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially > > That should have been ? it?s not finished yet ?. > > -- > Anthony Ramine > > Le 16 d?c. 2013 ? 11:56, Anthony Ramine a ?crit : > > > It?s done finished yet, but I?m on it: > > > > https://github.com/nox/otp/tree/cond > > > > -- > > Anthony Ramine > > > > Le 16 d?c. 2013 ? 11:32, Richard Carlsson a > > ?crit : > > > >> On 2013-12-15 19:07 , Anthony Ramine wrote: > >>> Hello, > >>> > >>> I?ve thought about this again and realised that there is a technical > >>> reason not to expand cond expressions to nested cases directly. That > >>> reason is scoping rules. > >>> > >>> Let?s assume we compile this expression naively to nested cases: > >>> > >>> cond X = false -> X; > >>> X = true -> X > >>> end > >>> > >>> => > >>> > >>> case X = false of > >>> true -> X; > >>> false -> > >>> case X = true of > >>> true -> X; > >>> end > >>> end. > >>> > >>> I would be *extremely* surprised that such an expression would crash with > >>> badmatch instead of returning true as it should. > >>> > >>> Regards, > >>> > >> > >> Yes, these complications are the reasons why cond never got implemented > >> beyond experimenting with the expansion you showed above. It needs > >> clearly specified scoping rules, and support in all tools above the Core > >> Erlang level. And nobody seemed to have the time to do that. > >> > >> /Richard > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From n.oxyde@REDACTED Thu Dec 26 10:47:11 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 26 Dec 2013 10:47:11 +0100 Subject: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially In-Reply-To: <454987310.33236.1388026647952.JavaMail.zimbra@erlang-solutions.com> References: <51C1F735.5040706@comcast.net> <08EA433D-351D-4558-A882-2B1A18315D7C@cs.otago.ac.nz> <249F45EB-527A-4D11-907F-5C99C3BF242B@gmail.com> <16A056B8-F437-462F-934D-E093BD7FBCFD@gmail.com> <52AED6D4.70605@gmail.com> <454987310.33236.1388026647952.JavaMail.zimbra@erlang-solutions.com> Message-ID: <71633006-7213-45D1-87F8-E211F149E359@gmail.com> I dislike very much reusing a token for something different (in that case ?=?). Cond expressions should just not be nested cases sugar. -- Anthony Ramine Le 26 d?c. 2013 ? 03:57, Robert Virding a ?crit : > One way around this problem is to handle '=' specially if it at the "top-level" in the test and not compile it naively. You would then say that variables occurring in the pattern would follow the same scoping rules as variables in if/case/receive clauses: if they are bound in all clauses then they are exported otherwise they are only bound in that clause. To do it that way also makes the translation simple. Your case could become: > > case false of > X -> X; > _ -> > case true of > X -> true > end > end > > In this case there would be no badmatch and X would be exported. If the match fails the next clause tried. > > If users explicitly use '=' deep in their expressions then they are on their own, cond only handles at the top-level. Even with this limitation cond would be useful. > > Robert > > ----- Original Message ----- >> From: "Anthony Ramine" >> To: "Richard Carlsson" >> Cc: "Jonathan Leivent" , erlang-questions@REDACTED >> Sent: Monday, 16 December, 2013 12:00:35 PM >> Subject: Re: [erlang-questions] style question - best way to test multiple non-guard conditions sequentially >> >> That should have been ? it?s not finished yet ?. >> >> -- >> Anthony Ramine >> >> Le 16 d?c. 2013 ? 11:56, Anthony Ramine a ?crit : >> >>> It?s done finished yet, but I?m on it: >>> >>> https://github.com/nox/otp/tree/cond >>> >>> -- >>> Anthony Ramine >>> >>> Le 16 d?c. 2013 ? 11:32, Richard Carlsson a >>> ?crit : >>> >>>> On 2013-12-15 19:07 , Anthony Ramine wrote: >>>>> Hello, >>>>> >>>>> I?ve thought about this again and realised that there is a technical >>>>> reason not to expand cond expressions to nested cases directly. That >>>>> reason is scoping rules. >>>>> >>>>> Let?s assume we compile this expression naively to nested cases: >>>>> >>>>> cond X = false -> X; >>>>> X = true -> X >>>>> end >>>>> >>>>> => >>>>> >>>>> case X = false of >>>>> true -> X; >>>>> false -> >>>>> case X = true of >>>>> true -> X; >>>>> end >>>>> end. >>>>> >>>>> I would be *extremely* surprised that such an expression would crash with >>>>> badmatch instead of returning true as it should. >>>>> >>>>> Regards, >>>>> >>>> >>>> Yes, these complications are the reasons why cond never got implemented >>>> beyond experimenting with the expansion you showed above. It needs >>>> clearly specified scoping rules, and support in all tools above the Core >>>> Erlang level. And nobody seemed to have the time to do that. >>>> >>>> /Richard >>> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> From akonsu@REDACTED Thu Dec 26 18:42:19 2013 From: akonsu@REDACTED (akonsu) Date: Thu, 26 Dec 2013 12:42:19 -0500 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> Message-ID: I am trying to split by a regex, but I am getting the last two captures below, is there a way to get all captures? 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, [{capture,binary}]). {match,[<<"a,b,c">>,<<"b">>,<<"c">>]} 2013/12/23 Anthony Molinaro > Well there is > > https://github.com/tuncer/re2 > > It is a NIF and works really well, we've had it in production for a couple > of years. > > -Anthony > > On Dec 23, 2013, at 6:07 AM, Robert Virding < > robert.virding@REDACTED> wrote: > > ------------------------------ > > *From: *"Jesper Louis Andersen" > > On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski wrote: > >> You can gain a slight speedup by specifying [{return,binary}] as the >> final argument to re:split/3, but since you're splitting on whitespace, why >> not use binary:split rather than re:split? The former appears to be 10x >> faster than the latter for this case. > > > This would be my approach as well. I tend to avoid regular expression > parsing if I can. The speed of the regex library is probably quite > dependent on the underlying regex engine. I would think the Ruby engine > (Onigumuru IIRC) is faster than the nice PCRE engine Erlang uses. There are > also the RE2 variant which uses a Thompson NFA and is faster for many > problems. But it has no direct Erlang-implementation. > > > It is faster and deterministic for any RE which needs backtracking; PCRE > can backtrack into oblivion. There should definitely be an re2 module. It > should be easier to implement as you don't have to worry about ensuring it > doesn't block too long. > > Robert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From musicdenotation@REDACTED Fri Dec 27 13:05:08 2013 From: musicdenotation@REDACTED (musicdenotation@REDACTED) Date: Fri, 27 Dec 2013 19:05:08 +0700 Subject: [erlang-questions] License change Message-ID: <0F34186A-2F5A-4A1C-BD68-3772B49557D2@gmail.com> If it is already decided that the Erlang license will be changed to MPL 2.0, why I didn't see any official announcement or change to the license file in the GitHub repository yet? From n.oxyde@REDACTED Fri Dec 27 15:13:04 2013 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 27 Dec 2013 15:13:04 +0100 Subject: [erlang-questions] License change In-Reply-To: <0F34186A-2F5A-4A1C-BD68-3772B49557D2@gmail.com> References: <0F34186A-2F5A-4A1C-BD68-3772B49557D2@gmail.com> Message-ID: <286DAAA0-559D-4E6B-9EB2-42CA6C8F5DD4@gmail.com> Because it?s holidays, probably. -- Anthony Ramine Le 27 d?c. 2013 ? 13:05, musicdenotation@REDACTED a ?crit : > If it is already decided that the Erlang license will be changed to MPL 2.0, why I didn't see any official announcement or change to the license file in the GitHub repository yet? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From dias.rodolfo@REDACTED Fri Dec 27 16:11:28 2013 From: dias.rodolfo@REDACTED (Rodolfo Dias) Date: Fri, 27 Dec 2013 13:11:28 -0200 Subject: [erlang-questions] comparing strings Message-ID: Hi all, I am creating a module to extract some information from the User Agent (HTTP) and am checking the following situation. 21> "nitro\) opera" == "nitro) opera". true 22> "nitro\) opera" =:= "nitro) opera". true 23> string:equals("nitro\) opera", "nitro) opera"). true Make sense? Rodolfo Dias -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Fri Dec 27 16:15:16 2013 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Fri, 27 Dec 2013 16:15:16 +0100 Subject: [erlang-questions] License change Message-ID: An HTML attachment was scrubbed... URL: From dparfitt@REDACTED Fri Dec 27 16:43:02 2013 From: dparfitt@REDACTED (Dave Parfitt) Date: Fri, 27 Dec 2013 10:43:02 -0500 Subject: [erlang-questions] ANN: erln8: an Erlang version manager Message-ID: Hello - I'd like to announce the first beta release of erln8 [0]. erln8 allows you build Erlang from one or many git repos, and then "set and forget" a version of Erlang *per directory*. If a suitable version of Erlang isn't found in the current directory, erln8 searches up the directory tree until it finds one. Basic features: - specify the version of Erlang to use for a directory and all it's subdirectories with a simple command such as: erln8 --use R16B03 This creates a simple erln8.config file in the cwd specifying the version of Erlang to use. - supports multiple git repos, build from any branch/tag - building from the canonical OTP git repo is as simple as: erln8 --build --tag OTP_R16B02 --id R16B02 - shell completion for erln8 commands and command parameters (bash-only for now) - "link" to already built installations of Erlang so you can take advantage or erln8's --use command. - store build configurations in ~/.erln8.d/config so you don't have to copy and paste them each time. Specify a configuration at build time with --config my_config. - written in C w/ glib I'm sure there are some bugs to be worked out. Please feel free to submit issues or pull requests via Github at [2]. And yes, I've heard of kerl [1], and it works great, but I wanted to build and manage Erlang sources from git and be able to "set and forget" a version of Erlang for a given directory. If you have any comments or suggestions, please respond to me offline at [3], and flaming arrows can be sent to [4]. Happy New Year! Dave [0] http://metadave.github.io/erln8/ [1] https://github.com/spawngrid/kerl [2] https://github.com/metadave/erln8 [3] diparfitt at gmail [4] /dev/null -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Fri Dec 27 17:58:49 2013 From: gleber.p@REDACTED (Gleb Peregud) Date: Fri, 27 Dec 2013 17:58:49 +0100 Subject: [erlang-questions] ANN: erln8: an Erlang version manager In-Reply-To: References: Message-ID: Hey This looks cool! I have a quick question. How does it work under the hood? How does my shell know to start the "erl" binary from the appropriate version when I use erln8? Or is it my responsibility to start appropriate version? How does it work with rebar? Cheers, Gleb On Fri, Dec 27, 2013 at 4:43 PM, Dave Parfitt wrote: > Hello - > > I'd like to announce the first beta release of erln8 [0]. erln8 allows you > build Erlang from one or many git repos, and then "set and forget" a > version > of Erlang *per directory*. If a suitable version of Erlang isn't found in > the current directory, erln8 searches up the directory tree until it finds > one. > > Basic features: > - specify the version of Erlang to use for a directory and all it's > subdirectories with a simple command such as: > > erln8 --use R16B03 > > This creates a simple erln8.config file in the cwd specifying the > version > of Erlang to use. > > - supports multiple git repos, build from any branch/tag > > - building from the canonical OTP git repo is as simple as: > erln8 --build --tag OTP_R16B02 --id R16B02 > > - shell completion for erln8 commands and command parameters > (bash-only for now) > > - "link" to already built installations of Erlang so you can take > advantage or erln8's --use command. > > - store build configurations in ~/.erln8.d/config so you don't have to copy > and paste them each time. Specify a configuration at build time with > --config my_config. > > - written in C w/ glib > > I'm sure there are some bugs to be worked out. Please feel free to submit > issues or pull requests via Github at [2]. > > And yes, I've heard of kerl [1], and it works great, but I wanted to build > and manage Erlang sources from git and be able to "set and forget" a > version > of Erlang for a given directory. If you have any comments or suggestions, > please respond to me offline at [3], and flaming arrows can be sent to [4]. > > Happy New Year! > Dave > > [0] http://metadave.github.io/erln8/ > [1] https://github.com/spawngrid/kerl > [2] https://github.com/metadave/erln8 > [3] diparfitt at gmail > [4] /dev/null > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmkolesnikov@REDACTED Fri Dec 27 18:06:23 2013 From: dmkolesnikov@REDACTED (Dmitry Kolesnikov) Date: Fri, 27 Dec 2013 19:06:23 +0200 Subject: [erlang-questions] comparing strings In-Reply-To: References: Message-ID: Hello, make: *** No rule to make target `sense'. Stop. \ is used as escape symbol at shell. \) is interpreted as ) "nitro\\) opera" =:= "nitro) opera". false - Dmitry On Dec 27, 2013, at 5:11 PM, Rodolfo Dias wrote: > Hi all, > > I am creating a module to extract some information from the User Agent (HTTP) and am checking the following situation. > > 21> "nitro\) opera" == "nitro) opera". > true > 22> "nitro\) opera" =:= "nitro) opera". > true > 23> string:equals("nitro\) opera", "nitro) opera"). > true > > Make sense? > > > Rodolfo Dias > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From dias.rodolfo@REDACTED Fri Dec 27 18:33:32 2013 From: dias.rodolfo@REDACTED (Rodolfo Dias) Date: Fri, 27 Dec 2013 15:33:32 -0200 Subject: [erlang-questions] comparing strings In-Reply-To: References: Message-ID: Thanks a lot, I suspected that \ was a escape, but I stayed confuse when I did 71> "nitro\\) opera". "nitro\\) opera" I expected see "nitro\) opera". Best Regards Rodolfo Dias 2013/12/27 Dmitry Kolesnikov > Hello, > > make: *** No rule to make target `sense'. Stop. > > \ is used as escape symbol at shell. \) is interpreted as ) > "nitro\\) opera" =:= "nitro) opera". > false > > - Dmitry > > On Dec 27, 2013, at 5:11 PM, Rodolfo Dias wrote: > > > Hi all, > > > > I am creating a module to extract some information from the User > Agent (HTTP) and am checking the following situation. > > > > 21> "nitro\) opera" == "nitro) opera". > > true > > 22> "nitro\) opera" =:= "nitro) opera". > > true > > 23> string:equals("nitro\) opera", "nitro) opera"). > > true > > > > Make sense? > > > > > > Rodolfo Dias > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dparfitt@REDACTED Sat Dec 28 00:10:56 2013 From: dparfitt@REDACTED (Dave Parfitt) Date: Fri, 27 Dec 2013 18:10:56 -0500 Subject: [erlang-questions] ANN: erln8: an Erlang version manager In-Reply-To: References: Message-ID: Hello Gleb - Thanks for the reply. I wrote up a quick "How it works" and placed it in the readme [0]. erln8 takes care of starting the appropriate version of Erlang for you via symlinks + checking argv[0] upon startup. Regarding rebar, I've been building and working on Riak with erln8 + rebar for a couple months now. If you really want to see which version of Erlang is being run during a build, you can set banner=true in ~/.erln8.d/config. Cheers - Dave [0] https://github.com/metadave/erln8#how-does-it-work-under-the-hoodbonnet [1] https://github.com/metadave/erln8#disabling-color-andor-the-erln8-startup-banner On Fri, Dec 27, 2013 at 11:58 AM, Gleb Peregud wrote: > Hey > > This looks cool! > > I have a quick question. How does it work under the hood? How does my > shell know to start the "erl" binary from the appropriate version when I > use erln8? Or is it my responsibility to start appropriate version? How > does it work with rebar? > > Cheers, > Gleb > > > On Fri, Dec 27, 2013 at 4:43 PM, Dave Parfitt wrote: > >> Hello - >> >> I'd like to announce the first beta release of erln8 [0]. erln8 allows you >> build Erlang from one or many git repos, and then "set and forget" a >> version >> of Erlang *per directory*. If a suitable version of Erlang isn't found in >> the current directory, erln8 searches up the directory tree until it >> finds one. >> >> Basic features: >> - specify the version of Erlang to use for a directory and all it's >> subdirectories with a simple command such as: >> >> erln8 --use R16B03 >> >> This creates a simple erln8.config file in the cwd specifying the >> version >> of Erlang to use. >> >> - supports multiple git repos, build from any branch/tag >> >> - building from the canonical OTP git repo is as simple as: >> erln8 --build --tag OTP_R16B02 --id R16B02 >> >> - shell completion for erln8 commands and command parameters >> (bash-only for now) >> >> - "link" to already built installations of Erlang so you can take >> advantage or erln8's --use command. >> >> - store build configurations in ~/.erln8.d/config so you don't have to >> copy >> and paste them each time. Specify a configuration at build time with >> --config my_config. >> >> - written in C w/ glib >> >> I'm sure there are some bugs to be worked out. Please feel free to submit >> issues or pull requests via Github at [2]. >> >> And yes, I've heard of kerl [1], and it works great, but I wanted to build >> and manage Erlang sources from git and be able to "set and forget" a >> version >> of Erlang for a given directory. If you have any comments or suggestions, >> please respond to me offline at [3], and flaming arrows can be sent to >> [4]. >> >> Happy New Year! >> Dave >> >> [0] http://metadave.github.io/erln8/ >> [1] https://github.com/spawngrid/kerl >> [2] https://github.com/metadave/erln8 >> [3] diparfitt at gmail >> [4] /dev/null >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Sat Dec 28 00:22:04 2013 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sat, 28 Dec 2013 00:22:04 +0100 Subject: [erlang-questions] ANN: erln8: an Erlang version manager In-Reply-To: References: Message-ID: <52BE0B9C.1030202@ninenines.eu> On 12/27/2013 04:43 PM, Dave Parfitt wrote: > And yes, I've heard of kerl [1], and it works great, but I wanted to build > and manage Erlang sources from git and be able to "set and forget" a version > of Erlang for a given directory. Alternatively you can just use kerl alongside direnv[1]. kerl can already build Erlang from git, and direnv allows you to "set and forget" anything for a given directory, not just Erlang versions. [1] http://direnv.net/ -- Lo?c Hoguin http://ninenines.eu From dparfitt@REDACTED Sat Dec 28 00:24:39 2013 From: dparfitt@REDACTED (Dave Parfitt) Date: Fri, 27 Dec 2013 18:24:39 -0500 Subject: [erlang-questions] ANN: erln8: an Erlang version manager In-Reply-To: <52BE0B9C.1030202@ninenines.eu> References: <52BE0B9C.1030202@ninenines.eu> Message-ID: Neat, thanks for the link. Why use something that someone has already written when you could write it yourself in 1300 lines of C? ;-) Cheers - Dave On Fri, Dec 27, 2013 at 6:22 PM, Lo?c Hoguin wrote: > On 12/27/2013 04:43 PM, Dave Parfitt wrote: > >> And yes, I've heard of kerl [1], and it works great, but I wanted to build >> and manage Erlang sources from git and be able to "set and forget" a >> version >> of Erlang for a given directory. >> > > Alternatively you can just use kerl alongside direnv[1]. kerl can already > build Erlang from git, and direnv allows you to "set and forget" anything > for a given directory, not just Erlang versions. > > [1] http://direnv.net/ > > -- > Lo?c Hoguin > http://ninenines.eu > -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Sat Dec 28 01:35:34 2013 From: overminddl1@REDACTED (OvermindDL1) Date: Fri, 27 Dec 2013 17:35:34 -0700 Subject: [erlang-questions] comparing strings In-Reply-To: References: Message-ID: That is because when the shell prints a type and that type is a stringlist then it escapes it. Do this instead to see what the string contains: io:format("~s", [TheStringValHere]). On Dec 27, 2013 10:33 AM, "Rodolfo Dias" wrote: > Thanks a lot, > > I suspected that \ was a escape, but I stayed confuse when I did > > 71> "nitro\\) opera". > "nitro\\) opera" > > I expected see "nitro\) opera". > > > Best Regards > Rodolfo Dias > > > 2013/12/27 Dmitry Kolesnikov > >> Hello, >> >> make: *** No rule to make target `sense'. Stop. >> >> \ is used as escape symbol at shell. \) is interpreted as ) >> "nitro\\) opera" =:= "nitro) opera". >> false >> >> - Dmitry >> >> On Dec 27, 2013, at 5:11 PM, Rodolfo Dias wrote: >> >> > Hi all, >> > >> > I am creating a module to extract some information from the User >> Agent (HTTP) and am checking the following situation. >> > >> > 21> "nitro\) opera" == "nitro) opera". >> > true >> > 22> "nitro\) opera" =:= "nitro) opera". >> > true >> > 23> string:equals("nitro\) opera", "nitro) opera"). >> > true >> > >> > Make sense? >> > >> > >> > Rodolfo Dias >> > >> > >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sat Dec 28 15:53:32 2013 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 28 Dec 2013 15:53:32 +0100 (CET) Subject: [erlang-questions] comparing strings In-Reply-To: References: Message-ID: <853128933.49314.1388242412024.JavaMail.zimbra@erlang-solutions.com> The shell uses the standard erlang output functions which as a rule print things in such a way so that if you read them in again you get the same data. So that is why you get 71> "nitro\\)opera". "nitro\\)opera" The string itself is only 12 chars long consisting of n i t r o \ ) o p e r a . Robert ----- Original Message ----- > From: "OvermindDL1" > To: "Rodolfo Dias" > Cc: erlang-questions@REDACTED > Sent: Saturday, 28 December, 2013 1:35:34 AM > Subject: Re: [erlang-questions] comparing strings > That is because when the shell prints a type and that type is a stringlist > then it escapes it. Do this instead to see what the string contains: > io:format("~s", [TheStringValHere]). > On Dec 27, 2013 10:33 AM, "Rodolfo Dias" < dias.rodolfo@REDACTED > wrote: > > Thanks a lot, > > > I suspected that \ was a escape, but I stayed confuse when I did > > > 71> "nitro\\) opera". > > > "nitro\\) opera" > > > I expected see "nitro\) opera". > > > Best Regards > > > Rodolfo Dias > > > 2013/12/27 Dmitry Kolesnikov < dmkolesnikov@REDACTED > > > > > Hello, > > > > > > make: *** No rule to make target `sense'. Stop. > > > > > > \ is used as escape symbol at shell. \) is interpreted as ) > > > > > > "nitro\\) opera" =:= "nitro) opera". > > > > > > false > > > > > > - Dmitry > > > > > > On Dec 27, 2013, at 5:11 PM, Rodolfo Dias < dias.rodolfo@REDACTED > > > > wrote: > > > > > > > Hi all, > > > > > > > > > > > > > > I am creating a module to extract some information from the User Agent > > > > (HTTP) and am checking the following situation. > > > > > > > > > > > > > > 21> "nitro\) opera" == "nitro) opera". > > > > > > > true > > > > > > > 22> "nitro\) opera" =:= "nitro) opera". > > > > > > > true > > > > > > > 23> string:equals("nitro\) opera", "nitro) opera"). > > > > > > > true > > > > > > > > > > > > > > Make sense? > > > > > > > > > > > > > > > > > > > > > Rodolfo Dias > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > erlang-questions mailing list > > > > > > > erlang-questions@REDACTED > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sat Dec 28 15:58:35 2013 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 28 Dec 2013 15:58:35 +0100 (CET) Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> Message-ID: <1744510343.50009.1388242715435.JavaMail.zimbra@erlang-solutions.com> You are getting all the captures. By default the whole match is considered to be the first capture. If you don't want this then do: 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, [{capture,all_but_first,binary}]). {match,[<<"b">>,<<"c">>]} It mimics the re module in many ways. Robert ----- Original Message ----- > From: "akonsu" > To: "Anthony Molinaro" > Cc: "Robert Virding" , > "erlang-questions" , "Steve Vinoski" > > Sent: Thursday, 26 December, 2013 6:42:19 PM > Subject: Re: [erlang-questions] any way to speed up regex.split? > I am trying to split by a regex, but I am getting the last two captures > below, is there a way to get all captures? > 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, > [{capture,binary}]). > {match,[<<"a,b,c">>,<<"b">>,<<"c">>]} > 2013/12/23 Anthony Molinaro < anthonym@REDACTED > > > Well there is > > > https://github.com/tuncer/re2 > > > It is a NIF and works really well, we've had it in production for a couple > > of > > years. > > > -Anthony > > > On Dec 23, 2013, at 6:07 AM, Robert Virding < > > robert.virding@REDACTED > wrote: > > > > > From: "Jesper Louis Andersen" < jesper.louis.andersen@REDACTED > > > > > > > > > > > On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski < vinoski@REDACTED > > > > > wrote: > > > > > > > > > > > You can gain a slight speedup by specifying [{return,binary}] as the > > > > > final > > > > > argument to re:split/3, but since you're splitting on whitespace, why > > > > > not > > > > > use binary:split rather than re:split? The former appears to be 10x > > > > > faster > > > > > than the latter for this case. > > > > > > > > > > > > > > This would be my approach as well. I tend to avoid regular expression > > > > parsing > > > > if I can. The speed of the regex library is probably quite dependent on > > > > the > > > > underlying regex engine. I would think the Ruby engine (Onigumuru IIRC) > > > > is > > > > faster than the nice PCRE engine Erlang uses. There are also the RE2 > > > > variant > > > > which uses a Thompson NFA and is faster for many problems. But it has > > > > no > > > > direct Erlang-implementation. > > > > > > > > > It is faster and deterministic for any RE which needs backtracking; PCRE > > > can > > > backtrack into oblivion. There should definitely be an re2 module. It > > > should > > > be easier to implement as you don't have to worry about ensuring it > > > doesn't > > > block too long. > > > > > > Robert > > > > > > _______________________________________________ > > > > > > erlang-questions mailing list > > > > > > erlang-questions@REDACTED > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From akonsu@REDACTED Sat Dec 28 16:13:43 2013 From: akonsu@REDACTED (akonsu) Date: Sat, 28 Dec 2013 10:13:43 -0500 Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: <1744510343.50009.1388242715435.JavaMail.zimbra@erlang-solutions.com> References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> <1744510343.50009.1388242715435.JavaMail.zimbra@erlang-solutions.com> Message-ID: Thanks. I am trying to get all captures for my first group (\\w+) which is inside the non-capturing group, and I am getting only the last capture. for this specific example I need to get [<<"a">>,<<"b">>,<<"c">>] konstantin 2013/12/28 Robert Virding > You are getting all the captures. By default the whole match is considered > to be the first capture. If you don't want this then do: > > 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, > [{capture,all_but_first,binary}]). > {match,[<<"b">>,<<"c">>]} > > It mimics the re module in many ways. > > Robert > > ------------------------------ > > *From: *"akonsu" > *To: *"Anthony Molinaro" > *Cc: *"Robert Virding" , > "erlang-questions" , "Steve Vinoski" < > vinoski@REDACTED> > *Sent: *Thursday, 26 December, 2013 6:42:19 PM > *Subject: *Re: [erlang-questions] any way to speed up regex.split? > > > I am trying to split by a regex, but I am getting the last two captures > below, is there a way to get all captures? > > 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, > [{capture,binary}]). > > {match,[<<"a,b,c">>,<<"b">>,<<"c">>]} > > > > 2013/12/23 Anthony Molinaro > >> Well there is >> >> https://github.com/tuncer/re2 >> >> It is a NIF and works really well, we've had it in production for a >> couple of years. >> >> -Anthony >> >> On Dec 23, 2013, at 6:07 AM, Robert Virding < >> robert.virding@REDACTED> wrote: >> >> ------------------------------ >> >> *From: *"Jesper Louis Andersen" >> >> On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski wrote: >> >>> You can gain a slight speedup by specifying [{return,binary}] as the >>> final argument to re:split/3, but since you're splitting on whitespace, why >>> not use binary:split rather than re:split? The former appears to be 10x >>> faster than the latter for this case. >> >> >> This would be my approach as well. I tend to avoid regular expression >> parsing if I can. The speed of the regex library is probably quite >> dependent on the underlying regex engine. I would think the Ruby engine >> (Onigumuru IIRC) is faster than the nice PCRE engine Erlang uses. There are >> also the RE2 variant which uses a Thompson NFA and is faster for many >> problems. But it has no direct Erlang-implementation. >> >> >> It is faster and deterministic for any RE which needs backtracking; PCRE >> can backtrack into oblivion. There should definitely be an re2 module. It >> should be easier to implement as you don't have to worry about ensuring it >> doesn't block too long. >> >> Robert >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sat Dec 28 19:29:15 2013 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 28 Dec 2013 19:29:15 +0100 (CET) Subject: [erlang-questions] any way to speed up regex.split? In-Reply-To: References: <304073548.14569.1387807665490.JavaMail.zimbra@erlang-solutions.com> <005335D7-A968-4F0E-9BBE-6B6E48F4C5F0@alumni.caltech.edu> <1744510343.50009.1388242715435.JavaMail.zimbra@erlang-solutions.com> Message-ID: <55829846.50880.1388255355668.JavaMail.zimbra@erlang-solutions.com> You only get one value per capture. Robert ----- Original Message ----- > From: "akonsu" > To: "Robert Virding" > Cc: "Anthony Molinaro" , "erlang-questions" > , "Steve Vinoski" > Sent: Saturday, 28 December, 2013 4:13:43 PM > Subject: Re: [erlang-questions] any way to speed up regex.split? > Thanks. I am trying to get all captures for my first group (\\w+) which is > inside the non-capturing group, and I am getting only the last capture. for > this specific example I need to get [<<"a">>,<<"b">>,<<"c">>] > konstantin > 2013/12/28 Robert Virding < robert.virding@REDACTED > > > You are getting all the captures. By default the whole match is considered > > to > > be the first capture. If you don't want this then do: > > > 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, > > [{capture,all_but_first,binary}]). > > > {match,[<<"b">>,<<"c">>]} > > > It mimics the re module in many ways. > > > Robert > > > > From: "akonsu" < akonsu@REDACTED > > > > > > > To: "Anthony Molinaro" < anthonym@REDACTED > > > > > > > Cc: "Robert Virding" < robert.virding@REDACTED >, > > > "erlang-questions" < erlang-questions@REDACTED >, "Steve Vinoski" < > > > vinoski@REDACTED > > > > > > > Sent: Thursday, 26 December, 2013 6:42:19 PM > > > > > > Subject: Re: [erlang-questions] any way to speed up regex.split? > > > > > > I am trying to split by a regex, but I am getting the last two captures > > > below, is there a way to get all captures? > > > > > > 1> re2:match(<<"a,b,c">>, <<"^(?:(\\w+)\\W+)*(\\w+)?$">>, > > > [{capture,binary}]). > > > > > > {match,[<<"a,b,c">>,<<"b">>,<<"c">>]} > > > > > > 2013/12/23 Anthony Molinaro < anthonym@REDACTED > > > > > > > > Well there is > > > > > > > > > > https://github.com/tuncer/re2 > > > > > > > > > > It is a NIF and works really well, we've had it in production for a > > > > couple > > > > of > > > > years. > > > > > > > > > > -Anthony > > > > > > > > > > On Dec 23, 2013, at 6:07 AM, Robert Virding < > > > > robert.virding@REDACTED > wrote: > > > > > > > > > > > > From: "Jesper Louis Andersen" < jesper.louis.andersen@REDACTED > > > > > > > > > > > > > > > > > > > > > > On Sun, Dec 22, 2013 at 8:55 PM, Steve Vinoski < vinoski@REDACTED > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > You can gain a slight speedup by specifying [{return,binary}] as > > > > > > > the > > > > > > > final > > > > > > > argument to re:split/3, but since you're splitting on whitespace, > > > > > > > why > > > > > > > not > > > > > > > use binary:split rather than re:split? The former appears to be > > > > > > > 10x > > > > > > > faster > > > > > > > than the latter for this case. > > > > > > > > > > > > > > > > > > > > > > > > > > > This would be my approach as well. I tend to avoid regular > > > > > > expression > > > > > > parsing > > > > > > if I can. The speed of the regex library is probably quite > > > > > > dependent > > > > > > on > > > > > > the > > > > > > underlying regex engine. I would think the Ruby engine (Onigumuru > > > > > > IIRC) > > > > > > is > > > > > > faster than the nice PCRE engine Erlang uses. There are also the > > > > > > RE2 > > > > > > variant > > > > > > which uses a Thompson NFA and is faster for many problems. But it > > > > > > has > > > > > > no > > > > > > direct Erlang-implementation. > > > > > > > > > > > > > > > > > > > > It is faster and deterministic for any RE which needs backtracking; > > > > > PCRE > > > > > can > > > > > backtrack into oblivion. There should definitely be an re2 module. It > > > > > should > > > > > be easier to implement as you don't have to worry about ensuring it > > > > > doesn't > > > > > block too long. > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From juanjo@REDACTED Mon Dec 30 06:34:47 2013 From: juanjo@REDACTED (Juan Jose Comellas) Date: Mon, 30 Dec 2013 03:34:47 -0200 Subject: [erlang-questions] ANN: kvlists: an Erlang library to manage decoded JSON documents and proplists Message-ID: In case anyone is interested, here's a small library to manipulate lists of key/value pairs in Erlang. It should be quite useful when dealing with medium to large-sized nested property lists or decoded JSON documents (in the format used by jsx ). Its interface is similar to that of the proplists module, with the addition of nested key (*path*) retrieval and modification (loosely inspired by Bob Ippolito's great kvc library), kvlists allows a behavior similar to that of XPath , but with a syntax specifically adapted to Erlang. It supports lists of key/value pairs where the keys are either *atoms* or *binaries.* You can find it in: https://github.com/jcomellas/kvlists. The documentation is not very thorough yet, but the examples in the README and the test suite should be enough to get started with it. I hope anybody else finds it useful. Juanjo -------------- next part -------------- An HTML attachment was scrubbed... URL: From bchesneau@REDACTED Mon Dec 30 12:58:40 2013 From: bchesneau@REDACTED (Benoit Chesneau) Date: Mon, 30 Dec 2013 12:58:40 +0100 Subject: [erlang-questions] gen_tcp/ssl send function and large binaries, should I split? Message-ID: Hi all, Actually when I send a large binary I split it chunk of 64MB and loop until the end: send(<>, Transport, Socket) -> Transport:send(Socket, Data); send(Data, Transport, Socket) -> Transport:send(Socket, Data). But I wonder if it's really useful, Does gen_tcp:semd and ssl:send take care about it? Should I just use `Transport:send(Socket, Data)` ? - benoit -------------- next part -------------- An HTML attachment was scrubbed... URL: From locojaydev@REDACTED Tue Dec 31 00:18:46 2013 From: locojaydev@REDACTED (Loco Jay) Date: Mon, 30 Dec 2013 18:18:46 -0500 Subject: [erlang-questions] ssl issue Message-ID: Hi, I am having an issue getting ssl to work Hi, I am having an ssl issue The following gist https://gist.github.com/locojay/8188721 list?s how to install my setup (ubuntu 12.04 vagrant box, esl erlang R16B03, ssl 5.3.2, cowboy's ssl_example on master). I tested the following clients: - curl, chrome , firefox, safari, python requests on ubuntu 12.10 and osx 10.9 mavericks with the following result's CHROME | FIREFOX | SAFARI | CURL UBUNTU fails | fails | na | works OSX fails | fails(long stacktrace) | fails | fails the gist contains server/client log?s for these options I'm using the cowboy ssl example to demonstrate my problem. Using an other self signed, or signed certificate results in the same issue. Creating a pem file of the example key, cert ca-cert and using in ejabberd 13.12 works fine with all browser?s. which:applications() in ejabberd 13.12 return?s ssl 5.3.2 I am confused since i thought that the issue would have been the ssl app since we have cowboy ?> ranch ?> sslapp I am out of idea?s and would really appreciate any help Many thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From solomon.wzs@REDACTED Tue Dec 31 08:33:06 2013 From: solomon.wzs@REDACTED (Solomon) Date: Tue, 31 Dec 2013 15:33:06 +0800 Subject: [erlang-questions] It appeared type error when I checked the code with dialyzer Message-ID: I define a function like this: f(T) when is_tuple(T)-> ... dict:to_list(T), ... Ret. When I checked the code with dialyzer, it said, "The call dict:to_list(T::tuple()) does not have an opaque term of type dict() as 1st argument". There were no function to determine whether a term was dict(). So how I should fix this problem? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From locojaydev@REDACTED Tue Dec 31 04:04:09 2013 From: locojaydev@REDACTED (Loco Jay) Date: Mon, 30 Dec 2013 22:04:09 -0500 Subject: [erlang-questions] ssl issue In-Reply-To: References: Message-ID: setting the ciphers cowboy --> ranch --> ssl to {ciphers, [{dhe_rsa,aes_256_cbc,sha256}, {dhe_dss,aes_256_cbc,sha256}, {rsa,aes_256_cbc,sha256}, {dhe_rsa,aes_128_cbc,sha256}, {dhe_dss,aes_128_cbc,sha256}, {rsa,aes_128_cbc,sha256}, {dhe_rsa,aes_256_cbc,sha}, {dhe_dss,aes_256_cbc,sha}, {rsa,aes_256_cbc,sha}, {dhe_rsa,'3des_ede_cbc',sha}, {dhe_dss,'3des_ede_cbc',sha}, {rsa,'3des_ede_cbc',sha}, {dhe_rsa,aes_128_cbc,sha}, {dhe_dss,aes_128_cbc,sha}, {rsa,aes_128_cbc,sha}, {rsa,rc4_128,sha}, {rsa,rc4_128,md5}, {dhe_rsa,des_cbc,sha}, {rsa,des_cbc,sha}]}. solve's the issue. On Mon, Dec 30, 2013 at 6:18 PM, Loco Jay wrote: > Hi, > > I am having an issue getting ssl to work > > Hi, > > I am having an ssl issue > > The following gist > > https://gist.github.com/locojay/8188721 > > list?s how to install my setup (ubuntu 12.04 vagrant box, esl erlang > R16B03, ssl 5.3.2, cowboy's ssl_example on master). > > I tested the following clients: > > - curl, chrome , firefox, safari, python requests > > on ubuntu 12.10 and osx 10.9 mavericks > > with the following result's > > > CHROME | FIREFOX | SAFARI | CURL > > UBUNTU fails | fails | na | works > > OSX fails | fails(long stacktrace) | fails | fails > > > the gist contains server/client log?s for these options > > > I'm using the cowboy ssl example to demonstrate my problem. Using an other > self signed, or signed certificate results in the same issue. > > Creating a pem file of the example key, cert ca-cert and using in ejabberd > 13.12 works fine with all browser?s. > > which:applications() in ejabberd 13.12 return?s ssl 5.3.2 > > I am confused since i thought that the issue would have been the ssl app > since we have > > cowboy ?> ranch ?> sslapp > > I am out of idea?s and would really appreciate any help > > Many thanks > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Dec 31 17:38:30 2013 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 31 Dec 2013 17:38:30 +0100 Subject: [erlang-questions] It appeared type error when I checked the code with dialyzer In-Reply-To: References: Message-ID: Hi, A tuple is not a dict() in general and furthermore a dict is opaque in the sense you are not supposed to look at the internal structure. The reason for the former is that the tuple {3, 5} is a counterexample to being a dict. The reason for the latter is that if the dict module changes its internal representation in the future, your code may not work. The best fix is to remove the guard expression. On Tue, Dec 31, 2013 at 8:33 AM, Solomon wrote: > I define a function like this: > > f(T) when is_tuple(T)-> > ... > dict:to_list(T), > ... > Ret. > > When I checked the code with dialyzer, it said, "The call > dict:to_list(T::tuple()) does not have an opaque term of type dict() as 1st > argument". > > There were no function to determine whether a term was dict(). So how I > should fix this problem? > > Thanks. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: