On Saturday, 9 June 2018 at 22:28:22 UTC, Ali Çehreli wrote:
There is some explanation at the following page, of how the
lambda syntax is related to the full syntax:
http://ddili.org/ders/d.en/lambda.html#ix_lambda.=%3E
copy rect from article as image
https://i.gyazo.com/c23a9139688b7ed59fbe9c6cdcf91b93.png
well, I can to remember that lambda () => { return ..; } returns
another implicit lambda
but my mind refuses to understand fact that ...
auto l1 = (int a) => a + 1; // returns incremented value
auto l2 = (int a) => { return a + 1; }; // return another
lambda that increment value
... very different artifacts.
WHY? it's looks same, but in DLang it's some kind of mindtrap,
looks mindness and falsy. I am upset and angry cause somebody
just told me "There Is No Santa Claus in Dlang!" (I fell same
yesterday and almost calmed down already)
D-compiler: you want one lambda? you are lucky today! I'll give
you two lambda in square(^2) for same price! do not thank!
really, if I want lambda that returns another lambda I can write
auto l1 = (int a) => () => a + 1; // maybe I need it in some
special case
but if I want lambda with return... well, I should forget about
shorter syntax and write
auto l1 = (int a) { /*...*/ return a + 1; } // why I can't use
"=>" here?
silent cry. yes, this version is shorter than with "=>", but my
production language is C# (same as Dlang with CIL instead native.
before today) and I try to do something in Dlang.
my state when I stick to such things looks like this (pic about
JavaScript)
https://pics.me.me/javascript-%3E-53-53-5-2-5-2-%3E-53-ah-gonna-29130223.png
DON'T READ NEXT
I readed 2 weeks ago post "Dlang is a crap".
well, I agree with author in many thing.
* and such small things like (not)using "=>" can kickass you for
hours.
* and naming exceptions for example in std.concurrency - some
ends with "Exception" some not - told me that no one center in
Dlang development, no good organization and no standard.
* and VisualD sometimes lost autocompletion/intellisense and
there's no way to get it back, except to restart the computer.
* and parsing Binance(cryptoexchange) JSON-response "All Market
Tickers Stream" from
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md (~150 submessages about 200KB) with ctRegex(that told as very fast) spend 13ms. task is find every submessage that starts with '{' and ends with '}' and parse it from JSON to some struct. but simple replace ctRegex to indexOf( '{'|'}' ) decrease time to 2ms only - 90% of time getting filled 150 structs with data (that means find all string values in submessage and convert it to some types like double or long with my CTFE-code, not Dlang-JSON) spend compile-time Regex for searching start{ and end}. WTF? well, Go(version maybe 1.9) was a little bit faster about 10ms, but C# with Json.NET, where JIT and no string-spans(that means alloc every substring in GC) and all strings are Unicode(WebSocket sent UTF8, that adds Encoding time to Unicode) - spend only 3ms for all. Dlang can do things better and faster but it don't want (or people don't want)
* and many "nothrow nogc trusted pure" near every function in
Phobos and you should read every function attrubute when you try
to understand exactly what does and how works this function,
cause you can miss some important attribute. I don't know how it
should be done/removed from eyes. probably better such stuff
describe before function like [context: nogc noBoundsCheck
nothrow pure trusted] int func( args... ) cause you can vissually
ignore [context..] and look at function without urban garbage..
maybe it should looks in editor like checkbox spans in right side
of editor where you can turn off/on such attributes but text is
clear not over..loaded? (English is not my native)
* and everybody will change nothing with textual representation
of code cause this things used already in many code and packages.
(except VisualD that in some days will be fixed)
it's sad.
over Dlang' code textual representation should be used another
sugar representation that hides and reorganize some things (like
TypeScript over JavaScript or MOC in Qt)
when Rust will add GC I will go to Rust - I dont like ownership
stuff.
when Go will add OOP & exceptions I will go to Go - I dont like
check every function call with if err.. also I can live with type
traits without classes in most cases.
probably I will go.
I like in Dlang: native (with asm), GC, CTFE, OOP, functional
style... (I am not a professional with Dlang, I learning it)
but sometimes Dlang is little baby who can piss/shit you in
moments when you really not expect and you haven't diaper or any
protection for that cases.
YOU CAN READ AGAIN
can somebody tell me please what was the reason that lambda
(blah) => { return value + 1; } actionally returns another lambda
that returns value+1? what case it can be usefull? why Dlang
gives me lambda of lambda where I want lambda written with "=> {
return"?
I am expecting some magic and simple trick with lambdas.