profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/yuutayamada/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

yuutayamada/flycheck-tip 43

Show flycheck/flymake errors by tooltip

yuutayamada/auto-capitalize-el 9

Forked Emacs-lisp package from emacswiki's auto-capitalize.el to use at SKK

yuutayamada/company-arduino 9

Company-mode for Arduino using irony-mode and company-c-headers

yuutayamada/emacs.d 6

my emacs configuration

yuutayamada/bpe 4

Post blog article of org-mode to Blogger from Emacs

yuutayamada/android-app.g8 0

A g8 template for Android apps in Scala

push eventnim-lang/Nim

Timothee Cour

commit sha 87cd9b24a3df66dcde96bbdec2bd7620015ddeba

add more APIs to compiler/debugutils; re-export it (#18243)

view details

push time in an hour

PR merged nim-lang/Nim

add more APIs to compiler/debugutils to help debugging compiler PTAL
  • follows #17652
  • the re-export is intentional, it allows debugging compiler with less friction

every time i have to debug compiler, I use something like this; this avoids having to patch/unpatch every compiler PR and can be useful for other people debugging compiler

+85 -0

1 comment

4 changed files

timotheecour

pr closed time in an hour

pull request commentnim-lang/Nim

escape analysis: enables memory safe views (cf 1st class openarray) and optimizations


{.experimental: "views".}

type
  Foo = object
    field: string

proc valid(s: var seq[Foo]) =
  let v: lent Foo = s[0]  # begin of borrow
  echo v.field            # end of borrow
  s.setLen 0  # valid because 'v' isn't used afterwards

proc dangerous(s: var seq[Foo]) =
  let meh: lent Foo = s[0]
  s.setLen 0
  echo meh.field
timotheecour

comment created time in 2 hours

issue commentnim-lang/Nim

IRC logs gives Error 502 Bad gateway

Indeed it's down because of Freenode troubles. I am working on bringing it back up, old logs are still there the server just isn't running, apologies :)

StefanSalewski

comment created time in 2 hours

pull request commentnim-lang/Nim

add `typetraits.deref` to return `T` in `ref T|ptr T`

What ambiguities?

I don't know either but I'm very cautious with typedesc operations and since they are very rarely used the extra verbosity cannot hurt.

timotheecour

comment created time in 3 hours

pull request commentnim-lang/Nim

add `typetraits.deref` to return `T` in `ref T|ptr T`

Ok but deref is a bad name, it doesn't dereference anything, it returns the "base type".

timotheecour

comment created time in 3 hours

pull request commentnim-lang/Nim

disable pkg manu

update: catching defects causes memory leaks, will make an issue.

timotheecour

comment created time in 4 hours

push eventnim-lang/Nim

Araq

commit sha 4ab386d072319d594821a9562a6e61226be6abe2

Deploy to GitHub pages

view details

push time in 5 hours

push eventnim-lang/Nim

j-james

commit sha a250481dcde2167d568cc1b61624658419c18e69

