Nushell core team meeting 2023-03-29

Attendees

  • Darren
  • Antoine
  • JT
  • Michael
  • Keith
  • Jakub
  • Reilly
  • Stefan
  • fold squirrel
  • melmass
  • 1kinoti

Agenda

Discussed Topics

closure syntax change

  • Require ||
  • will break code and config for users in many places
  • Darren:
    • Vote to leave it as it brings clarity and consistency
  • Stefan
    • don't want to expose nu/new users to such a fundamental breaking change
    • could we make the blocks with out arguments still implicit but introduce some notion of mutable closure
  • JT
    • options for introducing a mut ||
    • compromise: revert for now but make design a priority

  • Justin in https://github.com/nushell/nushell/pull/8290#issuecomment-1483801462
    • alternative shorthand syntax for the empty closure arguments
  • Antoine:
    • Require an underscore in |_| to make the use clearer
  • Consensus:
    • accept the breaking change and don't revert
    • nushell value: clarity and readability of a finished script

Syntax for types

we currently have eaten our type syntax from whatever came from describe
very nominally typed: record<...>,list<...>

Can we use the actual syntax to describe the type: e.g. [int] (see rusts slice or array type)

JT's initial experiment PR https://github.com/nushell/nushell/pull/8665

# List
def goo [var: [int]] {}
# Record
def goo [var: {a: int}] {}
# Table
def goo [var: [{name: string, id: int}]] {}

Darren: we need to be stricter around table element types than we are currently
Jakbu: can we have partial record description, should structural subtyping to be explicit

JT is leaning towards implicitly allowing extra fields and the spec in the function to be just the minimal requirement

Stefan: data/type/pattern looking the same

Darren: record vs. table type syntax might already be confusing
Antoine: good example of that default values in a parameter list

def goo [var: {a: int} = {a: 3}] {}
def goo [var = {a: 3}] {}

Alternative syntax for table (Jakub)

def goo [var: Table(name: string, id: int)] {} 
def goo [var: Record(name: string, id: int)] {}

Make sure you can escalate to more stringent typing and also use the minimal expectation

Conclusion:

  • keep the pr draft for now
  • post some discussion points
  • notify 1kinoti (they were working towards record inner type annotation)

Type aliases might be worth adding to keep signatures neat

Pattern matching update

primitive types should be covered (mostly, easy to fill in)

record matching is structural subtyping (additional fields will be ignored)

top-to-bottom with break

list:
[$a $b] will constrain the number of arguments and binds to the names
missing: rest pattern for list.

if nothing matches $nothing/null is return (so it is not exhaustive by default)

Ignore value pattern exists for catch-all

Really moves the nu language forward! Good job JT!

duplicates some parsing logic

not yet added to some other places like closure arguments.

Scoping scars

Jakub found a bug in variable capturing related to dynamically adding hooks? correct me if I am wrong

Embedding the standard library and adding it as a prelude

Amtoine's big PR to land it: https://github.com/nushell/nushell/pull/8627

Pretty close, embedding and defining the prelude implemented

panics on interaction with the commands from the prelude

Decision: landing it right after the release (follow up with the removal PRs for the previous rust impls)

Observation: with help you can see some performance differences
Great opportunity to improve!

Wild guess: interacting with large records through many cell path accesses is slow as we clone liberally
-> profile and improve
-> is pattern matching also a potential performance win as all binding can happen at once.

PR's

Select a repo