Commit Graph

44 Commits

Author SHA1 Message Date
Qi Xiao
a3f4384495 Move all elvdocs into .d.elv files.
The elvdocs still use the old format (#elvdoc:fn or #elvdoc:var) for now, but
will be changed to "fn" and "var" forms soon.

Also remove the accidentally committed cmd/mvelvdoc. It has been used to perform
the conversion automatically but is not supposed to be committed.
2022-11-20 21:59:45 +00:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
59459793e3 pkg/persistent: Cons -> Conj.
Cons was a misnomer for the operation of adding an element at the end of a
vector. Follow Clojure's naming here and call this operation Conj.
2022-01-05 22:34:55 +00:00
Qi Xiao
38d4553833 Update assignment syntax in docs.
- Also remove the section for the legacy assignment syntax.

- Also add a paragraph to "eval" about upvalues.
2022-01-03 19:45:39 +00:00
Qi Xiao
097e32b375 pkg/eval/vals: Add ReprPlain, Repr without pretty-printing.
Also de-export NoPretty now that it is no longer needed.
2021-12-31 21:05:07 +00:00
Qi Xiao
7da4b58f2f Revise doc for the builtin module.
- Revise the introduction section.

- Link to the notes on commands taking value inputs from all such commands.

- Revise the doc on the "all" command.

- Revise references to the builtin module from the language reference.
2021-12-28 12:01:35 +00:00
Qi Xiao
560bd17c17 pkg/eval: Break up builtin_fn_container.go.
- range -> builtin_fn_num.go

- all, one, take, drop, count, order -> new builtin_fn_stream.go

- repeat -> builtin_fn_io.go

- compare -> builtin_fn_pred.go
2021-12-26 12:22:14 +00:00
Kurtis Rader
c59e01abfc Document the use of slurp with printf
A recent IM question, and subsequent discussion, resulted in @hhanche
commenting that if you need to explicitly move the output of `printf`
from the byte to the value stream you should use `slurp` rather than
`put` or `from-lines`. Include that insight in the `printf`
documentation.
2021-11-14 16:19:46 +00:00
Qi Xiao
5198e38f28 Advice against "useless use of put". 2021-11-07 23:36:56 +00:00
Qi Xiao
0571db69e2 Remove commands deprecated in 0.16.0, and deprecate dir-history. 2021-10-03 16:47:51 +01:00
Qi Xiao
9076934395 Remove most uses of the ioutil package.
https://golang.org/doc/go1.16#ioutil
2021-08-23 00:36:26 +01:00
Kurtis Rader
85c499f110 Lint cleanups
This change addresses issues reported by the `staticcheck` tool and a
couple reported by the `golint` tool. It also adds missing issue links
to a couple of entries in the release notes. This change deliberately
does not address these warnings since it is unclear whether the project
owner would prefer to suppress or address them:

    pkg/store/cmd.go:8:2: should not use dot imports (ST1001)
    pkg/store/db_store.go:10:2: should not use dot imports (ST1001)
    pkg/store/dir.go:8:2: should not use dot imports (ST1001)
2021-07-07 23:21:02 +01:00
Kurtis Rader
de9ae18fa8 Fix go vet error about unreachable code 2021-07-03 20:00:59 +01:00
Qi Xiao
4afab8804b Fixup for #1342. 2021-06-27 16:41:07 +01:00
Kurtis Rader
3da541c719 Other float64 cases that should be generalized
While pondering issue #1340 I looked at the other `case float64:`
blocks. This change generalizes the few places that need it.

Fixes #1340
2021-06-27 16:32:38 +01:00
Qi Xiao
f4cb00e618 pkg/eval: Test that all byte-outputting commands throw on write error. 2021-06-21 23:39:24 +01:00
Qi Xiao
657b73122f Change all builtin commands writing value output to surface ReaderGone.
Also replace (*Frame).OutputChan with (*Frame).ValueOutput, which returns a
small interface for writing to the value output that is also aware when the
reader is gone.
2021-06-18 00:14:59 +01:00
Qi Xiao
321a4e78eb Merge branch 'master' into reader-gone 2021-06-15 22:09:40 +01:00
Qi Xiao
3204e700ac Fixup for #1329 2021-06-13 22:54:47 +01:00
Kurtis Rader
9a576529a3 Replace ErrArgs with more specific errors
This also replaces the slightly awkward "arguments here" reason with
"argument count" as the "what" for a typical errs.ArityMismatch
exception. It also reformats most of the constructors so that the "what"
is on the same line. This makes `grep errs.ArityMismatch **.go` more
useful as a result.
2021-06-13 22:42:04 +01:00
Qi Xiao
067c809fc5 Change all builtin commands that write to byte output to surface write errors.
Also replace (*Frame).OutputFile with (*Frame).ByteOutput, which returns a
small interface for writing bytes and converts EPIPE to ReaderGone.
2021-06-11 22:20:27 +01:00
Qi Xiao
3e9e7ce5c8 In elvdoc for to-terminated, use slurp to show byte output that includes NUL. 2021-06-11 14:49:43 +01:00
Qi Xiao
46fa331dca Fixup for #1308. 2021-06-10 09:14:15 +01:00
Kurtis Rader
267e015bd6 Add from-terminated and to-terminated commands
This change makes feeding output to commands which handle NUL terminated
"lines" (e.g., `fzf -read0` or `xargs -0`) extremely fast compared to
using an explicit Elvish loop that does `print $val"\x00"`. Similarly for
handling input from commands that produce NUL terminated "lines" (e.g.,
`find . -print0`) compared to an Elvish loop using `read-upto "\x00"`.

Resolves #1070
Related #1053
2021-06-10 09:06:15 +01:00
Supreet
8f2accb0b9 File module with pipe function. Pipe command marked deprecated in compiler.go and builtin_fn_io.go
Prclose and pwclose with Deprecation marked in specific file. Give
feedback regarding the test cases.

File module now has prclose and pwclose

Wrote test cases for prclose and pwclose, need better test cases

Deprecation for prclose and pwclose marked in respective files.
2021-04-19 18:48:22 -04:00
Supreet
77c40b9abb Links file module, marks fopen and fclose deprecation in compiler.go
aand builtin_fn_io.go
2021-04-08 22:45:16 +01:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
e833b74aa4 Document %% in the elvdoc of printf. 2021-01-11 21:49:11 +00:00
Qi Xiao
ff69171c9d Fix typo: interprete -> interpret 2021-01-11 12:00:55 +00:00
Qi Xiao
75f10573d4 Address feedback of #1200. 2021-01-10 18:34:34 +00:00
Kurtis Rader
c67677fd8f Implement a printf builtin
There is more work to be done but this should address 99.9999% of the
expected uses of a `printf` builtin. Some corner cases which don't have
a POSIX analog, such as support for Elvish bool types will be implemented
in future changes.

Resolves #1132
2021-01-10 16:39:50 +00:00
Qi Xiao
672f097a2c pkg/eval: Break up value.go. 2020-10-10 22:28:13 +01:00
Qi Xiao
734eb955e2 pkg/eval: Use exported methods to access ports from builtin functions. 2020-10-10 22:28:13 +01:00
Qi Xiao
27fa20d65e pkg/eval: Move ChopLineEnding to the strutil package.
Also add unit tests.
2020-09-04 21:16:06 +01:00
Qi Xiao
9b2b33b429 pkg/eval: Move elvdoc comments before the implementations. 2020-08-16 18:46:29 +01:00
Kurtis Rader
cff229d9fa Remove two obsolete TODO comments and resolve one 2020-07-25 16:25:23 +01:00
Qi Xiao
e9b4035896 pkg/eval: Move the show command into the builtin namespace.
This will likely become a basic operation in future that can support more types
than exceptions, so putting it in the builtin namespace is appropriate.

Also remove the exc: module altogether as it contains nothing now. All the
introspection features are now implemented as fields of the exception values and
the reason values.
2020-06-30 22:36:27 +01:00
Qi Xiao
a4875de822 pkg/eval: Document {from to}-lines.
This fixes #1023.
2020-05-17 16:35:44 +01:00
Qi Xiao
5a09222cf7 pkg/eval: Implement read-line.
This fixes #975.
2020-05-06 23:03:49 +01:00
Qi Xiao
28a7ca5a15 Document read-upto.
This fixes #938.
2020-04-19 14:28:37 +01:00
Qi Xiao
41985123d3 Move all docs for builtins to the Go code. 2020-01-18 08:12:50 -05:00
Qi Xiao
b496591e7c pkg/eval: Slightly simplify implementation of fopen. 2020-01-06 22:17:48 +00:00
Qi Xiao
770904b2c0 pkg/eval: Introduce new builtin read-upto for reading up to a byte.
This fixes #831.
2019-12-30 23:11:41 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00