summary refs log tree commit diff stats
path: root/doc/manual.md
Commit message (Collapse)AuthorAgeFilesLines
* open new scope for const values (#24084)metagn2024-09-091-0/+9
| | | | | | | | | | | | | fixes #5395 Previously values of `const` statements used the same scope as the `const` statement itself, meaning variables could be declared inside them and referred to in other statements in the same block. Now each `const` value opens its own scope, so any variable declared in the value of a constant can only be accessed for that constant. We could change this to open a new scope for the `const` *section* rather than each constant, so the variables can be used in other constants, but I'm not sure if this is sound.
* handle explicit generic routine instantiations in sigmatch (#24010)metagn2024-09-021-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #16376 The way the compiler handled generic proc instantiations in calls (like `foo[int](...)`) up to this point was to instantiate `foo[int]`, create a symbol for the instantiated proc (or a symchoice for multiple procs excluding ones with mismatching generic param counts), then perform overload resolution on this symbol/symchoice. The exception to this was when the called symbol was already a symchoice node, in which case it wasn't instantiated and overloading was called directly ([these lines](https://github.com/nim-lang/Nim/blob/b7b1313d21deb687adab2b4a162e716ba561a26b/compiler/semexprs.nim#L3366-L3371)). This has several problems: * Templates and macros can't create instantiated symbols, so they couldn't participate in overloaded explicit generic instantiations, causing the issue #16376. * Every single proc that can be instantiated with the given generic params is fully instantiated including the body. #9997 is about this but isn't fixed here since the instantiation isn't in a call. The way overload resolution handles explicit instantiations by itself is also buggy: * It doesn't check constraints. * It allows only partially providing the generic parameters, which makes sense for implicit generics, but can cause ambiguity in overloading. Here is how this PR deals with these problems: * Overload resolution now always handles explicit generic instantiations in calls, in `initCandidate`, as long as the symbol resolves to a routine symbol. * Overload resolution now checks the generic params for constraints and correct parameter count (ignoring implicit params). If these don't match, the entire overload is considered as not matching and not instantiated. * Special error messages are added for mismatching/missing/extra generic params. This is almost all of the diff in `semcall`. * Procs with matching generic parameters now instantiate only the type of the signature in overload resolution, not the proc itself, which also works for templates and macros. Unfortunately we can't entirely remove instantiations because overload resolution can't handle some cases with uninstantiated types even though it's resolved in the binding (see the last 2 blocks in `texplicitgenerics`). There are also some instantiation issues with default params that #24005 didn't fix but I didn't want this to become the 3rd huge generics PR in a row so I didn't dive too deep into trying to fix them. There is still a minor instantiation fix in `semtypinst` though for subscripts in calls. Additional changes: * Overloading of `[]` wasn't documented properly, it somewhat is now because we need to mention the limitation that it can't be done for generic procs/types. * Tests can now enable the new type mismatch errors with just `-d:testsConciseTypeMismatch` in the command. Package PRs: - using fork for now: [combparser](https://github.com/PMunch/combparser/pull/7) (partial generic instantiation) - merged: [cligen](https://github.com/c-blake/cligen/pull/233) (partial generic instantiation but non-overloaded + template) - merged: [neo](https://github.com/andreaferretti/neo/pull/56) (trying to instantiate template with no generic param)
* fixes #14522 #22085 #12700 #23132; no range check for uints (#23930)ringabout2024-08-111-3/+0
| | | | | | | | | | fixes #14522 fixes #22085 fixes #12700 fixes #23132 closes https://github.com/nim-lang/Nim/pull/22343 (succeeded by this PR) completes https://github.com/nim-lang/RFCs/issues/175 follow up https://github.com/nim-lang/Nim/pull/12688
* make routine implicitly gensym when other gensym symbol exists again (#23842)metagn2024-07-161-3/+6
| | | | | | | | | | | | | fixes #23813, partially reverts #23392 Before #23392, if a `gensym` symbol was defined before a proc with the same name in a template even with an `inject` annotation, the proc would be `gensym`. After #23392 the proc was instead changed to be `inject` as long as no `gensym` annotation was given. Now, to keep compatibility with the old behavior, the behavior is changed back to infer the proc as `gensym` when no `inject` annotation is given, however an explicit `inject` annotation will still inject the proc. This is also documented in the manual as the old behavior was undocumented and the new behavior is slightly different.
* Fix example code in Nim manual that cannot be compiled without error (#23722)Tomohiro2024-06-151-1/+1
|
* Add a note about the sideeffect pragma (#23543)Antonis Geralis2024-05-081-0/+2
|
* fixes #4695; closure iterators support for JS backend (#23493)ringabout2024-04-181-1/+0
| | | | | | | | | | | | | | | | | | | | | | | fixes #4695 ref https://github.com/nim-lang/Nim/pull/15818 Since `nkState` is only for the main loop state labels and `nkGotoState` is used only for dispatching the `:state` (since https://github.com/nim-lang/Nim/pull/7770), it's feasible to rewrite the loop body into a single case-based dispatcher, which enables support for JS, VM backend. `nkState` Node is replaced by a label and Node pair and `nkGotoState` is only used for intermediary processing. Backends only need to implement `nkBreakState` and `closureIterSetupExc` to support closure iterators. pending https://github.com/nim-lang/Nim/pull/23484 <del> I also observed some performance boost for C backend in the release mode (not in the danger mode though, I suppose the old implementation is optimized into computed goto in the danger mode) </del> allPathsAsgnResult???
* Update manual.md (#23393)arkanoid872024-03-161-1/+1
| | | adding link to generic == for tuples in Open and Closed symbols example
* fixes broken doc links (#23255)ringabout2024-01-251-1/+1
| | | | | https://nim-lang.github.io/Nim/testament.html#writing-unit-tests https://nim-lang.github.io/Nim/testament.html#writing-unit-tests-output-message-variable-interpolation
* Fixing overload resolution documentation (#23171)Ryan McConnell2024-01-191-22/+64
| | | As requested. Let me know where adjustments are wanted.
* document the new ambiguous identifier resolution (#23166)metagn2024-01-111-4/+26
| | | | | refs #23123 Not sure if detailed enough.
* Nim manual: better byref pragma explanation (#23192)Tomohiro2024-01-091-2/+56
| | | | | | | | | | | | | | Nim manual says: > When using the Cpp backend, params marked as byref will translate to cpp references `&` But how `byref` pragma translate to depends on whether it is used with `importc` or `importcpp`. When `byref` pragma used with `importc` types and compiled with the Cpp backend, it is not traslated to cpp reference `&`. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Changing generic weight of `tyGenericParam` (#22143)Ryan McConnell2024-01-051-9/+29
| | | | | | | | | | | | This is in reference to a [feature request](https://github.com/nim-lang/Nim/issues/22142) that I posted. I'm making this PR to demonstrate the suggested change and expect that this should be scrutinized --------- Co-authored-by: Bung <crc32@qq.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* complete std prefixes for stdlib (#22887)ringabout2023-10-301-3/+3
| | | | follow up https://github.com/nim-lang/Nim/pull/22851 follow up https://github.com/nim-lang/Nim/pull/22873
* fixes #22867; fixes cstring modification example on Nim Manual (#22871)ringabout2023-10-261-1/+2
| | | fixes #22867
* Fix typo/grammar in exception tracking section (#22801)Levi Notik2023-10-071-1/+1
| | | | | | | | I came across this sentence in the Nim Manual and couldn't make sense of it. I believe this is the correct fix for the sentence. --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* fixes a typo in the manual (#22383)ringabout2023-08-041-1/+1
| | | ref https://github.com/nim-lang/Nim/commit/0d3bde95f578576d2e84d422d5694ee0e0055cbc#commitcomment-122093273
* Document `cast` zeroing memory (#22313)konsumlamm2023-07-221-14/+17
|
* Adding info to manual (#22252)Ryan McConnell2023-07-191-3/+57
| | | | | | | | | | | * Adjustments * Moving example * typo * adding code example back and fix terms * Condensing
* clean up the documentation (#22196)ringabout2023-07-021-5/+3
|
* fixes #19086: Document exception and defect hierarchy (#22030)Raynei2023-06-081-0/+32
| | | | | * Documented exception and defect hierarchy (#19086) * Fixed style
* documents changes on byref and bycopy (#21882)Juan M Gómez2023-05-221-6/+10
|
* isolation spec update; WIP (#21843)Andreas Rumpf2023-05-141-6/+4
| | | | | | | | | | | * isolation spec update; WIP * wip * docs update, WIP * progress * Update doc/manual.md
* adds documentation for `=wasMoved` and `=dup` hooks and small fixes (#21827)ringabout2023-05-111-1/+1
| | | | | | | | | | | * adds documentation for `=wasMoved` and `=dup` hooks and small fixes * Update doc/destructors.md * Update doc/destructors.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Remove LineTooLong (#21819)Juan Carlos2023-05-111-10/+10
| | | | | | | * LineTooLong refactor to make it actually useful * Improve error message * changelog wording * Fix typo
* fixes links of generic `define` pragma (#21828)ringabout2023-05-111-1/+1
|
* documents codegendecl for object types (#21811)Juan M Gómez2023-05-081-2/+25
|
* Document about size pragma (#21794)Tomohiro2023-05-061-0/+31
| | | | | | | | | | | | | * Document about size pragma * Fix typos * Fix manual.md * Update doc/manual.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Update the Nim Manual compile pragma with the second tuple form (#21773)Daniel Belmes2023-05-051-0/+6
| | | | | * Update the nim manual compile pragma with the second tuple form of * Incorrectly put 'two' forms
* documents #21628 (#21723)Juan M Gómez2023-04-241-0/+29
| | | | | | | | | * documents #21628 * Update doc/manual.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Documented path substitution by compiler (#21662)Raynei2023-04-211-0/+2
| | | Document compiler path substitution (nim-lang#19928)
* `proc` typeclass accounts for `iterator`, call conventions + `nil` fix + ↵metagn2023-04-111-1/+12
| | | | | | | | | | | | | document typeclass AST (#21629) * test fix #16546 #16548 + another issue * please don't tell me other packages do this * fix CI + test typeclass callconv pragma * better logic in parser * docs and changelog
* warn against `a, b = val` in routine arguments (#21604)metagn2023-04-061-9/+0
| | | closes https://github.com/nim-lang/RFCs/issues/480
* document general use of `_`, error message, fixes (#21584)metagn2023-03-301-0/+13
| | | | | | | | | | | | * document general use of `_`, error message, fixes fixes #20687, fixes #21435 Documentation and changelog updated to clarify new universal behavior of `_`. Also new error message for attempting to use `_`, new tests, and fixes with overloadable symbols and implicit generics. * add test for #21435
* tuple unpacking for vars as just sugar, allowing nesting (#21563)metagn2023-03-281-2/+31
| | | | | | | | | | | | | | | | | | | * tuple unpacking for vars as just sugar, allowing nesting * set temp symbol AST * hopeful fix some issues, add test for #19364 * always use temp for consts * document, fix small issue * fix manual indentation * actually fix manual * use helper proc * don't resem temp tuple assignment
* closes #21536; fixes manual (#21552)ringabout2023-03-201-2/+2
| | | fixes manual
* fixes #19291; implements `wasMoved` hook (#21303)ringabout2023-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #19291; implements `wasMoved` hook * basics * checkpoint * finish `wasMoved` * add a test for #19291 * add documentation and changelog * work `attachedWasMoved` with generics * fixes optimizer * register `=wasMoved` * handle wasMoved magcis * check another round * some patches * try `op == nil` * nicer * generate `wasMoved` before `destroy` * try again * fixes tests * default wasMoved * Update tests/destructor/tv2_cast.nim * Update tests/destructor/tv2_cast.nim * Update tests/arc/topt_refcursors.nim
* Fix a couple of small keyword issues. (#21416)Benji York2023-02-221-2/+2
| | | In this section of the manual, "if" should be enclosed in backticks and "elif" should be lower case.
* fix #19580; add warning for bare except: clause (#21099)ringabout2022-12-151-11/+9
| | | | | | | | | | | | | | | | | | | | | * fix #19580; add warning for bare except: clause * fixes some easy ones * Update doc/manual.md * fixes docs * Update changelog.md * addition * Apply suggestions from code review Co-authored-by: Jacek Sieka <arnetheduck@gmail.com> * Update doc/tut2.md Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
* generic `define` pragma + string alias (#20979)metagn2022-12-131-0/+18
| | | | | | | | | * generic `define` pragma + string alias * clean * add tests and document * remove char/float, minimize changelog
* clean up the documentation of threads (#21067)ringabout2022-12-101-12/+1
| | | | | * clean up the documentation of threads * cleanup
* better procvar ambiguity errors, clean up after #20457 (#20932)metagn2022-12-011-0/+17
| | | | | | | | | | | | | | | * better procvar ambiguity errors, clean up after #20457 fixes #6359, fixes #13849 * only trigger on closedsymchoice again * new approach * add manual entry for ambiguous enums too * add indent [skip ci] * move to proc
* add documentation and changelog for default object fields (#20845)ringabout2022-11-151-0/+51
|
* add back discard as a way to do multiline comments, see #12352 (#20688)Pietro Peterlongo2022-10-281-0/+12
|
* fixes #19162; enable `strictEffects` for v2 (#19380)ringabout2022-10-151-3/+1
| | | | | | | | | | | | | | | | | | | * enable stricteffects * add gcsafe * fix tests * use func * fixes pegs tests * explicitly mark repr related procs with noSideEffect * add nimLegacyEffects * change URL * fixes docopt * add `raises: []` to repr * fixes weave * fixes nimyaml * fixes glob * fixes parsetoml * Apply suggestions from code review * Update testament/important_packages.nim * add legacy:laxEffects
* Automatic dereferencing is removed (#20531)ringabout2022-10-101-4/+0
|
* Markdown indented code blocks (#20473)Andrey Makarov2022-10-051-70/+76
| | | | | | | | | | | | | | | | | | | | | | | * Implement Markdown indented code blocks Additional indentation of 4 spaces makes a block an "indented code block" (monospaced text without syntax highlighting). Also `::` RST syntax for code blocks is disabled. So instead of ```rst see:: Some code ``` the code block should be written as ```markdown see: Some code ``` * Migrate RST literal blocks :: to Markdown's ones
* Unicode Operators are no longer experimental (#20444)ringabout2022-09-281-0/+15
| | | | | | | | | * Unicode Operators are no longer experimental * fixes tests * Update doc/manual.md Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* moderate system cleanup & refactor (#20355)metagn2022-09-281-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Update manual.md (#20394)Judd2022-09-211-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * Update manual.md update outdated information on `ObservableStores`. * Update manual.md add `base` pragma to fix the warning. * Update doc/manual.md accept. Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Update manual.md update example code. * Update manual.md 1. more updates to help keeping readers on track. 1. fix typos. Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>