|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 - 3 - 4 - 5 - 6 - 7 | Next > |
|
|
Re: erlang sucksOn Wed, 12 Mar 2008, Anders G S Svensson wrote:
[...] > You might not think that when the code is at a customer site and > applying patches isn't something the customer (or the layers of > management between you and the customer) will let you do. Thankfully I haven't been in this situation. But I stand by my claim - if it's possible, it's often faster to insert io:format calls into the call than to try to make sense of hundreds of lines of trace generated by two simple function calls. Actually it would be nice if we'd have a tool that could parse such trace and the source code and could show me that which function was called... Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksOn Tue, 11 Mar 2008, Sean Hinde wrote:
[...] > The more normal Erlang way to write the equivalent of the C version would be > simply: > > some_function(X,Y,Z) -> > case handle_some_function(X,Y,Z) of > ok -> ok; > error1 -> handle_error1(); > error2 -> handle_error2() > end. > > I'd argue that it is even more readable than the C version. And not an 'if' > in sight :-) But you have to write nonsense like: ok -> ok; Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: Line numbers for logging/errors.Thank you. That looks good. I'll experiment with it.
Eider Silva de Oliveira wrote: > I use this: > > -define(d(Format, Args), > io:format("~s" ++ Format, > [string:left(lists:flatten(io_lib:format("~p~p(~p):", [self(),?MODULE, > ?LINE])), 35, $ ) | Args])). > > > On 12/03/2008, at 12:08, Richard Kelsall wrote: > >> Nohl Attila Rajmund wrote: >>> Yes, erlang has excellent trace facilities, it shows me that the 'rfmm' >>> function was called - unfortunately it doesn't show that which of the 10 >>> rfmm functions was called. >> >> Breaking a small subject off the main thread. I haven't written much >> Erlang yet so maybe I'm just missing something, but I get the impression >> Erlang won't tell me the line number when something goes wrong. I feel >> it would be useful to know this and very in keeping with the Erlang >> approach of making bugs nice and visible. So my vote while we're all >> requesting changes to Erlang :) is for more line number visibility. >> >> On a related subject I've played around with the LINE macro to tag >> my own logging/error messages with line numbers and the best I could >> produce was something like this : >> >> -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, >> ??Var, Var)). % LINE macro always gives '1' if I put it here. >> >> log_message(Module, Line, Message, VarName, Var) -> >> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, >> VarName, Var]). >> >> and then in my code I can do things like >> >> ?log(?LINE, "Unexpected post", Other), >> >> This works fine, but it would be nice to just write >> >> ?log("Unexpected post", Other), >> >> and get the line number somehow. Can this be done? >> _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksPerhaps I am misunderstanding the comma or == operator, but for what values
of X will the following guard evaluate to true? when X == '123', X == '456' Please advise. Thank-you. DBM -----Original Message----- From: erlang-questions-bounces@... [mailto:erlang-questions-bounces@...] On Behalf Of Sean Hinde Sent: Tuesday, March 11, 2008 15:06 To: Mats Cronqvist Cc: Erlang mailing list Subject: Re: [erlang-questions] erlang sucks On 11 Mar 2008, at 19:26, Mats Cronqvist wrote: > Sean Hinde wrote: >> >> On 11 Mar 2008, at 12:47, Mats Cronqvist wrote: >> >>> >>> * 'if' is completely worthless, and should ideally be obsoleted. >> >> No, no no! I like 'if' It allows some neat constructs that are >> horrible with case. > > i was afraid no one was going to bite... still, I'd like an example > or 2. I'm thinking of things like: case X of _ when X == abc; X == xyz -> do_abc_or_xyz(); _ when X == '123', X == '456' -> do_123456() '123' -> do_123_only(); fred -> do_fred() end vs if X == abc; X == xyz -> do_abc_or_xyz(); X == '123', X == '456' -> do_123456(); X == '123' -> do_123_only(); X == fred -> do_fred() end I don't much like the _ when business. 'if' is also useful when you want to branch on a bunch of unrelated boolean variables in various combinations: case {X,Y,Z} of {true, false, _} -> do_a(); {false, _, true} -> do_b(); _ -> do_c() end vs if X and not Y -> do_a; not X and Z -> do_b; true -> do_c end. I find the second more clearly states the intent. You also don't have to remember the positions in the tuple to parse the code (though you do need to know that 'not' is stickier* than 'and') Sean * IANACS _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: Line numbers for logging/errors.I've found it in the mnesia example code! You'd find a lot of hints in
the original source code. On 12/03/2008, at 14:44, Richard Kelsall wrote: > Thank you. That looks good. I'll experiment with it. > > Eider Silva de Oliveira wrote: >> I use this: >> -define(d(Format, Args), >> io:format("~s" ++ Format, >> [string:left(lists:flatten(io_lib:format("~p~p(~p):", [self(),? >> MODULE, ?LINE])), 35, $ ) | Args])). >> On 12/03/2008, at 12:08, Richard Kelsall wrote: >>> Nohl Attila Rajmund wrote: >>>> Yes, erlang has excellent trace facilities, it shows me that the >>>> 'rfmm' >>>> function was called - unfortunately it doesn't show that which of >>>> the 10 >>>> rfmm functions was called. >>> >>> Breaking a small subject off the main thread. I haven't written much >>> Erlang yet so maybe I'm just missing something, but I get the >>> impression >>> Erlang won't tell me the line number when something goes wrong. I >>> feel >>> it would be useful to know this and very in keeping with the Erlang >>> approach of making bugs nice and visible. So my vote while we're all >>> requesting changes to Erlang :) is for more line number visibility. >>> >>> On a related subject I've played around with the LINE macro to tag >>> my own logging/error messages with line numbers and the best I could >>> produce was something like this : >>> >>> -define(log(Line, Message, Var), log_message(?MODULE, Line, >>> Message, >>> ??Var, Var)). % LINE macro always gives '1' if I put it >>> here. >>> >>> log_message(Module, Line, Message, VarName, Var) -> >>> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, >>> VarName, Var]). >>> >>> and then in my code I can do things like >>> >>> ?log(?LINE, "Unexpected post", Other), >>> >>> This works fine, but it would be nice to just write >>> >>> ?log("Unexpected post", Other), >>> >>> and get the line number somehow. Can this be done? >>> > _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksOn 12 Mar 2008, at 17:29, attila.rajmund.nohl@... wrote: > On Tue, 11 Mar 2008, Sean Hinde wrote: > [...] >> The more normal Erlang way to write the equivalent of the C version >> would be >> simply: >> >> some_function(X,Y,Z) -> >> case handle_some_function(X,Y,Z) of >> ok -> ok; >> error1 -> handle_error1(); >> error2 -> handle_error2() >> end. >> >> I'd argue that it is even more readable than the C version. And not >> an 'if' >> in sight :-) > > But you have to write nonsense like: > ok -> ok; You seem to be mostly complaining about the fact that case .. end and if .. end do not have an implicit pass through when no clauses match. Well, Erlang is not C. Idiomatic Elang does not mean writing everything in single function with a few hundred lines of ifs and gotos. I've read many C programs in that style, and also seen Erlang code attempting to follow the same style. It makes for ugly and hard to debug Erlang code. I've no idea if it is good C coding style. In Erlang you have the choice to throw a runtime exception if no clause matches, or to provide an explicit wildcard case. The Erlang "crash early" philosophy means that in most cases wildcard is the wrong solution. Sean > > Bye,NAR > -- > "Beware of bugs in the above code; I have only proved it correct, not > tried it." > _______________________________________________ > erlang-questions mailing list > erlang-questions@... > http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksThis line will indeed never match :-) Well spotted
Sean On 12 Mar 2008, at 17:48, David Mercer wrote: > Perhaps I am misunderstanding the comma or == operator, but for what > values > of X will the following guard evaluate to true? > > when X == '123', X == '456' > > Please advise. Thank-you. > > DBM > > -----Original Message----- > From: erlang-questions-bounces@... > [mailto:erlang-questions-bounces@...] On Behalf Of Sean Hinde > Sent: Tuesday, March 11, 2008 15:06 > To: Mats Cronqvist > Cc: Erlang mailing list > Subject: Re: [erlang-questions] erlang sucks > > > On 11 Mar 2008, at 19:26, Mats Cronqvist wrote: > >> Sean Hinde wrote: >>> >>> On 11 Mar 2008, at 12:47, Mats Cronqvist wrote: >>> >>>> >>>> * 'if' is completely worthless, and should ideally be obsoleted. >>> >>> No, no no! I like 'if' It allows some neat constructs that are >>> horrible with case. >> >> i was afraid no one was going to bite... still, I'd like an example >> or 2. > > I'm thinking of things like: > > case X of > _ when X == abc; X == xyz -> > do_abc_or_xyz(); > _ when X == '123', X == '456' -> > do_123456() > '123' -> > do_123_only(); > fred -> > do_fred() > end > > vs > > if > X == abc; > X == xyz -> > do_abc_or_xyz(); > X == '123', > X == '456' -> > do_123456(); > X == '123' -> > do_123_only(); > X == fred -> > do_fred() > end > > I don't much like the _ when business. > > 'if' is also useful when you want to branch on a bunch of unrelated > boolean variables in various combinations: > > case {X,Y,Z} of > {true, false, _} -> > do_a(); > {false, _, true} -> > do_b(); > _ -> > do_c() > end > > vs > > if > X and not Y -> > do_a; > not X and Z -> > do_b; > true -> > do_c > end. > > I find the second more clearly states the intent. You also don't have > to remember the positions in the tuple to parse the code (though you > do need to know that 'not' is stickier* than 'and') > > Sean > > * IANACS > > _______________________________________________ > erlang-questions mailing list > erlang-questions@... > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@... > http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: Line numbers for logging/errors.May be I missed some, but it works for me in R11B-5
-module(temp). -export([test/0]). -define(log(Message, Var), log_message(?MODULE, ?LINE, Message, ??Var, Var)). log_message(Module, Line, Message, VarName, Var) -> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, VarName, Var]). test() -> X = {a,b}, ?log("Unexpected post", X). % here is line 20 %end $ erl -smp Erlang (BEAM) emulator version 5.5.5 [source] [smp:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.5 (abort with ^G) 1> c(temp). {ok,temp} 2> temp:test(). log: {temp, 20} Unexpected post X = {a,b} ok 3> On Wed, Mar 12, 2008 at 4:08 PM, Richard Kelsall <r.kelsall@...> wrote: Nohl Attila Rajmund wrote: -- --Hynek (Pichi) Vychodil _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksConcerning 'if', may I remind readers that the 'cond' proposal (not
mine) has been around for quite a while, and except for using 'cond' rather than 'if' as the keyword, completely answers the claimed need for an if with user-defined functions callable in the guards. What happens if those user defined functions exchange messages with the rest of the world is not something I want to think about... _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksGreetings,
Out of interest: Does anybody know of _anything_ that has been removed, ever? bengt On Wed, 2008-03-12 at 16:53 +0100, Mats Cronqvist wrote: > Hynek Vychodil wrote: > > > > > > On Wed, Mar 12, 2008 at 3:02 PM, Mats Cronqvist > > <mats.cronqvist@... <mailto:mats.cronqvist@...>> wrote: > > > > or are you saying there is a need for several 'and'? in that case i > > disagree. > > > > ... > > I think there is no way to change it, because if you remove 'andalso' > > and use 'and' in programmers manner lazy behaviour, you will break > > some legacy code a vice versa. This change is impossible. You can be > > not agree with it. You can argue against it, but it is all what you > > can do with it. > if you go back a few posts, you'll see that i try to make it very > clear that nothing will be removed (at least not for the next few years). > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@... > http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksattila.rajmund.nohl@... wrote:
> On Wed, 12 Mar 2008, Anders G S Svensson wrote: > [...] > >> You might not think that when the code is at a customer site and >> applying patches isn't something the customer (or the layers of >> management between you and the customer) will let you do. >> > > Thankfully I haven't been in this situation. But I stand by my claim - > if it's possible, it's often faster to insert io:format calls into the > call than to try to make sense of hundreds of lines of trace generated by > two simple function calls. Actually it would be nice if we'd have a tool > that could parse such trace and the source code and could show me that > which function was called... > for example, the "hundreds of lines of trace" you're talking about would presumably be the arguments to functions calls? from the erlang:trace/3 man page; "arity - Used in conjunction with the call trace flag. {M, F, Arity} will be specified instead of {M, F, Args} in call trace messages." the need for a better tool than dbg to interface with the trace BIF is a different issue. mats [mats_cronqvist.vcf] begin:vcard fn:Mats Cronqvist n:Cronqvist;Mats org:Kreditor Europe AB email;internet:mats.cronqvist@... title:Senior Developer x-mozilla-html:FALSE version:2.1 end:vcard _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksIf you count libraries: after rewriting a GUI from iv to tcl I gave up
when tcl was removed. I guess gs has been around long enough to consider it, but then again there are still GUI alternatives floating around, and I am afraid they will become better than gs and gs will be replaced. *Erik. > Out of interest: > Does anybody know of _anything_ that has been removed, ever? > > > bengt > > On Wed, 2008-03-12 at 16:53 +0100, Mats Cronqvist wrote: > > Hynek Vychodil wrote: > > > > > > > > > On Wed, Mar 12, 2008 at 3:02 PM, Mats Cronqvist > > > <mats.cronqvist@... > <mailto:mats.cronqvist@...>> wrote: > > > > > > or are you saying there is a need for several > 'and'? in that case i > > > disagree. > > > > > > ... > > > I think there is no way to change it, because if you > remove 'andalso' > > > and use 'and' in programmers manner lazy behaviour, you > will break > > > some legacy code a vice versa. This change is impossible. > You can be > > > not agree with it. You can argue against it, but it is > all what you > > > can do with it. > > if you go back a few posts, you'll see that i try to make it very > > clear that nothing will be removed (at least not for the > next few years). > > > > mats > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@... > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@... > http://www.erlang.org/mailman/listinfo/erlang-questions > erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksBengt Kleberg wrote:
> Greetings, > > Out of interest: > Does anybody know of _anything_ that has been removed, ever? > not me. and i think it will be impossible to ever remove anything unless a mechanism to obsolete things is put in place (or there is a fork of OTP.) mats [mats_cronqvist.vcf] begin:vcard fn:Mats Cronqvist n:Cronqvist;Mats org:Kreditor Europe AB email;internet:mats.cronqvist@... title:Senior Developer x-mozilla-html:FALSE version:2.1 end:vcard _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksBengt Kleberg <bengt.kleberg@...> writes:
> Greetings, > > Out of interest: > Does anybody know of _anything_ that has been removed, ever? A number of deprecated BIFs and functions were removed in R12B. Minor features (such as zombie processes) have been removed in past. /Bjorn -- Björn Gustavsson, Erlang/OTP, Ericsson AB _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksOn Tue, Mar 11, 2008 at 01:47:27PM +0100, Mats Cronqvist wrote:
> katz starts out like this; "...it's time to whine about my favorite > language I use quite extensively." seems pretty clear that the problem > is not that he is a troll, but rather that the erlang community (or at > least certain members of it) is immature. CouchDB is a major erlang > application, and katz should not have to take any crap from people that > has never written a significant piece of erlang (I'm not talking about > you, ulf!) > > more so because most of his complaints are essentially valid. > * the syntax does suck. for beginners, because it looks weird (i.e. not > like ALGOL), thus being a major obstacle to adoption. for pros, because > the silly separators, and the needless verbosity (lambdas, using > 'receive' instead of '?', etc) > * 'if' is completely worthless, and should ideally be obsoleted. > * strings as lists of integers is often annoying. > * the X1=x1(X),X2=x2(X1),,, pattern is tedious and error prone. > * records are "limited and verbose" (for a reason, but still) > * some of the libs/docs are of poor quality. > I mostly agree with all those complaints about Erlang. Syntax is not usually a problem for programmers that know and use more than one language at a time, but it is still an obstacle for newcomers. My (little) experience about teaching Erlang at university gave me the impression that students are attracted by many of the *cool* features of the language (concurrency, message passing, reliability, gen_*) but are mostly disappointed by syntax and libraries. Maybe it is due to the fact that most of them know C/C++/Java/Python. Maybe Erlang syntax is not so intuitive and easy as one could expect from a modern and powerful languages. Maybe because the standard library is not so rich and not so consistent as expected from a mature language. I think that the blogpost written by kats summerizes the most relevant issues that should be solved in order to make Erlang a main-stream language. Given that this community and people at Ericsson really want this to happen......:-) HND Enzo -- [ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ] [ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ] [ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ] [ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ] _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksOn 13 Mar 2008, at 08:53, KatolaZ wrote: > On Tue, Mar 11, 2008 at 01:47:27PM +0100, Mats Cronqvist wrote: > > > Maybe it is due to the fact that most of them know C/C++/Java/Python. > Maybe Erlang syntax is not so intuitive and easy as one could expect > from a modern and powerful languages. > Maybe because the standard library is not so rich and not so > consistent as expected from a mature language. As someone who learned Erlang before C or Java my observation was quite the opposite. I found the Erlang syntax to be extremely simple and elegant, and that it was very easy to express the meaning of the code. I find C/Java Syntax ugly and unnatural. Erlang syntax didn't spring from nowhere. I bet Prolog programmers find it quite comfortable :-) Sean _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucks> As someone who learned Erlang before C or Java my observation was
> quite the opposite. I found the Erlang syntax to be extremely simple > and elegant, and that it was very easy to express the meaning of the > code. I find C/Java Syntax ugly and unnatural. Also, as having been a student and among students I know that students are way too stupid to have worthy opinions. _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksOn 13 Mar 2008, at 10:10, Christian S wrote: >> As someone who learned Erlang before C or Java my observation was >> quite the opposite. I found the Erlang syntax to be extremely simple >> and elegant, and that it was very easy to express the meaning of the >> code. I find C/Java Syntax ugly and unnatural. > > Also, as having been a student and among students I know that students > are way too stupid to have worthy opinions. I mostly avoided EE class so couldn't comment. Maybe I should have blogged about how C syntax should change to be more like Erlang. Darn! Blogs weren't invented then ;-) Sean _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
Re: erlang sucksSean Hinde wrote:
> On 13 Mar 2008, at 08:53, KatolaZ wrote: > >> On Tue, Mar 11, 2008 at 01:47:27PM +0100, Mats Cronqvist wrote: >> >> >> Maybe it is due to the fact that most of them know C/C++/Java/Python. >> Maybe Erlang syntax is not so intuitive and easy as one could expect >> from a modern and powerful languages. >> Maybe because the standard library is not so rich and not so >> consistent as expected from a mature language. > > As someone who learned Erlang before C or Java my observation was > quite the opposite. I found the Erlang syntax to be extremely simple > and elegant, and that it was very easy to express the meaning of the > code. I find C/Java Syntax ugly and unnatural. > > Erlang syntax didn't spring from nowhere. I bet Prolog programmers > find it quite comfortable :-) Speaking as one who knew Prolog before learning Erlang, I found the syntax faimilar, but that wasn't a help. Once you started write code you soon realized that this just fooled you into believing Erlang did all those nice thing Prolog does, but it doesn't. (Not surprising really, since Erlang is functional, not logic based.) Also, there are some subtle differences in the syntax, and those are usually around the things people have been complaining about here, such as the different separators. In Prolog much of these things don't happen since the order of definitions and statements are pretty unimportant in Prolog (you should get the same results no matter how you define things, just the order of the results will differ. Prolog will give all solutions, and not just the first that matches.) (Prolog is much nicer... ;-) ) Johnny _______________________________________________ erlang-questions mailing list erlang-questions@... http://www.erlang.org/mailman/listinfo/erlang-questions |
|
|
|
| < Prev | 1 - 2 - 3 - 4 - 5 - 6 - 7 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |