||
|_|
to make the use clearerwe 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:
Type aliases might be worth adding to keep signatures neat
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.
Jakub found a bug in variable capturing related to dynamically adding hooks? correct me if I am wrong
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.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing