Nim: deprecation syntax inconsistent for objects, not possible for const/let/var

Created on 12 Oct 2018  路  3Comments  路  Source: nim-lang/Nim

  • {.deprecated: "msg" .} works for routines/types but not for const/let/var:
block:
  # works
  const Foo {.deprecated.}  = 1

block:
  # Error: annotation to deprecated not supported here
  # const Foo {.deprecated: "bla".}  = 1
  • deprecated for object type inconsistent all other deprecated forms:
    for pretty much everything, {.deprecated: "blabla".} goes before the = but not for object type:
block:
  # object type: deprecated goes after `=`
  type Foo = object {.deprecated: "blabla".}
    a: int

block:
  # every thing else: deprecated goes before `=`: enum, routines, const/let/var
  type Foo {.deprecated: "asdf" .} = enum
    a
Pragmas

Most helpful comment

This could have been separated to two issues, each with a small, not an essay title:

  • deprecated pragma with annotation doesn't work for variables
  • deprecated pragma is inconsistant for object type

Seriously, you should start minimizing your issue title to not scare people away, avoiding symbols might be a good start. Just my 2垄.

All 3 comments

This could have been separated to two issues, each with a small, not an essay title:

  • deprecated pragma with annotation doesn't work for variables
  • deprecated pragma is inconsistant for object type

Seriously, you should start minimizing your issue title to not scare people away, avoiding symbols might be a good start. Just my 2垄.

Seriously, you should start minimizing your issue title to not scare people away, avoiding symbols might be a good start. Just my 2垄.

I understand your points and will keep in mind; there's a tradeoff between precision and conciseness; regarding symbols, {.deprecated: "msg" .} may make it easier to search (via {.deprecated: ") compared to deprecated pragma with annotation (lots of synonyms in english) when searching with in:title but YMMV
likewise with grouping vs splitting related issues; in some similar past cases others were recommending grouping instead; so it's not completely obvious.

Part 2 fixed by - https://github.com/nim-lang/Nim/commit/05b8085a873ad0d8e5e823d35a0b043997e873df
Part 1 - PR https://github.com/nim-lang/Nim/pull/10110 These symbols do not store enough information currently so the patch does not work (more information). Patch added for vars/lets https://github.com/nim-lang/Nim/pull/10234
Only remaining issue is const

Was this page helpful?
0 / 5 - 0 ratings