Make the existence of high(type) clearer, especially near subranges (#18286) * Make the existence of high(type) clearer, especially around subranges * Use a better example and dry up the wording

view details

push time in 5 hours

PR merged nim-lang/Nim

Make the existence of high(type) clearer, especially near subranges

This PR just mentions high(type) and low(type) in a couple of key places: the definition of ordinal types and the section on subranges.

Since these sections (especially subranges!) are very dependent on high(type) and low(type) and since the manual is used primarily as a reference, I thought it would be valuable to mention and have an example of those functions nearby.

+7 -4

0 comment

1 changed file

j-james

pr closed time in 5 hours

pull request commentnim-lang/Nim

add `typetraits.deref` to return `T` in `ref T|ptr T`

but with the syntax T[], but that was problematic and caused issues because of ambiguities;

What ambiguities?

timotheecour

comment created time in 6 hours

pull request commentgroonga/groonga

NormalizerTable: add

Cc: @HashidaTKS

kou

comment created time in 6 hours

PR opened groonga/groonga

Reviewers
NormalizerTable: add

See the added tests for how to use.

It uses Groonga table to normalize text. Users can implement custom normalization by managing a Groonga table.

Note that users need to rebuild the index that uses NormalizerTable when they change substitution table for the NormalizerTable. Because normalization rules are changed by change of the substitution table.

+1012 -1

0 comment

37 changed files

pr created time in 6 hours

create barnchgroonga/groonga

branch : normalizer-table

created branch time in 6 hours

pull request commentnim-lang/Nim

Strutils new sets

* make dist/asciisets import it and re-export the ones that make sense there

To me it would make sense to add all sets there. Since if it does not export all, than there is gonna be that awkwardness of having to also implement strutils just for a set its missing. However, If we define all of the sets there as well, then if we import both strutils and asciisets then some of it would be double-declared... And so would force you to write strutils.Letters or asciisets.Letters while really they are the same.

I am not misunderstanding something, right?

kintrix007

comment created time in 6 hours

pull request commentnim-lang/Nim

add `typetraits.deref` to return `T` in `ref T|ptr T`

elementType is semantically different:

import std/typetraits
type AImpl = object
  x: seq[int]
type A = ref AImpl
iterator items(a: A): int =
  for ai in a.x: yield ai

template deref*[T](_: typedesc[ptr T | ref T]): typedesc = T

echo elementType(A.default) # int
echo deref(A) # AImpl
timotheecour

comment created time in 7 hours

pull request commentnim-lang/Nim

add `typetraits.deref` to return `T` in `ref T|ptr T`

Should instead elementType support this? Yes, I know it might turn the implementation from a template to a magic but still.

timotheecour

comment created time in 7 hours

Pull request review commentnim-lang/Nim

strformat.fmt now supports non-literal const strings

 proc strformatImpl(pattern: NimNode; openChar, closeChar: char): NimNode =   when defined(debugFmtDsl):     echo repr result -macro `&`*(pattern: string): untyped = strformatImpl(pattern, '{', '}')-  ## For a specification of the `&` macro, see the module level documentation.--macro fmt*(pattern: string): untyped = strformatImpl(pattern, '{', '}')-  ## An alias for `& <#&.m,string>`_.--macro fmt*(pattern: string; openChar, closeChar: char): untyped =-  ## The same as `fmt <#fmt.m,string>`_, but uses `openChar` instead of `'{'`-  ## and `closeChar` instead of `'}'`.+macro fmt*(pattern: static string; openChar: static char, closeChar: static char): string =+  ## Interpolates `pattern` using symbols in scope.   runnableExamples:-    let testInt = 123-    assert "<testInt>".fmt('<', '>') == "123"-    assert """(()"foo" & "bar"())""".fmt(')', '(') == "(foobar)"-    assert """ ""{"123+123"}"" """.fmt('"', '"') == " \"{246}\" "--  strformatImpl(pattern, openChar.intVal.char, closeChar.intVal.char)+    let x = 7+    assert "var is {x * 2}".fmt == "var is 14"+    assert "var is {{x}}".fmt == "var is {x}" # escape via doubling+    const s = "foo: {x}"+    assert s.fmt == "foo: 7" # also works with const strings++    assert fmt"\n" == r"\n" # raw string literal+    assert "\n".fmt == "\n" # regular literal (likewise with `fmt("\n")` or `fmt "\n"`)+  runnableExamples:+    # custom `openChar`, `closeChar`+    let x = 7+    assert "<x>".fmt('<', '>') == "7"+    assert "<<<x>>>".fmt('<', '>') == "<7>"+    assert "`x`".fmt('`', '`') == "7"+  strformatImpl(pattern, openChar, closeChar)++template fmt*(pattern: static string): untyped =+  ## Alias for `fmt(pattern, '{', '}')`.+  fmt(pattern, '{', '}')++macro `&`*(pattern: string{lit}): string =+  ## `&pattern` is the same as `pattern.fmt`; prefer `fmt` since it's more+  ## flexible and readable (`&` can be confused with binary append operator).
  ## `&pattern` is the same as `pattern.fmt`.
  ## For a specification of the `&` macro, see the module level documentation.
timotheecour

comment created time in 7 hours

pull request commentnim-lang/Nim

escape analysis: enables memory safe views (cf 1st class openarray) and optimizations

var s: seq[int] 

var x = keepVarness(s[i])
x = 4 # ok, mutate s[i]
setLen s, 0
x = 4 # invalid write!

@araq I don't understand this example, var x = keepVarness(s[i]) would create a copy, x is int; can you write another example that runs and produces bad results?

timotheecour

comment created time in 8 hours

Pull request review commentnim-lang/Nim

make privateAccess work with generic types and generic instantiations; fix a SIGSEGV

 proc magicsAfterOverloadResolution(c: PContext, n: PNode,     result = n   of mPrivateAccess:     var t = n[1].typ[0]-    if t.kind in {tyRef, tyPtr}: t = t[0]+    #[+    find the underlying `object`, even in cases like these:+    type+      B[T] = object f0: int+      A1[T] = ref B[T]+      A2[T] = ref object f1: int+      A3 = ref object f2: int+      A4 = object f3: int+    ]#+    var foundPtrLike = false+    while true:+      case t.kind+      of tyRef, tyPtr:+        if foundPtrLike: break+        foundPtrLike = true

Btw I think it should follow all pointers much like we deref them all for objRefRefRef.field

timotheecour

comment created time in 8 hours

Pull request review commentnim-lang/Nim

make privateAccess work with generic types and generic instantiations; fix a SIGSEGV

 proc magicsAfterOverloadResolution(c: PContext, n: PNode,     result = n   of mPrivateAccess:     var t = n[1].typ[0]-    if t.kind in {tyRef, tyPtr}: t = t[0]+    #[+    find the underlying `object`, even in cases like these:+    type+      B[T] = object f0: int+      A1[T] = ref B[T]+      A2[T] = ref object f1: int+      A3 = ref object f2: int+      A4 = object f3: int+    ]#+    var foundPtrLike = false+    while true:+      case t.kind+      of tyRef, tyPtr:+        if foundPtrLike: break+        foundPtrLike = true+        t = t[0]+      of tyGenericBody: t = t.lastSon+      of tyGenericInst: t = t[0]+      of tyGenericInvocation: t = t[0]

tyAlias is missing I think.

And while you're at it, move all this logic to a semPrivateAccess proc.

timotheecour

comment created time in 8 hours

issue openednim-lang/Nim

IRC logs gives Error 502 Bad gateway

I have a dozen bookmarks for the Nim IRC logs, mostly advice from mratsim, like

https://irclogs.nim-lang.org/13-09-2020.html#13:59:21

Seems to be all dead since a few days, same for log of actual day https://irclogs.nim-lang.org/.

Of course it is strange that nobody other noticed that, but I tried with my smartphone too, it is the same. So maybe a regional problem for central Europe?

I heard from the IRC freenode trouble, but that should not concern old logs?

created time in 8 hours

pull request commentnim-lang/Nim

implements https://github.com/nim-lang/RFCs/issues/369

just haven't gotten around to fleshing out an answer yet on the RFC.

done, see https://github.com/nim-lang/RFCs/issues/369#issuecomment-863813757

Araq

comment created time in 8 hours

PR opened nim-lang/Nim

add typetraits.deref to return T in ref T|ptr T

IIRC there was a previous PR (from araq?) that had added the same feature but with the syntax T[], but that was problematic and caused issues because of ambiguities; this PR instead uses typetraits.deref for this

(for the same reason, in typetraits we have tup.get(i) instead of tup[i])

+16 -9

0 comment

2 changed files

pr created time in 12 hours

pull request commentnim-lang/Nim

add more APIs to compiler/debugutils to help debugging compiler

ping on this @Araq, I depend on this in every PR where i need to debug compiler

if needed i can change

conf0.isDefined("nimCompilerDebug")

to using a magic

timotheecour

comment created time in 13 hours

Pull request review commentnim-lang/Nim

make privateAccess work with generic types and generic instantiations; fix a SIGSEGV

 proc magicsAfterOverloadResolution(c: PContext, n: PNode,     result = n   of mPrivateAccess:     var t = n[1].typ[0]-    if t.kind in {tyRef, tyPtr}: t = t[0]+    if t.kind in {tyRef, tyPtr, tyGenericInst}: t = t[0]

thanks, should be correct with latest commit; your version still wasn't quite correct but I've corrected it (also t.lastSon wouldn't work for the tyGenericInst case as can be seen by looking at astalgo.debug)

the new tests i added reflect that

timotheecour

comment created time in 13 hours

pull request commentnim-lang/Nim

support `--hint:all:off --hint:x` (ditto with `--warnings` + friends)

@Araq PTAL, I implemented @Clyybber 's excellent suggestion --hint:all:on|off instead of adding --hints:none|all, ie using note groups (ditto with similar flags)

timotheecour

comment created time in 13 hours

Pull request review commentnim-lang/Nim

strformat.fmt now supports non-literal const strings

 template formatValue(result: var string; value: char; specifier: string) = template formatValue(result: var string; value: cstring; specifier: string) =   result.add value -proc strformatImpl(pattern: NimNode; openChar, closeChar: char): NimNode =-  if pattern.kind notin {nnkStrLit..nnkTripleStrLit}:-    error "string formatting (fmt(), &) only works with string literals", pattern+proc strformatImpl(f: string; openChar, closeChar: char): NimNode =+  let info = callsite()+  # pending https://github.com/nim-lang/RFCs/issues/387, use `callTree`

last commit removes callsite (but I still think RFC 387 is a good thing to implement regardless), here's the semantic difference:

when defined case1:
  import std/strformat
  let x = @[3, 4]
  let a = fmt"foo {nonexistent}"

when defined case2:
  import std/strformat
  let x = @[3, 4]
  let a = fmt"foo {x * }"

case1: no difference case2: before PR:

stack trace: (most recent call last)
/Users/timothee/git_clone/nim/Nim_devel/lib/pure/strformat.nim(673, 53) fmt
/Users/timothee/git_clone/nim/Nim_devel/lib/pure/strformat.nim(639, 18) strformatImpl
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12419.nim(5, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12419.nim(13, 14) Error: could not parse `x * `.
/Users/timothee/git_clone/nim/Nim_devel/lib/core/macros.nim(530, 5) Error: expression expected, but found '[EOF]'
    let a = fmt"foo {x * }"

after PR (after the commit that removes callsite):

stack trace: (most recent call last)
/Users/timothee/git_clone/nim/Nim_prs/lib/pure/strformat.nim(680, 16) fmt
/Users/timothee/git_clone/nim/Nim_prs/lib/pure/strformat.nim(634, 16) strformatImpl
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12419.nim(5, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12419.nim(13, 14) template/generic instantiation of `fmt` from here
/Users/timothee/git_clone/nim/Nim_prs/lib/pure/strformat.nim(634, 16) Error: could not parse `x * ` in `foo {x * }`.
/Users/timothee/git_clone/nim/Nim_prs/lib/core/macros.nim(531, 5) Error: expression expected, but found '[EOF]'
            error("could not parse `$#` in `$#`.\n$#" % [subexpr, f, e.msg])

i'd argue it's better after PR because it shows more context in stacktrace and all the information is still there.

timotheecour

comment created time in 14 hours

pull request commentnim-lang/Nim

[TODO] simplify code that handles hints/warnings

removing the TODO; this has since been more or less implemented via https://github.com/nim-lang/Nim/pull/15775 and hint:link + --listcmd for the 2 aspects of this PR

timotheecour

comment created time in 15 hours

Pull request review commentnim-lang/Nim

support `--hint:all:off --hint:x` (ditto with `--warnings` + friends)

 proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,   if i == arg.len: discard   elif i < arg.len and (arg[i] in {':', '='}): inc(i)   else: invalidCmdLineOption(conf, pass, orig, info)-  # unfortunately, hintUser and warningUser clash-  if state in {wHint, wHintAsError}:-    let x = findStr(hintMin, hintMax, id, errUnknown)-    if x != errUnknown: n = TNoteKind(x)-    else: localError(conf, info, "unknown hint: " & id)-  else:-    let x = findStr(warnMin, warnMax, id, errUnknown)-    if x != errUnknown: n = TNoteKind(x)-    else: localError(conf, info, "unknown warning: " & id) +  let isSomeHint = state in {wHint, wHintAsError}+  template findNode(noteMin, noteMax, name) =+    # unfortunately, hintUser and warningUser clash, otherwise implementation would simplify a bit+    let x = findStr(noteMin, noteMax, id, errUnknown)+    if x != errUnknown: notes = {TNoteKind(x)}+    else: localError(conf, info, "unknown $#: $#" % [name, id])+  case id.normalize+  of "all": # other note groups would be easy to support via additional cases+    notes = if isSomeHint: {hintMin..hintMax} else: {warnMin..warnMax}+  elif isSomeHint: findNode(hintMin, hintMax, "hint")+  else: findNode(warnMin, warnMax, "warning")   var val = substr(arg, i).normalize   if val == "": val = "on"   if val notin ["on", "off"]:     localError(conf, info, errOnOrOffExpectedButXFound % arg)-  elif n notin conf.cmdlineNotes or pass == passCmd1:-    if pass == passCmd1: incl(conf.cmdlineNotes, n)-    incl(conf.modifiedyNotes, n)-    case val-    of "on":-      if state in {wWarningAsError, wHintAsError}:-        incl(conf.warningAsErrors, n) # xxx rename warningAsErrors to noteAsErrors-      else:-        incl(conf.notes, n)-        incl(conf.mainPackageNotes, n)-    of "off":-      if state in {wWarningAsError, wHintAsError}:-        excl(conf.warningAsErrors, n)-      else:-        excl(conf.notes, n)-        excl(conf.mainPackageNotes, n)-        excl(conf.foreignPackageNotes, n)+  else:+    for n in notes:+      processSpecificNoteImpl(conf, pass, n, val == "on", noteAsError = state in {wWarningAsError, wHintAsError})

done

timotheecour

comment created time in 15 hours