diff --git a/doc/advopt.txt b/doc/advopt.txt index bfeee0c643..38461244d2 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -78,5 +78,5 @@ Advanced options: --listCmd list the commands used to execute external programs --parallelBuild=0|1|... perform a parallel build value = number of processors (0 for auto-detect) - --verbosity:0|1|2|3 set Nimrod's verbosity level (0 is default) + --verbosity:0|1|2|3 set Nimrod's verbosity level (1 is default) -v, --version show detailed version information diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt index 06d447b7e1..179de3b043 100644 --- a/doc/nimrodc.txt +++ b/doc/nimrodc.txt @@ -68,6 +68,25 @@ ShadowIdent A local variable shadows another local User Some user defined warning. ========================== ============================================ + +Verbosity levels +---------------- + +===== ============================================ +Level Description +===== ============================================ +0 Minimal output level for the compiler. +1 Displays compilation of all the compiled files, including those imported + by other modules or through the `compile pragma<#compile-pragma>`_. + This is the default level. +2 Displays compilation statistics, enumerates the dynamic + libraries that will be loaded by the final binary and dumps to + standard output the result of applying `a filter to the source code + `_ if any filter was used during compilation. +3 In addition to the previous levels dumps a debug stack trace + for compiler developers. +===== ============================================ + Configuration files ------------------- diff --git a/doc/tut1.txt b/doc/tut1.txt index 746d11f01d..7c2a35f94a 100644 --- a/doc/tut1.txt +++ b/doc/tut1.txt @@ -1311,6 +1311,24 @@ integer. echo(person[0]) # "Peter" echo(person[1]) # 30 + # You don't need to declare tuples in a separate type section. + var building: tuple[street: string, number: int] + building = ("Rue del Percebe", 13) + echo(building.street) + + # The following line does not compile, they are different tuples! + #person = building + # --> Error: type mismatch: got (tuple[street: string, number: int]) + # but expected 'TPerson' + + # The following works because the field names and types are the same. + var teacher: tuple[name: string, age: int] = ("Mark", 42) + person = teacher + +Even though you don't need to declare a type for a tuple to use it, tuples +created with different field names will be considered different objects despite +having the same field types. + Reference and pointer types --------------------------- diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 408fbd9d43..433a79c5eb 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -794,8 +794,11 @@ when not defined(ENOENT): var ENOENT {.importc, header: "".}: cint proc removeFile*(file: string) {.rtl, extern: "nos$1", tags: [FWriteDir].} = - ## Removes the `file`. If this fails, `EOS` is raised. This does not fail - ## if the file never existed in the first place. + ## Removes the `file`. + ## + ## If this fails, `EOS` is raised. This does not fail if the file never + ## existed in the first place. Despite the name of this proc you can also + ## call it on directories, but they will only be removed if they are empty. if cremove(file) != 0'i32 and errno != ENOENT: OSError() proc execShellCmd*(command: string): int {.rtl, extern: "nos$1", @@ -1076,8 +1079,12 @@ proc rawRemoveDir(dir: string) = proc removeDir*(dir: string) {.rtl, extern: "nos$1", tags: [ FWriteDir, FReadDir].} = ## Removes the directory `dir` including all subdirectories and files - ## in `dir` (recursively). If this fails, `EOS` is raised. This does not fail - ## if the directory never existed in the first place. + ## in `dir` (recursively). + ## + ## If this fails, `EOS` is raised. This does not fail if the directory never + ## existed in the first place. If you need non recursive directory removal + ## which fails when the directory contains files use the `removeFile` proc + ## instead. for kind, path in walkDir(dir): case kind of pcFile, pcLinkToFile, pcLinkToDir: removeFile(path) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index a28c9a24e6..03a05aea19 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -153,15 +153,15 @@ proc TimeInfoToTime*(timeInfo: TTimeInfo): TTime {.tags: [].} ## them from the other information in the broken-down time structure. proc fromSeconds*(since1970: float): TTime {.tags: [].} - ## Takes a float which contains the number of seconds since 1970 and + ## Takes a float which contains the number of seconds since the unix epoch and ## returns a time object. proc fromSeconds*(since1970: int|int64): TTime = fromSeconds(float(since1970)) - ## Takes an in which contains the number of seconds since 1970 and + ## Takes an int which contains the number of seconds since the unix epoch and ## returns a time object. proc toSeconds*(time: TTime): float {.tags: [].} - ## Returns the time in seconds since 1970. + ## Returns the time in seconds since the unix epoch. proc `$` *(timeInfo: TTimeInfo): string {.tags: [].} ## converts a `TTimeInfo` object to a string representation. @@ -226,14 +226,9 @@ proc getDaysInMonth(month: TMonth, year: int): int = of mApr, mJun, mSep, mNov: result = 30 else: result = 31 -proc `-`*(interval: TTimeInterval): TTimeInterval = - for a, b in fields(result, interval): - a = -b - -proc toSeconds*(a: TTimeInfo, interval: TTimeInterval): float = - ## Returns the time the interval will be at that point in time. This - ## needs a time as well, because e.g. a month is not always the same - ## length. +proc toSeconds(a: TTimeInfo, interval: TTimeInterval): float = + ## Calculates how many seconds the interval is worth by adding up + ## all the fields var anew = a var newinterv = interval @@ -253,9 +248,6 @@ proc toSeconds*(a: TTimeInfo, interval: TTimeInterval): float = result += float(newinterv.seconds) result += newinterv.miliseconds / 1000 -proc toSeconds*(a: TTime, interval: TTimeInterval): float = - result = toSeconds(getGMTime(a), interval) - proc `+`*(a: TTimeInfo, interval: TTimeInterval): TTimeInfo = ## adds ``interval`` time. ## @@ -273,7 +265,12 @@ proc `-`*(a: TTimeInfo, interval: TTimeInterval): TTimeInfo = ## ## **Note:** This has been only briefly tested, it is inaccurate especially ## when you subtract so much that you reach the Julian calendar. - result = a + -interval + let t = toSeconds(TimeInfoToTime(a)) + let secs = toSeconds(a, interval) + if a.tzname == "UTC": + result = getGMTime(fromSeconds(t - secs)) + else: + result = getLocalTime(fromSeconds(t - secs)) when not defined(JS): proc epochTime*(): float {.rtl, extern: "nt$1", tags: [FTime].} @@ -742,4 +739,6 @@ when isMainModule: var t4 = getGMTime(fromSeconds(876124714)) # Mon 6 Oct 08:58:34 BST 1997 assert t4.format("M MM MMM MMMM") == "10 10 Oct October" - + # Interval tests + assert((t4 - initInterval(years = 2)).format("yyyy") == "1995") + assert((t4 - initInterval(years = 7, minutes = 34, seconds = 24)).format("yyyy mm ss") == "1990 24 10")