mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
Remove confusing <//> (#17830)
This commit is contained in:
@@ -1290,10 +1290,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
|
||||
put(g, tkSpaces, Space)
|
||||
infixArgument(g, n, 2)
|
||||
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:
|
||||
let opr = if n[0].kind == nkIdent: n[0].ident
|
||||
elif n[0].kind == nkSym: n[0].sym.name
|
||||
|
||||
@@ -68,7 +68,7 @@ type
|
||||
## A node of a doubly linked list.
|
||||
##
|
||||
## It consists of a `value` field, and pointers to `next` and `prev`.
|
||||
next*: <//>(DoublyLinkedNode[T])
|
||||
next*: DoublyLinkedNode[T]
|
||||
prev* {.cursor.}: DoublyLinkedNode[T]
|
||||
value*: T
|
||||
DoublyLinkedNode*[T] = ref DoublyLinkedNodeObj[T]
|
||||
@@ -77,23 +77,23 @@ type
|
||||
## A node of a singly linked list.
|
||||
##
|
||||
## It consists of a `value` field, and a pointer to `next`.
|
||||
next*: <//>(SinglyLinkedNode[T])
|
||||
next*: SinglyLinkedNode[T]
|
||||
value*: T
|
||||
SinglyLinkedNode*[T] = ref SinglyLinkedNodeObj[T]
|
||||
|
||||
SinglyLinkedList*[T] = object
|
||||
## A singly linked list.
|
||||
head*: <//>(SinglyLinkedNode[T])
|
||||
head*: SinglyLinkedNode[T]
|
||||
tail* {.cursor.}: SinglyLinkedNode[T]
|
||||
|
||||
DoublyLinkedList*[T] = object
|
||||
## A doubly linked list.
|
||||
head*: <//>(DoublyLinkedNode[T])
|
||||
head*: DoublyLinkedNode[T]
|
||||
tail* {.cursor.}: DoublyLinkedNode[T]
|
||||
|
||||
SinglyLinkedRing*[T] = object
|
||||
## A singly linked ring.
|
||||
head*: <//>(SinglyLinkedNode[T])
|
||||
head*: SinglyLinkedNode[T]
|
||||
tail* {.cursor.}: SinglyLinkedNode[T]
|
||||
|
||||
DoublyLinkedRing*[T] = object
|
||||
@@ -148,7 +148,7 @@ proc initDoublyLinkedRing*[T](): DoublyLinkedRing[T] =
|
||||
|
||||
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`.
|
||||
runnableExamples:
|
||||
let n = newDoublyLinkedNode[int](5)
|
||||
@@ -157,7 +157,7 @@ proc newDoublyLinkedNode*[T](value: T): <//>(DoublyLinkedNode[T]) =
|
||||
new(result)
|
||||
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`.
|
||||
runnableExamples:
|
||||
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.
|
||||
##
|
||||
## See also:
|
||||
@@ -810,7 +810,7 @@ proc newTable*[A, B](initialSize = defaultInitialSize): <//>TableRef[A, B] =
|
||||
new(result)
|
||||
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`.
|
||||
##
|
||||
## `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)
|
||||
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.
|
||||
# TODO: As soon as supported, change collection: A to collection: A[B]
|
||||
result = newTable[C, B]()
|
||||
@@ -1790,7 +1790,7 @@ iterator mvalues*[A, B](t: var OrderedTable[A, B]): var B =
|
||||
# --------------------------- 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.
|
||||
##
|
||||
## See also:
|
||||
@@ -1805,7 +1805,7 @@ proc newOrderedTable*[A, B](initialSize = defaultInitialSize): <//>OrderedTableR
|
||||
new(result)
|
||||
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`.
|
||||
##
|
||||
## `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 newCountTable*[A](initialSize = defaultInitialSize): <//>CountTableRef[A] =
|
||||
proc newCountTable*[A](initialSize = defaultInitialSize): CountTableRef[A] =
|
||||
## Creates a new ref count table that is empty.
|
||||
##
|
||||
## See also:
|
||||
@@ -2621,7 +2621,7 @@ proc newCountTable*[A](initialSize = defaultInitialSize): <//>CountTableRef[A] =
|
||||
new(result)
|
||||
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`
|
||||
## having a count of how many times it occurs in that container.
|
||||
result = newCountTable[A](keys.len)
|
||||
|
||||
@@ -496,17 +496,17 @@ proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} =
|
||||
|
||||
# ---------------- Configuration file related operations ----------------
|
||||
type
|
||||
Config* = OrderedTableRef[string, <//>OrderedTableRef[string, string]]
|
||||
Config* = OrderedTableRef[string, OrderedTableRef[string, string]]
|
||||
|
||||
proc newConfig*(): Config =
|
||||
## Creates a new configuration table.
|
||||
## 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.
|
||||
## `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,
|
||||
## the default value of the current section is "",
|
||||
## which means that the current section is a common
|
||||
@@ -536,7 +536,7 @@ proc loadConfig*(stream: Stream, filename: string = "[stream]"): <//>Config =
|
||||
close(p)
|
||||
result = dict
|
||||
|
||||
proc loadConfig*(filename: string): <//>Config =
|
||||
proc loadConfig*(filename: string): Config =
|
||||
## Loads the specified configuration file into a new Config instance.
|
||||
let file = open(filename, fmRead)
|
||||
let fileStream = newFileStream(file)
|
||||
|
||||
@@ -218,7 +218,7 @@ proc resetOutputFormatters* {.since: (1, 1).} =
|
||||
formatters = @[]
|
||||
|
||||
proc newConsoleOutputFormatter*(outputLevel: OutputLevel = outputLevelDefault,
|
||||
colorOutput = true): <//>ConsoleOutputFormatter =
|
||||
colorOutput = true): ConsoleOutputFormatter =
|
||||
ConsoleOutputFormatter(
|
||||
outputLevel: outputLevel,
|
||||
colorOutput: colorOutput
|
||||
@@ -246,7 +246,7 @@ proc colorOutput(): bool =
|
||||
deprecateEnvVarHere()
|
||||
result = false
|
||||
|
||||
proc defaultConsoleFormatter*(): <//>ConsoleOutputFormatter =
|
||||
proc defaultConsoleFormatter*(): ConsoleOutputFormatter =
|
||||
var colorOutput = colorOutput()
|
||||
var outputLevel = nimUnittestOutputLevel.parseEnum[:OutputLevel]
|
||||
when declared(stdout):
|
||||
@@ -315,7 +315,7 @@ proc xmlEscape(s: string): string =
|
||||
else:
|
||||
result.add(c)
|
||||
|
||||
proc newJUnitOutputFormatter*(stream: Stream): <//>JUnitOutputFormatter =
|
||||
proc newJUnitOutputFormatter*(stream: Stream): JUnitOutputFormatter =
|
||||
## Creates a formatter that writes report to the specified stream in
|
||||
## JUnit format.
|
||||
## 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.}
|
||||
## 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:
|
||||
template unown*(x: typed): untyped = x
|
||||
@@ -908,8 +906,6 @@ else:
|
||||
new(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) =
|
||||
## Useful for `disarming` dangling pointers explicitly for `--newruntime`.
|
||||
|
||||
@@ -25,8 +25,13 @@ putEnv("HEAPTRASHING", "Indeed")
|
||||
|
||||
let s1 = getAllocStats()
|
||||
|
||||
|
||||
proc newTableOwned[A, B](initialSize = defaultInitialSize): owned(TableRef[A, B]) =
|
||||
new(result)
|
||||
result[] = initTable[A, B](initialSize)
|
||||
|
||||
proc main =
|
||||
var w = newTable[string, owned Node]()
|
||||
var w = newTableOwned[string, owned Node]()
|
||||
w["key"] = Node(field: "value")
|
||||
echo w["key"][]
|
||||
echo getEnv("HEAPTRASHING")
|
||||
|
||||
Reference in New Issue
Block a user