hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0dff0b7458bec03afe552955b37c82561cbb0f86
parent 5bf82661b4989dd93db5cbe07655196f7c78f2b9
Author: Byron Torres <b@torresjrjr.com>
Date:   Wed,  8 Dec 2021 18:21:29 +0000

update for match binding "case let" syntax

Update code to compile with:
dd73e7df284e61e2fb1e371210dbe5956db84bcb harec

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mdatetime/arithmetic.ha | 2+-
Mdatetime/calendar.ha | 28++++++++++++++--------------
Mdatetime/format.ha | 18+++++++++---------
3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/datetime/arithmetic.ha b/datetime/arithmetic.ha @@ -66,7 +66,7 @@ export fn hop(dt: datetime, pp: period...) datetime = { // // TODO: // How to handle overflows and predictability with cal-arithm in general? -export fn add(m: datetime, flag: int, pp: period...) datetime = { +export fn add(dt: datetime, flag: int, pp: period...) datetime = { // TODO for (let i = 0z; i < len(pp); i += 1) { const p = pp[i]; diff --git a/datetime/calendar.ha b/datetime/calendar.ha @@ -26,7 +26,7 @@ export fn epochal(dt: *datetime) int = { // Use calc_epochal_from_*? How to avoid recursion? // When to rely on input validation? abort("TODO"); - case e: int => + case let e: int => return e; }; }; @@ -40,7 +40,7 @@ export fn era(dt: *datetime) int = { }; dt.date.era = calc_era(dt.date.year: int); return dt.date.era: int; - case a: int => + case let a: int => return a; }; }; @@ -57,7 +57,7 @@ export fn year(dt: *datetime) int = { dt.date.month = ymd.1; dt.date.day = ymd.2; return dt.date.year: int; - case y: int => + case let y: int => return y; }; }; @@ -74,7 +74,7 @@ export fn month(dt: *datetime) int = { dt.date.month = ymd.1; dt.date.day = ymd.2; return dt.date.month: int; - case y: int => + case let y: int => return y; }; }; @@ -91,7 +91,7 @@ export fn day(dt: *datetime) int = { dt.date.month = ymd.1; dt.date.day = ymd.2; return dt.date.day: int; - case y: int => + case let y: int => return y; }; }; @@ -105,7 +105,7 @@ export fn weekday(dt: *datetime) int = { }; dt.date.weekday = calc_weekday(dt.date.epochal: int); return dt.date.weekday: int; - case y: int => + case let y: int => return y; }; }; @@ -129,7 +129,7 @@ export fn yearday(dt: *datetime) int = { dt.date.day: int, ); return dt.date.yearday: int; - case yd: int => + case let yd: int => return yd; }; }; @@ -157,7 +157,7 @@ export fn isoweekyear(dt: *datetime) int = { dt.date.weekday: int, ); return dt.date.isoweekyear: int; - case iwy: int => + case let iwy: int => return iwy; }; }; @@ -177,7 +177,7 @@ export fn week(dt: *datetime) int = { dt.date.weekday: int, ); return dt.date.week: int; - case w: int => + case let w: int => return w; }; }; @@ -205,7 +205,7 @@ export fn isoweek(dt: *datetime) int = { dt.date.yearday: int, ); return dt.date.isoweek: int; - case iw: int => + case let iw: int => return iw; }; }; @@ -220,7 +220,7 @@ export fn hour(dt: *datetime) int = { match (dt.time.hour) { case void => abort("TODO"); - case h: int => + case let h: int => return h; }; }; @@ -230,7 +230,7 @@ export fn min(dt: *datetime) int = { match (dt.time.min) { case void => abort("TODO"); - case m: int => + case let m: int => return m; }; }; @@ -240,7 +240,7 @@ export fn sec(dt: *datetime) int = { match (dt.time.sec) { case void => abort("TODO"); - case s: int => + case let s: int => return s; }; }; @@ -250,7 +250,7 @@ export fn nsec(dt: *datetime) int = { match (dt.time.nsec) { case void => abort("TODO"); - case n: int => + case let n: int => return n; }; }; diff --git a/datetime/format.ha b/datetime/format.ha @@ -65,7 +65,7 @@ fn get_max_n_digits(iter: *strings::iterator, n: uint) (int | errors::invalid) = let r: rune = match (strings::next(iter)) { case void => break; - case r: rune => + case let r: rune => yield r; }; if (!ascii::isdigit(r)) { @@ -80,7 +80,7 @@ fn get_max_n_digits(iter: *strings::iterator, n: uint) (int | errors::invalid) = }; }; return match (strconv::stoi(strio::string(bufstr))) { - case res: int => + case let res: int => yield res; case => yield errors::invalid; @@ -91,7 +91,7 @@ fn eat_one_rune(iter: *strings::iterator, needle: rune) (uint | errors::invalid) let s_r = match (strings::next(iter)) { case void => return errors::invalid; - case r: rune => + case let r: rune => yield r; }; if (s_r == needle) { @@ -125,7 +125,7 @@ export fn strptime(format: str, s: str, dt: *datetime) (void | errors::invalid) let format_r: rune = match (strings::next(&format_iter)) { case void => break; - case r: rune => + case let r: rune => yield r; }; @@ -138,7 +138,7 @@ export fn strptime(format: str, s: str, dt: *datetime) (void | errors::invalid) let s_r = match (strings::next(&s_iter)) { case void => return errors::invalid; - case r: rune => + case let r: rune => yield r; }; if (s_r != format_r) { @@ -189,7 +189,7 @@ export fn strptime(format: str, s: str, dt: *datetime) (void | errors::invalid) }; const hour = get_max_n_digits(&s_iter, max_n_digits); dt.time.hour = match (hour) { - case hour: int => + case let hour: int => yield if (hour > 12) { yield clamp_int(hour - 12, 1, 12); } else { @@ -257,7 +257,7 @@ export fn strptime(format: str, s: str, dt: *datetime) (void | errors::invalid) eat_one_rune(&s_iter, '\t')?; case 'u', 'w' => dt.date.weekday = match (get_max_n_digits(&s_iter, 1)) { - case i: int => + case let i: int => yield if (format_r == 'w') { yield if (i == 0) { yield 7; @@ -354,7 +354,7 @@ export fn strptime(format: str, s: str, dt: *datetime) (void | errors::invalid) // TODO: Localization // Time dt.time.hour = match (get_max_n_digits(&s_iter, 2)) { - case hour: int => + case let hour: int => yield if (hour > 12) { yield clamp_int(hour - 12, 1, 12); } else { @@ -455,7 +455,7 @@ export fn fmttime(h: io::handle, format: str, dt: *datetime) (size | errors::inv let r: rune = match (strings::next(&iter)) { case void => break; - case r: rune => + case let r: rune => yield r; };