Skip to content

v0.3.0

Latest

Choose a tag to compare

@ilyash-b ilyash-b released this 28 Nov 07:11

New features

  • Add assert(val, pattern, Fun)
  • Add parallel(*funcs)
  • Add peach(Eachable1, ...)
  • Add each_ik_val(Eachable, Fun)
  • Add debug_enabled(facility)
  • Add paginate(body)
  • Add after_first(Str, Str)
  • Add before_last(Str, Str)
  • Add experimental RecIter for recursive iteration of data structures.
  • Add peek(MapIter)
  • Support negative range start in [](Arr, NumRange) and [](Str, NumRange)
  • Add =~(Any, Sfx, MatchContext) for Arr suffixes
  • Result(Fun) -> Result(Fun, catch=Exception) - only catch given exceptions
  • Invoke main in sub-namespaces, enabling local help/usage for nested CLI namespaces
  • Arr return values rendered as tables: now column order and name can be set via rows.meta()[Table]
  • Add colored TTY output to error(), warn(), log(), etc. Respects NO_COLOR. Override with NGS_COLORS=category:N,....
  • Add RegExp field newline returning the effective newline convention (a C_PCRE2_NEWLINE_* value).
  • Add RegExp fields pattern and arg_options
  • Add code(RegExp)
  • Add error_code field (numeric PCRE2 error code) to RegExpCompileFail exceptions.
  • Add deep_copy(x) - recursive copy. Throws MethodNotFound for unsupported types. Cyclic structures are not supported.
    • Add DeepCopyable - inherit to have default deep_copy() implementation.
  • Add instantiate_param_dflt(x) - per-call instantiation of parameter defaults when the argument is not provided.
    • Simple data structures are copied.
    • Some can not be reasonably copied and left as is: Type, Block, MultiMethod, CleanupPolicy, Fun, Namespace
  • Add Holder - a mutable container
  • Add get(Holder)
  • Add get_and_update(Holder, cb)
  • Add sleep(Int), sleep(Real), sleep(Int, Int), sleep(Duration) and c_nanosleep(tv_sec, tv_nsec)
  • Add c_waitpid(pid, options) and C_WNOHANG
  • Add finished(ProcessesPipeline)
  • Add VS Code extension: syntax highlighting, comment toggling, bracket matching (vscode/)
  • Add c_waitid(idtype, id, options), C_P_*, C_WEXITED, C_WSTOPPED, C_WCONTINUED, C_WNOWAIT, C_CLD_*
  • Add intersect(Set, Set) and intersect(Arr, Arr) - intersection
  • Add validate(val, param:Str, pattern) - for argument checking
  • Add validate(a:Hash, params_patterns:Hash) - for checking multiple arguments, typically args()
  • Add write_to(data, target) - same as write(target, data)
  • Add echo_to(data, target) - same as echo(target, data)
  • Add store_to(data, target, encode_hints) - same as store(target, data, encode_hints)
  • Add can(val, fun) - check whether fun(val) throws
  • Add MultiHash - MultiMap
  • Add URI, URL, URN, URLPath, QueryParams
  • Add in(IPNet, IPNet) - check whether a subnet is within another subnet
  • Add in(IPNet, Arr) - check whether a subnet is within one of the given subnets
  • Add c_sockaddr_in(Str, Int) and c_sockaddr_in(IPAddr, Int) - IPv4 socket address
  • Add .(c_sockaddr_un, Str) - sun_family and sun_path fields
  • Add .(c_sockaddr_in, Str) - sin_family, sin_port and sin_addr fields
  • Add .(c_sockaddr, Str) - sa_family field
  • Add C_AF_UNIX and C_AF_INET - address families, as in sa_family
  • Add c_getsockname(Int) - local address of a socket (GETSOCKNAME(2))
  • Add getsockname(Int) - local address of a socket
  • Add getsockopt(Int, Int, Int)
  • Add accept(Int)
  • Add recvfrom(Int, Int, Int=0) - returns [data, address]
  • Add c_fcntl(Int, Int, Int)
  • Add FCNTL(2) constants C_F_*, C_FD_CLOEXEC, C_O_NONBLOCK, C_O_APPEND
  • Add c_getsockopt(Int, Int, Int)
  • Add GETSOCKOPT(2) constants C_SOL_SOCKET, C_SO_ERROR, C_SO_TYPE, C_SO_RCVBUF
  • Add c_accept(Int)
  • Add c_recvfrom(Int, Int, Int)
  • Add C_INT_MAX
  • Add experimental net::TcpClient
  • Add read(net::TcpClient)
  • Add =~(CommandsPipeline, CommandsPipeline)
  • Add experimental {Each(K): V} pattern
  • Add experimental Test
  • Add experimental DynVar
  • Add experimental DynVar(Type)
  • ns { } binds DynVar(Namespace) to the namespace being defined
  • Test(Str, Fun) inside ns { } becomes the namespace's member
  • Add decode(Str, Str), decode(Str, Int) and decode(Str, Bool)

