What is the purpose of do notation

2021-07-28 Thread ashleylose07
Damm even I am having a similar kind of issue, I have searched all over the internet and even have posted on number of threads on different forum, no solution seems to work. I am really frustrated, can anyone of you here help me resolve this issue, I am very much tired now.

What is the purpose of do notation

2021-07-23 Thread Araq
> Now I see why it is so :). Because it's a hack that doesn't look good enough > to be included into the language. But that's a sad news. Type infer, at the > very least for anonymous functions, is very useful and important feature... 1. No, it's not a very "important feature", it's pretty muc

What is the purpose of do notation

2021-07-23 Thread juancarlospaco
Pass result as argument, then it wont use auto

What is the purpose of do notation

2021-07-23 Thread dom96
> Now I see why it is so :). Because it's a hack that doesn't look good enough > to be included into the language. But that's a sad news. Type infer, at the > very least for anonymous functions, is very useful and important feature... I dunno, I wouldn't call the `=>` itself a hack, it uses what

What is the purpose of do notation

2021-07-23 Thread alexeypetrushin
> This is the same old problem — Nim doesn't have backward type inference. The > => macro does argument type “inference” in a hacky way by making the function > generic, but I'm not sure if that's appropriate for a language construct. Aha... it explains this mystery. I was always wondering why `

What is the purpose of do notation

2021-07-23 Thread haxscramper
test _12_

What is the purpose of do notation

2021-07-23 Thread juancarlospaco
I was not against nor in favor of it, it was just raw new-user feedback.

What is the purpose of do notation

2021-07-23 Thread haxscramper
It does not really make sense to put two-three line procedure (that might also be a closure btw, so it can't really be moved to toplevel) to the toplevel, and cramming all of this in the `=>` notation is not always possible as well.

What is the purpose of do notation

2021-07-23 Thread dom96
Regarding `quote do`, I see no reason why the `do` is necessary for this. Still waiting for someone to explain why it uses `do`. Why can't `quote` just work? Regarding @yglukhov's examples, personally I think the proc syntax is perfectly good, your style just needs a tweak :) foo(a

What is the purpose of do notation

2021-07-23 Thread Araq
> but I'm not sure if that's appropriate for a language construct. I think it's completely acceptable. Esp for alexeypetrushin.

What is the purpose of do notation

2021-07-23 Thread xigoi
This is the same old problem — Nim doesn't have backward type inference. The `=>` macro does argument type “inference” in a hacky way by making the function generic, but I'm not sure if that's appropriate for a language construct.

What is the purpose of do notation

2021-07-23 Thread alexeypetrushin
> 1 do is used frequently, see posts above of yours. > 2 do works as it is > documented, see point (1) > 3 Ruby had no significant influence on Nim's > design, sorry. 1. Ok, maybe, although I don't think `do` is used frequently, and I haven't seen such usage in other's people code. 2. I phr

What is the purpose of do notation

2021-07-23 Thread yglukhov
We have 873 `do`\- lambda occurrences in our private codebase :) . Although they can be replaced with anonymous procs, they slightly add to syntactical ergonomics and readability IMO. Compare this: foo(a, b) do(c, d: int) -> int: # Some body here return c + d

What is the purpose of do notation

2021-07-23 Thread Araq
Well... > Situation is similar here. Nobody uses it because do implemented poorly. I > from Ruby experience, like do, and tried to use it in Nim. But it doesn't > work. 1. `do` is used frequently, see posts above of yours. 2. `do` works as it is documented, see point (1) 3. Ruby had no si

What is the purpose of do notation

2021-07-22 Thread alexeypetrushin
> I never really used do outside of quote do, and never seen used too much in > the wild neither, and people want to have else in more places, like > for...else, try...else, etc in Python. Reminds me about issue Youtube had couple of years ago. They improved Front-End performance, made it light

What is the purpose of do notation

2021-07-22 Thread cblake
> I think that theres alternatives already in std/genasts, fusion/astdsl, etc. @juancarlospaco \- sure, but I just did a search and in the whole nimbleverse not even one package imports `genasts`. The compiler/stdlib itself only tests it, instead using `quote do:`. The only thing I found anywher

What is the purpose of do notation

2021-07-22 Thread dom96
Good question, one I've had for a while myself.

What is the purpose of do notation

2021-07-22 Thread juancarlospaco
I think that theres alternatives already in std/genasts, fusion/astdsl, etc.

What is the purpose of do notation

2021-07-22 Thread Araq
> I think a real benefit is simplifying Nim. Costs vs benefits. The costs are high and `do` is only syntax so you don't simplify the language a whole lot. I'd rather throw away Nim's effect system. ;-) > but if someone is passionate enough to create a PR which deprecates it and > introduces th

What is the purpose of do notation

2021-07-22 Thread xigoi
Is there any difference between `quote do:` and just `quote:`?

What is the purpose of do notation

2021-07-22 Thread cblake
@juancarlospaco \- ok, but there are literally 1000s of calls to quote do: in the nimbleverse alone. So, we probably can never get rid of it, but that doesn't mean we cannot make it better. @dom96 \- The easy path here might be to just allow `do` to accept **_optional parameter names_**. We cou

What is the purpose of do notation

2021-07-22 Thread juancarlospaco
I never really used `do` outside of `quote do`, and never seen used too much in the wild neither, and people want to have `else` in more places, like `for...else`, `try...else`, etc in Python.

What is the purpose of do notation

2021-07-22 Thread cblake
FWIW, user-specifiable keywords at definition/part of the call signature might be both backward compatible and nicely more general. E.g. `template[phase2, phase3] foo(phase1, phase2, phase3)` where the desired `else` might be `template[else] withValue(...)`. That seems like it'd be trickier, tho

What is the purpose of do notation

2021-07-22 Thread cblake
There is also probably a whole lot of `quote do:` code out there. While it may not be the most robust kind of macro metaprogramming, that general area is one of Nim's very distinctive features. `algorithm.sort` docs still direct users to use `do` instead of a `(proc(): int =)` lambda syntax. So

What is the purpose of do notation

2021-07-22 Thread dom96
I think a real benefit is simplifying Nim. It's definitely not a priority and there is plenty of other more important things to do, but if someone is passionate enough to create a PR which deprecates it and introduces the syntax above would you complain?

What is the purpose of do notation

2021-07-22 Thread Araq
No... I don't like `do` either but removing/changing/deprecating it at this point only has downsides. Maybe it's used in some code you like to use as a dependency, what then? Patch the dependency? And what if its author happens to like it? For everything we do we should do some basic "costs vs b

What is the purpose of do notation

2021-07-22 Thread dom96
The "do notation" is an overloaded feature of the language because it offers two things: * A different way to pass anonymous procs/closures to a procedure * A way to pass two code blocks to a template. Personally I've been arguing for the removal of the first use case for years now. For t

What is the purpose of do notation

2021-07-22 Thread Araq
It allows for code like: table.withValue("key", value): echo "value is ", value do: echo "key is not in table" Run

What is the purpose of do notation

2021-07-21 Thread cobbycobby
Can someone please explain me purpose of do notation? What are its benefits in comparison to anonymous procs?