all repos — min @ 2e572bf7fe13d927581f2371a19d9b984b9d3553

A small but practical concatenative programming language.

Added dsput! and dspost!, docs
h3rald h3rald@h3rald.com
Sat, 09 Jan 2021 10:23:51 +0000
commit

2e572bf7fe13d927581f2371a19d9b984b9d3553

parent

c087434a201a518167dca3247260ae4a2077802c

3 files changed, 22 insertions(+), 1 deletions(-)

jump to
M minpkg/lib/min_dstore.nimminpkg/lib/min_dstore.nim

@@ -108,6 +108,10 @@ i.dset(data, collection, newDict(i.scope))

var cll = i.dget(data, collection) i.dset(cll, id, d) i.push ds + + def.symbol("dspost!") do (i: In): + i.pushSym "dspost" + i.pushSym "pop" def.symbol("dsput") do (i: In): let vals = i.expect("dict", "'sym", "dict:datastore")

@@ -125,6 +129,10 @@ i.dset(data, collection, newDict(i.scope))

var cll = i.dget(data, collection) i.dset(cll, id, d) i.push ds + + def.symbol("dsput!") do (i: In): + i.pushSym "dsput" + i.pushSym "pop" def.symbol("dsdelete") do (i: In): let vals = i.expect("'sym", "dict:datastore")
M next-release.mdnext-release.md

@@ -5,4 +5,5 @@ * Added **union**, **intersection**, **difference**, **symmetric-difference**, **one?** symbols to **seq** module.

* Fixed compilation for loaded files and assets. * Refacored code to satisfy nimble package structure. * Now caching required modules so that their code is executed only once. -* Added **line-info** symbol returning a dictionary containing the current filename, line and column numbers.+* Added **line-info** symbol returning a dictionary containing the current filename, line and column numbers. +* Added **dsdelete!**, **dspost!**, **dsput!**, **dswrite!**.
M site/contents/reference-dstore.mdsite/contents/reference-dstore.md

@@ -7,6 +7,9 @@

{#op||dsdelete||{{dstore}} {{sl}}||{{dstore}}|| Removes an item from the datastore {{dstore}}. The item is uniquely identified by {{sl}}, which contains the collection containing the item and the item id, separated by a forward slash (/). Puts the reference to the modified datastore back on tbe stack. #} + +{#op||dsdelete!||{{dstore}} {{sl}}||{{none}}|| +Same as `dsdelete`, but doesn't leave anything on the stack. #} {#op||dsget||{{dstore}} {{sl}}||{{d}}|| Retrieves item {{d}} from datastore {{dstore}}. {{d}} is retrieved by specifying {{sl}}, which contains the collection containing the item and the item id, separated by a forward slash (/).

@@ -18,10 +21,16 @@

{#op||dspost||{{dstore}} {{sl}} {{d}}||{{dstore}}|| Adds the dictionary {{d}} to the datastore {{dstore}} inside collection {{sl}}, generating and adding a unique **id** field to {{d}}. If the collection {{sl}} does not exist it is created. Puts the reference to the modified datastore back on tbe stack. #} + +{#op||dspost!||{{dstore}} {{sl}} {{d}}||{{none}}|| +Same as `dspost`, but doesn't leave anything on the stack. #} {#op||dsput||{{dstore}} {{sl}} {{d}}||{{dstore}}|| Adds the dictionary {{d}} to the datastore {{dstore}}. {{sl}} contains the collection where {{d}} will be placed and the id of {{d}}, separated by a forward slash (/). If the collection {{sl}} does not exist it is created. Puts the reference to the modified datastore back on tbe stack. #} + +{#op||dsput!||{{dstore}} {{sl}}||{{none}}|| +Same as `dsput`, but doesn't leave anything on the stack. #} {#op||dsquery||{{dstore}} {{sl}} {{q}}||({{d0p}})|| > Retrieves a quotation of dictionaries from the collection {{sl}} of datastore {{dstore}} obtained by applying {{q}} as a filter to each item of the collection, picking only the elements that match the filter.

@@ -42,3 +51,6 @@ {#op||dswrite||{{dstore}}||{{dstore}}||

Writes the contents of the datastore {{dstore}} to the filesystem. #} +{#op||dswrite!||{{dstore}}||{{none}}|| +Same as `dswrite`, but doesn't leave anything on the stack. #} +