Remove confusing <//> (#17830)
This commit is contained in:
parent
9e6f2d7d18
commit
68e522ecec
7 changed files with 29 additions and 31 deletions
|
|
@ -1290,9 +1290,6 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
|
||||||
put(g, tkSpaces, Space)
|
put(g, tkSpaces, Space)
|
||||||
infixArgument(g, n, 2)
|
infixArgument(g, n, 2)
|
||||||
of nkPrefix:
|
of nkPrefix:
|
||||||
if n.len > 0 and n[0].kind == nkIdent and n[0].ident.s == "<//>":
|
|
||||||
discard "XXX Remove this hack after 0.20 has been released!"
|
|
||||||
else:
|
|
||||||
gsub(g, n, 0)
|
gsub(g, n, 0)
|
||||||
if n.len > 1:
|
if n.len > 1:
|
||||||
let opr = if n[0].kind == nkIdent: n[0].ident
|
let opr = if n[0].kind == nkIdent: n[0].ident
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ type
|
||||||
## A node of a doubly linked list.
|
## A node of a doubly linked list.
|
||||||
##
|
##
|
||||||
## It consists of a `value` field, and pointers to `next` and `prev`.
|
## It consists of a `value` field, and pointers to `next` and `prev`.
|
||||||
next*: <//>(DoublyLinkedNode[T])
|
next*: DoublyLinkedNode[T]
|
||||||
prev* {.cursor.}: DoublyLinkedNode[T]
|
prev* {.cursor.}: DoublyLinkedNode[T]
|
||||||
value*: T
|
value*: T
|
||||||
DoublyLinkedNode*[T] = ref DoublyLinkedNodeObj[T]
|
DoublyLinkedNode*[T] = ref DoublyLinkedNodeObj[T]
|
||||||
|
|
@ -77,23 +77,23 @@ type
|
||||||
## A node of a singly linked list.
|
## A node of a singly linked list.
|
||||||
##
|
##
|
||||||
## It consists of a `value` field, and a pointer to `next`.
|
## It consists of a `value` field, and a pointer to `next`.
|
||||||
next*: <//>(SinglyLinkedNode[T])
|
next*: SinglyLinkedNode[T]
|
||||||
value*: T
|
value*: T
|
||||||
SinglyLinkedNode*[T] = ref SinglyLinkedNodeObj[T]
|
SinglyLinkedNode*[T] = ref SinglyLinkedNodeObj[T]
|
||||||
|
|
||||||
SinglyLinkedList*[T] = object
|
SinglyLinkedList*[T] = object
|
||||||
## A singly linked list.
|
## A singly linked list.
|
||||||
head*: <//>(SinglyLinkedNode[T])
|
head*: SinglyLinkedNode[T]
|
||||||
tail* {.cursor.}: SinglyLinkedNode[T]
|
tail* {.cursor.}: SinglyLinkedNode[T]
|
||||||
|
|
||||||
DoublyLinkedList*[T] = object
|
DoublyLinkedList*[T] = object
|
||||||
## A doubly linked list.
|
## A doubly linked list.
|
||||||
head*: <//>(DoublyLinkedNode[T])
|
head*: DoublyLinkedNode[T]
|
||||||
tail* {.cursor.}: DoublyLinkedNode[T]
|
tail* {.cursor.}: DoublyLinkedNode[T]
|
||||||
|
|
||||||
SinglyLinkedRing*[T] = object
|
SinglyLinkedRing*[T] = object
|
||||||
## A singly linked ring.
|
## A singly linked ring.
|
||||||
head*: <//>(SinglyLinkedNode[T])
|
head*: SinglyLinkedNode[T]
|
||||||
tail* {.cursor.}: SinglyLinkedNode[T]
|
tail* {.cursor.}: SinglyLinkedNode[T]
|
||||||
|
|
||||||
DoublyLinkedRing*[T] = object
|
DoublyLinkedRing*[T] = object
|
||||||
|
|
@ -148,7 +148,7 @@ proc initDoublyLinkedRing*[T](): DoublyLinkedRing[T] =
|
||||||
|
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc newDoublyLinkedNode*[T](value: T): <//>(DoublyLinkedNode[T]) =
|
proc newDoublyLinkedNode*[T](value: T): DoublyLinkedNode[T] =
|
||||||
## Creates a new doubly linked node with the given `value`.
|
## Creates a new doubly linked node with the given `value`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
let n = newDoublyLinkedNode[int](5)
|
let n = newDoublyLinkedNode[int](5)
|
||||||
|
|
@ -157,7 +157,7 @@ proc newDoublyLinkedNode*[T](value: T): <//>(DoublyLinkedNode[T]) =
|
||||||
new(result)
|
new(result)
|
||||||
result.value = value
|
result.value = value
|
||||||
|
|
||||||
proc newSinglyLinkedNode*[T](value: T): <//>(SinglyLinkedNode[T]) =
|
proc newSinglyLinkedNode*[T](value: T): SinglyLinkedNode[T] =
|
||||||
## Creates a new singly linked node with the given `value`.
|
## Creates a new singly linked node with the given `value`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
let n = newSinglyLinkedNode[int](5)
|
let n = newSinglyLinkedNode[int](5)
|
||||||
|
|
|
||||||
|
|
@ -795,7 +795,7 @@ iterator allValues*[A, B](t: Table[A, B]; key: A): B {.deprecated:
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
proc newTable*[A, B](initialSize = defaultInitialSize): <//>TableRef[A, B] =
|
proc newTable*[A, B](initialSize = defaultInitialSize): TableRef[A, B] =
|
||||||
## Creates a new ref hash table that is empty.
|
## Creates a new ref hash table that is empty.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
|
|
@ -810,7 +810,7 @@ proc newTable*[A, B](initialSize = defaultInitialSize): <//>TableRef[A, B] =
|
||||||
new(result)
|
new(result)
|
||||||
result[] = initTable[A, B](initialSize)
|
result[] = initTable[A, B](initialSize)
|
||||||
|
|
||||||
proc newTable*[A, B](pairs: openArray[(A, B)]): <//>TableRef[A, B] =
|
proc newTable*[A, B](pairs: openArray[(A, B)]): TableRef[A, B] =
|
||||||
## Creates a new ref hash table that contains the given `pairs`.
|
## Creates a new ref hash table that contains the given `pairs`.
|
||||||
##
|
##
|
||||||
## `pairs` is a container consisting of `(key, value)` tuples.
|
## `pairs` is a container consisting of `(key, value)` tuples.
|
||||||
|
|
@ -826,7 +826,7 @@ proc newTable*[A, B](pairs: openArray[(A, B)]): <//>TableRef[A, B] =
|
||||||
new(result)
|
new(result)
|
||||||
result[] = toTable[A, B](pairs)
|
result[] = toTable[A, B](pairs)
|
||||||
|
|
||||||
proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): <//>TableRef[C, B] =
|
proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): TableRef[C, B] =
|
||||||
## Index the collection with the proc provided.
|
## Index the collection with the proc provided.
|
||||||
# TODO: As soon as supported, change collection: A to collection: A[B]
|
# TODO: As soon as supported, change collection: A to collection: A[B]
|
||||||
result = newTable[C, B]()
|
result = newTable[C, B]()
|
||||||
|
|
@ -1790,7 +1790,7 @@ iterator mvalues*[A, B](t: var OrderedTable[A, B]): var B =
|
||||||
# --------------------------- OrderedTableRef -------------------------------
|
# --------------------------- OrderedTableRef -------------------------------
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
proc newOrderedTable*[A, B](initialSize = defaultInitialSize): <//>OrderedTableRef[A, B] =
|
proc newOrderedTable*[A, B](initialSize = defaultInitialSize): OrderedTableRef[A, B] =
|
||||||
## Creates a new ordered ref hash table that is empty.
|
## Creates a new ordered ref hash table that is empty.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
|
|
@ -1805,7 +1805,7 @@ proc newOrderedTable*[A, B](initialSize = defaultInitialSize): <//>OrderedTableR
|
||||||
new(result)
|
new(result)
|
||||||
result[] = initOrderedTable[A, B](initialSize)
|
result[] = initOrderedTable[A, B](initialSize)
|
||||||
|
|
||||||
proc newOrderedTable*[A, B](pairs: openArray[(A, B)]): <//>OrderedTableRef[A, B] =
|
proc newOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTableRef[A, B] =
|
||||||
## Creates a new ordered ref hash table that contains the given `pairs`.
|
## Creates a new ordered ref hash table that contains the given `pairs`.
|
||||||
##
|
##
|
||||||
## `pairs` is a container consisting of `(key, value)` tuples.
|
## `pairs` is a container consisting of `(key, value)` tuples.
|
||||||
|
|
@ -2610,7 +2610,7 @@ iterator mvalues*[A](t: var CountTable[A]): var int =
|
||||||
|
|
||||||
proc inc*[A](t: CountTableRef[A], key: A, val = 1)
|
proc inc*[A](t: CountTableRef[A], key: A, val = 1)
|
||||||
|
|
||||||
proc newCountTable*[A](initialSize = defaultInitialSize): <//>CountTableRef[A] =
|
proc newCountTable*[A](initialSize = defaultInitialSize): CountTableRef[A] =
|
||||||
## Creates a new ref count table that is empty.
|
## Creates a new ref count table that is empty.
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
|
|
@ -2621,7 +2621,7 @@ proc newCountTable*[A](initialSize = defaultInitialSize): <//>CountTableRef[A] =
|
||||||
new(result)
|
new(result)
|
||||||
result[] = initCountTable[A](initialSize)
|
result[] = initCountTable[A](initialSize)
|
||||||
|
|
||||||
proc newCountTable*[A](keys: openArray[A]): <//>CountTableRef[A] =
|
proc newCountTable*[A](keys: openArray[A]): CountTableRef[A] =
|
||||||
## Creates a new ref count table with every member of a container `keys`
|
## Creates a new ref count table with every member of a container `keys`
|
||||||
## having a count of how many times it occurs in that container.
|
## having a count of how many times it occurs in that container.
|
||||||
result = newCountTable[A](keys.len)
|
result = newCountTable[A](keys.len)
|
||||||
|
|
|
||||||
|
|
@ -496,17 +496,17 @@ proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} =
|
||||||
|
|
||||||
# ---------------- Configuration file related operations ----------------
|
# ---------------- Configuration file related operations ----------------
|
||||||
type
|
type
|
||||||
Config* = OrderedTableRef[string, <//>OrderedTableRef[string, string]]
|
Config* = OrderedTableRef[string, OrderedTableRef[string, string]]
|
||||||
|
|
||||||
proc newConfig*(): Config =
|
proc newConfig*(): Config =
|
||||||
## Creates a new configuration table.
|
## Creates a new configuration table.
|
||||||
## Useful when wanting to create a configuration file.
|
## Useful when wanting to create a configuration file.
|
||||||
result = newOrderedTable[string, <//>OrderedTableRef[string, string]]()
|
result = newOrderedTable[string, OrderedTableRef[string, string]]()
|
||||||
|
|
||||||
proc loadConfig*(stream: Stream, filename: string = "[stream]"): <//>Config =
|
proc loadConfig*(stream: Stream, filename: string = "[stream]"): Config =
|
||||||
## Loads the specified configuration from stream into a new Config instance.
|
## Loads the specified configuration from stream into a new Config instance.
|
||||||
## `filename` parameter is only used for nicer error messages.
|
## `filename` parameter is only used for nicer error messages.
|
||||||
var dict = newOrderedTable[string, <//>OrderedTableRef[string, string]]()
|
var dict = newOrderedTable[string, OrderedTableRef[string, string]]()
|
||||||
var curSection = "" ## Current section,
|
var curSection = "" ## Current section,
|
||||||
## the default value of the current section is "",
|
## the default value of the current section is "",
|
||||||
## which means that the current section is a common
|
## which means that the current section is a common
|
||||||
|
|
@ -536,7 +536,7 @@ proc loadConfig*(stream: Stream, filename: string = "[stream]"): <//>Config =
|
||||||
close(p)
|
close(p)
|
||||||
result = dict
|
result = dict
|
||||||
|
|
||||||
proc loadConfig*(filename: string): <//>Config =
|
proc loadConfig*(filename: string): Config =
|
||||||
## Loads the specified configuration file into a new Config instance.
|
## Loads the specified configuration file into a new Config instance.
|
||||||
let file = open(filename, fmRead)
|
let file = open(filename, fmRead)
|
||||||
let fileStream = newFileStream(file)
|
let fileStream = newFileStream(file)
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ proc resetOutputFormatters* {.since: (1, 1).} =
|
||||||
formatters = @[]
|
formatters = @[]
|
||||||
|
|
||||||
proc newConsoleOutputFormatter*(outputLevel: OutputLevel = outputLevelDefault,
|
proc newConsoleOutputFormatter*(outputLevel: OutputLevel = outputLevelDefault,
|
||||||
colorOutput = true): <//>ConsoleOutputFormatter =
|
colorOutput = true): ConsoleOutputFormatter =
|
||||||
ConsoleOutputFormatter(
|
ConsoleOutputFormatter(
|
||||||
outputLevel: outputLevel,
|
outputLevel: outputLevel,
|
||||||
colorOutput: colorOutput
|
colorOutput: colorOutput
|
||||||
|
|
@ -246,7 +246,7 @@ proc colorOutput(): bool =
|
||||||
deprecateEnvVarHere()
|
deprecateEnvVarHere()
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
proc defaultConsoleFormatter*(): <//>ConsoleOutputFormatter =
|
proc defaultConsoleFormatter*(): ConsoleOutputFormatter =
|
||||||
var colorOutput = colorOutput()
|
var colorOutput = colorOutput()
|
||||||
var outputLevel = nimUnittestOutputLevel.parseEnum[:OutputLevel]
|
var outputLevel = nimUnittestOutputLevel.parseEnum[:OutputLevel]
|
||||||
when declared(stdout):
|
when declared(stdout):
|
||||||
|
|
@ -315,7 +315,7 @@ proc xmlEscape(s: string): string =
|
||||||
else:
|
else:
|
||||||
result.add(c)
|
result.add(c)
|
||||||
|
|
||||||
proc newJUnitOutputFormatter*(stream: Stream): <//>JUnitOutputFormatter =
|
proc newJUnitOutputFormatter*(stream: Stream): JUnitOutputFormatter =
|
||||||
## Creates a formatter that writes report to the specified stream in
|
## Creates a formatter that writes report to the specified stream in
|
||||||
## JUnit format.
|
## JUnit format.
|
||||||
## The ``stream`` is NOT closed automatically when the test are finished,
|
## The ``stream`` is NOT closed automatically when the test are finished,
|
||||||
|
|
|
||||||
|
|
@ -885,8 +885,6 @@ when defined(nimOwnedEnabled) and not defined(nimscript):
|
||||||
proc unown*[T](x: T): T {.magic: "Unown", noSideEffect.}
|
proc unown*[T](x: T): T {.magic: "Unown", noSideEffect.}
|
||||||
## Use the expression `x` ignoring its ownership attribute.
|
## Use the expression `x` ignoring its ownership attribute.
|
||||||
|
|
||||||
# This is only required to make 0.20 compile with the 0.19 line.
|
|
||||||
template `<//>`*(t: untyped): untyped = owned(t)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
template unown*(x: typed): untyped = x
|
template unown*(x: typed): untyped = x
|
||||||
|
|
@ -908,8 +906,6 @@ else:
|
||||||
new(r)
|
new(r)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# This is only required to make 0.20 compile with the 0.19 line.
|
|
||||||
template `<//>`*(t: untyped): untyped = t
|
|
||||||
|
|
||||||
template disarm*(x: typed) =
|
template disarm*(x: typed) =
|
||||||
## Useful for `disarming` dangling pointers explicitly for `--newruntime`.
|
## Useful for `disarming` dangling pointers explicitly for `--newruntime`.
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,13 @@ putEnv("HEAPTRASHING", "Indeed")
|
||||||
|
|
||||||
let s1 = getAllocStats()
|
let s1 = getAllocStats()
|
||||||
|
|
||||||
|
|
||||||
|
proc newTableOwned[A, B](initialSize = defaultInitialSize): owned(TableRef[A, B]) =
|
||||||
|
new(result)
|
||||||
|
result[] = initTable[A, B](initialSize)
|
||||||
|
|
||||||
proc main =
|
proc main =
|
||||||
var w = newTable[string, owned Node]()
|
var w = newTableOwned[string, owned Node]()
|
||||||
w["key"] = Node(field: "value")
|
w["key"] = Node(field: "value")
|
||||||
echo w["key"][]
|
echo w["key"][]
|
||||||
echo getEnv("HEAPTRASHING")
|
echo getEnv("HEAPTRASHING")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue