You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For parameters it currently creates implicitly generic routines:
proc foo(a, b: auto) = discard
Is the same as:
proc foo[T1, T2](a: T1, b: T2) = discard
it's also not used (much/at all) IIRC and is underdocumented.
note
docs also says:
However, later versions of the language might change this to mean "infer the parameters' types from the body". Then the above foo would be rejected as the parameters' types can not be inferred from an empty discard statement.
but IMO a pragma should be used for that instead of changing meaning of auto
note 2
docs should add right here: typedesc is a "bind many" type class:
that auto is also "bind many"
Reacted by Andreas Rumpf, Zed, Andrea Ferretti, Sebastian, Juan Carlos, Xie Yanbo, Smooth Operator, γγθ, haxscramper, konsumlamm and 1 more
To me any is a pretty scary thing. I wasn't even aware of its existence (talk about under documented) until a master's student of mine started using it in her code.
To me it's too close to making it seem like Nim is a dynamic language, i.e. people using it not realizing that it's "just" an implicit generic and then getting confused about resulting errors etc.
It's kinda neat that Nim allows to write code that looks so little like typed code, but... Who would honestly use any instead of a completely unrestricted generic?
any is shorter and more accurate name for a type, should we decom auto instead
auto is widespread, and common in other languages; it's here to stay.
...talk about under documented...
yes
Who would honestly use any instead of a completely unrestricted generic?
same holds for auto though. But it's useful, you just need to read the docs about what auto means as a param. That can be made easy if theindex.html starts indexing keywords like auto.
procfn[T1,T2](a1: T1, a2: T2) =discardprocfn(a1, a2: auto) =discard# shorter, and makes sense if you're not using T1, T2
Activity
[-]deprecate `any` and `tyAnything` (redundant with `auto`)[/-][+]deprecate `any` (redundant with `auto`)[/+]cooldome commentedon Nov 6, 2020
any is shorter and more accurate name for a type, should we decom auto instead
Vindaar commentedon Nov 6, 2020
To me
anyis a pretty scary thing. I wasn't even aware of its existence (talk about under documented) until a master's student of mine started using it in her code.To me it's too close to making it seem like Nim is a dynamic language, i.e. people using it not realizing that it's "just" an implicit generic and then getting confused about resulting errors etc.
It's kinda neat that Nim allows to write code that looks so little like typed code, but... Who would honestly use
anyinstead of a completely unrestricted generic?timotheecour commentedon Nov 6, 2020
auto is widespread, and common in other languages; it's here to stay.
yes
same holds for
autothough. But it's useful, you just need to read the docs about whatautomeans as a param. That can be made easy iftheindex.htmlstarts indexing keywords likeauto.treeform commentedon Jan 7, 2021
I support removal of
anyin favor of just havingauto.Also
anytype conflicts with function std libany( https://nim-lang.org/docs/sequtils.html#any%2CopenArray%5BT%5D%2Cproc%28T%29 ).Which leads to some strange errors and crashes: nim-lang/Nim#14255
juancarlospaco commentedon Feb 2, 2021
Deprecation of
anyshould start ASAP then.timotheecour commentedon Feb 3, 2021
@juancarlospaco can you please make a PR?
juancarlospaco commentedon Feb 3, 2021
nim-lang/Nim#16920
ringabout commentedon Feb 9, 2021
autocauses the same issues tooError: internal error: getTypeDescAux(tyFromExpr)
No stack traceback available
timotheecour commentedon Feb 9, 2021
anywas also confusing (in the human sense, not compiler sense) with typeinfo.Any refs https://nim-lang.github.io/Nim/typeinfo.html#Any