Fixes and improvements

  • Fix broken parameter type links on namespace pages of the generated documentation
  • Fix subcommand exit code
  • Fix f(**x) on non-Hash throws InvalidArgument now instead of crashing
  • Fix Hash pattern with a pattern key throwing on non-Str keys
  • Fix escape_bash() losing backslashes; it now single-quotes, without external programs (faster log:)
  • Faster compilation of large files
  • retry() sleeps in-process instead of running external sleep
  • Fix for(i;n) and for(init;cond;incr) loops over 32 KB of bytecode aborting the compiler
  • Add peek(RangeIter) - fixes skip(pattern) on RangeIter
  • Fix Str(HashIter) always showing index 0
  • Fix # between switch/cond syntax error
  • Workaround for broken TmpDir
  • Migrate from EOL PCRE1 (libpcre3-dev) to PCRE2 (libpcre2-dev). Regex constants are now C_PCRE2_* (C_PCRE_* removed). RegExp#newline field.
  • Fix regex patterns containing a NUL byte being silently truncated at the NUL.
  • Fix IPNet(ip:Int, mask:Int) - it always threw FieldNotFound.
  • Fix IPNet(Str) throwing FieldNotFound instead of InvalidArgument on a non-integer mask.
  • Remove the regex n flag, it never worked.
  • Fix assert(Program) false positives on paths with slashes.
  • decompile() going out of sync and related fixes.
  • Adding a field to a type is now thread safe.
  • Table multi-row cells - elements are now separated by ---.
  • Fix native print_exception()
  • Fix =~(Any, Pfx, MatchContext) path tracking
  • Fix =~(Any, Transformed, MatchContext) context passing
  • Fix segfault F f(*args) and F f(**kwargs) called with f(*[])
  • Fix fetch(url:Str, decode_hints) ignoring decode_hints
  • Fix fetch(url:Str, decode_hints) reading HTTP://... (uppercase scheme) as a file
  • Fix break and continue in a switch/cond/match arm not reaching the enclosing loop. Fixes ngs my.ngs cmd -- arg ... failing with KeyNotFound.
  • Fix switch/cond/match with more than 16 arms aborting the compiler
  • Fix $* as a redirect target (e.g. $(echo x > $*a)) aborting the compiler. It is now a syntax error.
  • Fix Arr(ArrLike) returning a copy instead of the underlying array
  • Empty source (compile(""), an empty file) is now an empty program, not CompileFail
  • Fix %(...) and other subshell literals being a syntax error as a parameter pattern
  • Fix return, break and continue inside method call arguments, named arguments, array and hash literals, assignments, string interpolation and switch arm values corrupting the stack
  • Fix MatchSuccess from a RegExp match dropping trailing capture groups that did not participate. They are now null in matches (and present in positions), like leading and middle ones. matches/positions length now always equals the pattern's group count + 1, which also affects get(MatchSuccess, idx, dflt) (now null, not dflt, for such a group) and positional captures after a RegExp in composite patterns.
  • Fix code constructs at the top level of a file (commands syntax).
  • Fix $*NAME in commands (and $**NAME in %{...}) syntax
  • Fix huge Int indexes wrapping instead of throwing ([](Arr, Int), ord() etc.)
  • Fix Int(s:Str) silently wrapping numbers outside INT_MIN..INT_MAX; it now throws InvalidArgument
  • Int(s:Str) now accepts trailing whitespace
  • Fix Real(s:Str) with a negative number and a fraction (Real("-1.5") was -0.5, Real("-0.5") was 0.5)
  • Real(s:Str) now accepts surrounding whitespace and rejects a sign or whitespace after the dot (Real("1.-5"), Real("1. 5"))
  • Fix split(Str, Str, Int) with max_parts=1 splitting fully
  • Fix compile() output not being reproducible
  • Fix retry() running success_predicate after a swallowed RetryAssertFail
  • Fix .=(NormalType, Str, Any) (T.user = v) evaluating to the field name instead of v
  • Fix and improve documentation
  • Document cd: and ok_sig: command options
  • Fix ok_sig: command option failing commands that exit normally, including with exit code 0
  • Document null range end in [] and []= with NumRange, null range start/end with PredRange
  • Fix encode_base64() truncating its input at the first NUL byte
  • Fix encode_base64() returning a trailing newline on macOS
  • Unhardcode 10000 lines limit for source files
  • Support --dashed-command-line-switches
  • Fix ==(Lock, Lock) and ==(Cond, Cond)
  • Fix concurrent wait(Process) calls on the same process failing to join its threads
  • Fix finished(Process) returning false for an exited process until wait()
  • Fix kill(Process) and kill(ProcessesPipeline) signalling an exited process
  • kill(ProcessesPipeline) now returns the pipeline, like wait(ProcessesPipeline)
  • Str(RegExp) is now returning the literal (/a+/i), not <RegExp>
  • Document regular expression flags (/myregex/FLAGS)
  • Fix repeated regular expression flag (/abc/ii) compiling with wrong options
  • Document $[...]
  • Document guard in catch clauses
  • Document that a Fun default value (dflt etc.) is called to get the value
  • Fix decode(Str, AnyOf) throwing MethodNotFound for a type without decode()
  • Fix main rejecting arguments for parameters with AnyOf

Breaking changes

  • decode(Str, Type) now throws DecodeFail, not MethodNotFound, for a type without decode()
  • Parameter defaults are now instantiated per call through instantiate_param_dflt(DEFAULT_FROM_DEFINITION), which can throw MethodNotFound.
  • Fix copy(Set), Set + Set and inspect(Set) hardcoding Set instead of the value's exact type.
  • Set + Set now throws InvalidArgument unless both operands are of the same type.
  • A :: (pipeline) option after a : (command) option or after | is now a syntax error.
  • wait(Process) on a failed process throws ProcessFail on every call, not only the first.
  • Remove accept(Int, c_sockaddr) and c_accept(Int, c_sockaddr_un). Use accept(Int).
  • Remove recvfrom(Int, Int, Int, c_sockaddr) and c_recvfrom(Int, Int, Int, c_sockaddr_un) in favor of recvfrom(Int, Int, Int=0), which returns [data, address].
  • id of net::Connection is now a process-wide unique Str, also on client connections.