From 261ff2735ff92edff44553cc49aed21007976ab6 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 6 Sep 2020 21:37:10 -0400 Subject: [PATCH] go/README.md --- go/README.md | 18 +++++++++++------- go/src/miller/dsl/cst/types.go | 9 ++++++++- go/todo.txt | 6 ++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/go/README.md b/go/README.md index ad5846c09..1ebb29b76 100644 --- a/go/README.md +++ b/go/README.md @@ -2,16 +2,20 @@ * This is not necessarily a full Go port of Miller. At the moment, it's a little spot for some experimentation. Things are very rough and very iterative and very incomplete. I don't commit to finishing a Go port but I very much hope to. * One reason Miller exists is to be a useful tool for myself and others; another is it's fun to write. At bare minimum, I'll re-teach myself some Go. -* In all likelihood, though, this will turn into a full port which will someday become Miller 6.0. +* In all likelihood, though, this will turn into a full port which will someday become Miller 6.0. As noted below, this will be a win both at the source-code level, and for users of Miller. * I hope to retain backward compatibility at the command-line level as much as possible. -* Benefits of porting to Go: - * The lack of a streaming (record-by-record) JSON reader in the C implementation ([issue 99](https://github.com/johnkerl/miller/issues/99)) is immediately solved in the Go implementation. - * The quoted-DKVP feature from [issue 266](https://github.com/johnkerl/miller/issues/266) will be easily addressed. - * String/number-formatting issues in [issue 211](https://github.com/johnkerl/miller/issues/211), [issue 178](https://github.com/johnkerl/miller/issues/178), [issue 151](https://github.com/johnkerl/miller/issues/151), and [issue 259](https://github.com/johnkerl/miller/issues/259) will be fixed during the Go port. - * I think some DST/timezone issues such as [issue 359](https://github.com/johnkerl/miller/issues/359) will be easier to fix using the Go datetime library than using the C datetime library - * The code will be easier to read and, I hope, easier for others to contribute to. * In the meantime I will still keep fixing bugs, doing some features, etc. in C on Miller 5.x -- in the near term, support for Miller's C implementation continues as before. +# Benefits of porting to Go + +* The [lack of a streaming (record-by-record) JSON reader](http://johnkerl.org/miller/doc/file-formats.html#JSON_non-streaming) in the C implementation ([issue 99](https://github.com/johnkerl/miller/issues/99)) is immediately solved in the Go implementation. +* Previously [arrays were not supported in the DSL](http://johnkerl.org/miller/doc/file-formats.html#Arrays); now they will be. +* [Flattening nested map structures to output records](http://johnkerl.org/miller/doc/file-formats.html#Formatting_JSON_options) was clumsy. Now, Miller will be a full JSON-to-JSON processor, if your inputs and outputs are both JSON; JSON input and output will be idiomatic. +* The quoted-DKVP feature from [issue 266](https://github.com/johnkerl/miller/issues/266) will be easily addressed. +* String/number-formatting issues in [issue 211](https://github.com/johnkerl/miller/issues/211), [issue 178](https://github.com/johnkerl/miller/issues/178), [issue 151](https://github.com/johnkerl/miller/issues/151), and [issue 259](https://github.com/johnkerl/miller/issues/259) will be fixed during the Go port. +* I think some DST/timezone issues such as [issue 359](https://github.com/johnkerl/miller/issues/359) will be easier to fix using the Go datetime library than using the C datetime library +* The code will be easier to read and, I hope, easier for others to contribute to. + # Efficiency of the Go port As I wrote [here](http://johnkerl.org/miller/doc/whyc.html) back in 2015 I couldn't get Rust or Go (or any other language I tried) to do some test-case processing as quickly as C, so I stuck with C. diff --git a/go/src/miller/dsl/cst/types.go b/go/src/miller/dsl/cst/types.go index 55c923135..afa8c32c8 100644 --- a/go/src/miller/dsl/cst/types.go +++ b/go/src/miller/dsl/cst/types.go @@ -89,7 +89,7 @@ type StatementBlockNode struct { // ================================================================ // This is for any right-hand side (RHS) of an assignment statement. Also, for // computed field names on the left-hand side, like '$a . $b' in mlr put '$[$a -// . $b]' = $x + $y'. +// . $b]' = $x + $y'. Also known as an "Rvalue". type IEvaluable interface { Evaluate(state *State) lib.Mlrval } @@ -108,3 +108,10 @@ func NewEvaluablePair(key IEvaluable, value IEvaluable) *EvaluablePair { Value: value, } } + +// ================================================================ +// This is for any left-hand side (LHS) of an assignment statement. +// Also known as an "Lvalue". +type IAssignable interface { + Assign(state *State, mlrval lib.Mlrval) error +} diff --git a/go/todo.txt b/go/todo.txt index 9a3e63298..50b87d31e 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -58,6 +58,10 @@ TOP OF LIST: o --headerless-csv-output o new non-lite DKVP reader/writer +* simplify the DSL + o Lvalue rule + o single assignment type with left-child implementing a new Assignable interface + * widen DSL coverage o begin/end blocks o indirect field names, at LHS and RHS @@ -68,6 +72,7 @@ MAYBE: * string index/slice access * string/array slices on assignment LHS -- ? +* push/pop/shift/unshift subroutines ---------------------------------------------------------------- GOCC UPSTREAMS: @@ -114,3 +119,4 @@ NITS/NON-IMMEDIATE: a big red flag though for things like the repeat verb (maybe *only* that one ...) ! clean up the AST API. ish! :^/ * defer reg_test/run until there is quite a bit more verb/dsl/io expansion +* doc: no boolish truthy falsy