Skip to content

Commit

Permalink
(docs) replace **NOTE** with :::info in docs (#421)
Browse files Browse the repository at this point in the history
* docs: replace NOTE with info

* docs: normalize text casing and add 'Note' prefixes

---------

Co-authored-by: Achal <[email protected]>
  • Loading branch information
spudoodle and spudoodle authored Dec 27, 2024
1 parent 3cd369d commit c602896
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 27 deletions.
36 changes: 30 additions & 6 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ After adding the script tag with the main file, you can use Scheme code within a
</script>
```

**NOTE**: Only the core of LIPS is written in JavaScript, almost half of it it's written in Scheme.
:::info

Only the core of LIPS is written in JavaScript, almost half of it it's written in Scheme.
So if you want to load the standard library (to have full LIPS), you should use `bootstrap` or
`data-bootstrap` attribute that will load it for you. You can optionally specify the location of the
file.

:::

```html
<script type="text/x-scheme" bootstrap="https://cdn.jsdelivr.net/npm/@jcubic/lips@beta/dist/std.xcb">
(let ((what "world")
Expand All @@ -48,7 +52,11 @@ file.
`xcb` file is simple binary format that LIPS uses to speed up parsing the the code. You can also use
`.scm` file or `.min.scm` file that may be little bit bigger.

**NOTE** The `bootstrap` attribute can also be included on main script tag with the JavaScript file.
:::info

The `bootstrap` attribute can also be included on main script tag with the JavaScript file.

:::

### Running External Scheme Code

Expand Down Expand Up @@ -141,9 +149,13 @@ and execute the script by providing the name:
./script.scm
```
**NOTE**: by default most systems don't execute files in current directory so you need to provide `./` in front.
:::info
By default most systems don't execute files in current directory so you need to provide `./` in front.
You can change that if you add dot (current working directory) to the `$PATH` environment variable:
:::
```bash
export $PATH=".:$PATH"
```
Expand All @@ -156,9 +168,13 @@ If you prefer to install lips locally instead of globally you can use this sheba
(print (string-append "Hello " what)))
```
**NOTE**: if you run this code outside of [Node.js project](#nodejs-project) npx will install the
:::info
If you run this code outside of [Node.js project](#nodejs-project) npx will install the
package before execution.
:::
### Node.js project
After you have installed LIPS you can create a new Node.js project and write LIPS Scheme code
Expand Down Expand Up @@ -186,10 +202,14 @@ and use them in LIPS Scheme:
;; ==> #("01" "02" "03" "04" "05" "06" "07" "08" "09" "10")
```
**NOTE**: [braces](https://www.npmjs.com/package/braces) is a popular package to expand bash like
:::info
[braces](https://www.npmjs.com/package/braces) is a popular package to expand bash like
expressions, it's used as [deep dependency for
TailwindCSS](https://shubhamjain.co/2024/02/29/why-is-number-package-have-59m-downloads/).
:::
## Executing LIPS prammatically
You can also execute LIPS from JavaScript:
Expand Down Expand Up @@ -242,7 +262,11 @@ The Interpreter have a method `exec` that work the same as thhe one exported fro
### Bootstrapping
**Note**: that you also need to bootstrap the standard library to have fully working Scheme system.
:::info
Note that you also need to bootstrap the standard library to have fully working Scheme system.
:::
```javascript
await interpreter.exec(`(let-env lips.env.__parent__
Expand Down
6 changes: 5 additions & 1 deletion docs/docs/lips/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ specification](/docs/scheme-intro/what-is-lisp#standards) in a form of a functio

You can use this function in LIPS with version 5 and 7 to get R<sup>5</sup>RS or R<sup>7</sup>RS.

**NOTE**: that some of the functions from R<sup>5</sup>RS may have features of R<sup>7</sup>RS since
:::info

Note that some of the functions from R<sup>5</sup>RS may have features of R<sup>7</sup>RS since
some of them got additional arguments. R<sup>n</sup>RS is backward compatible.

:::

You can use this function with `eval` or `let-env`:

```scheme
Expand Down
12 changes: 10 additions & 2 deletions docs/docs/lips/extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ To see the expansion of syntax extension you can use `lips.parse`:
;; ==> #((list 10 10))
```

**NOTE**: The `lips.parse` function return array/vector of parsed expressions.
:::info

The `lips.parse` function return array/vector of parsed expressions.

:::

There are 3 types of syntax extensions `SPLICE`, `LITERAL`, and `SYMBOL`. You define them using
constants defined in `lips.specials` object.
Expand Down Expand Up @@ -286,9 +290,13 @@ extension that return line number:
;; ==> (12 13)
```

**NOTE**: The provided output will be exactly the same, when the code will be put into a single file
:::info

The provided output will be exactly the same, when the code will be put into a single file
and executed.

:::

### Standard input
In syntax extensions `current-input-port` points into the parser stream. So you can implement
your own parser logic. The best way to implement custom syntax extension (that works similar to
Expand Down
18 changes: 15 additions & 3 deletions docs/docs/lips/functional-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ Let's create a macro that will count how many times the code is executed:
(console.timeEnd ,label))))))
```

**NOTE** `#:result` expression is [auto gensym](/docs/lips/extension#autogensyms) as one of
:::info

`#:result` expression is [auto gensym](/docs/lips/extension#autogensyms) as one of
builtin [syntax extensions](/docs/lips/extension#syntax-extensions).

:::

We can use this code to make sure that the function has been executed only once:

```scheme
Expand Down Expand Up @@ -271,7 +275,11 @@ The code removes the zeros from list before applying the fraction that will thro
LIPS define function `reduce` that is an alias to standard Scheme procedure `fold-right` and fold that is the same
as `fold-left`. Both procedures works similarly. The take a procedure and a list and reduce it into a single value.

**NOTE** the reduce works differently than in JavaScript, the callback function get accumulator in last argument.
:::info

The reduce works differently than in JavaScript, the callback function get accumulator in last argument.

:::


```scheme
Expand Down Expand Up @@ -308,9 +316,13 @@ Same as reduce it accept more than one list:
;; ==> (1 "foo" 2 "bar" 3 "baz" 4 "quuz")
```

**NOTE**: here we use `cons` to create a list, `cons` construct the list in reverse order so `reduce`
:::info

Here we use `cons` to create a list, `cons` construct the list in reverse order so `reduce`
start from first element and `fold` is reversed:

:::

```scheme
(reduce (lambda (item acc)
(print acc)
Expand Down
56 changes: 46 additions & 10 deletions docs/docs/lips/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ There is also another function to check type of number:
;; ==> Expecting bigint got complex in expression `let`
```

**NOTE**: In LIPS all integers are BigInts.
:::info

In LIPS all integers are BigInts.

:::

The last typecking function is `typecheck-args` that check if all arguments are of same type.

Expand Down Expand Up @@ -478,9 +482,13 @@ This is equivalent of:
(document.querySelector "body")
```

**NOTE** the only time when you still need `.` function is when you want to get the property of
:::info

The only time when you still need `.` function is when you want to get the property of
object returned by expression.

:::

```scheme
(let ((style (. (document.querySelector "body") 'style)))
(set! style.background "red"))
Expand All @@ -490,7 +498,11 @@ Here we get a [style object](https://developer.mozilla.org/en-US/docs/Web/API/HT
from [the DOM node](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) without sorting the
reference to the DOM node.

**NOTE** because dot notation in symbols is not special syntax you can use code like this:
:::info

Because dot notation in symbols is not special syntax you can use code like this:

:::

```scheme
(let ((x #(1 2 3)))
Expand Down Expand Up @@ -548,7 +560,7 @@ in JavaScript:

:::info

the values in JavaScript are different because they have different representation in LIPS.
The values in JavaScript are different because they have different representation in LIPS.

:::

Expand Down Expand Up @@ -658,9 +670,13 @@ You can also use quasiquote with object literals:
;; ==> &(:name "Jack" :age 22)
```

**NOTE**: because of the construction of [syntax extensions](/docs/lips/extension#syntax-extensions) and
:::info

Because of the construction of [syntax extensions](/docs/lips/extension#syntax-extensions) and
[quasiquote](/docs/scheme-intro/data-types#quasiquote), you can't splice a list inside object literals:

:::

```scheme
(let ((args (list ':foo "lorem" ':bar "ipsum")))
`&(,@args))
Expand Down Expand Up @@ -699,9 +715,13 @@ The same you can use macros that will return LIPS Scheme code:
;; ==> &(:foo "lorem" :bar "ipsum")
```

**NOTE**: this example macro works the same `object` is it's not that useful, but you can create
:::info

This example macro works the same `object` is it's not that useful, but you can create
more complex code where you will be able to generate object literals with splicing.

:::

Object literal also have shorthad notation:

```scheme
Expand Down Expand Up @@ -773,7 +793,11 @@ automatic async/await you can use `(await)` procedure
;; ==> Scheme is Super Fun
```

**NOTE** Inside `then` lambda promises are still automagically resolved.
:::info

Inside `then` lambda promises are still automagically resolved.

:::

```scheme
(--> '>(Promise.resolve "hello")
Expand Down Expand Up @@ -853,7 +877,11 @@ You can also define `finally` without `catch`:
;; ==> nasty
```

**NOTE** the order of execution is not expected, but it may change in the future.
:::info

The order of execution is not expected, but it may change in the future.

:::

LIPS also define R<sup>7</sup>RS guard `procedure` that is just a macro that use try..catch behind the scene:

Expand Down Expand Up @@ -898,9 +926,13 @@ float if used on normal vector:
;; ==> #(0.5 0.3333333333333333 0.25 0.2)
```

**NOTE**: be careful when using iterator protocol because any function side Scheme can return a promise. If you would change
:::info

Be careful when using iterator protocol because any function side Scheme can return a promise. If you would change
quoted object literal `` `&() `` with longhand `object` you will get an error because `object` is async.

:::

You can abstract the use of iteration protocol with a macro, but to have real `yield` keyword like
syntax you need `call/cc`.

Expand Down Expand Up @@ -1063,9 +1095,13 @@ $ lips -c file.xcb
Will create `file.xcb` in same directory. For smaller files it make not have a difference when
loading `.xcb` or `.scm` files.
**NOTE**: directives `#!fold-case` and `#!no-fold-case` work only inside the parser and they are
:::info
Directives `#!fold-case` and `#!no-fold-case` work only inside the parser and they are
treated as comments, so you can't compile the code that have those directives.
:::
## loading SRFI
In LIPS, you can use `(load)` with path absolute or relative to the directory of the executed LIPS
Expand Down
12 changes: 10 additions & 2 deletions docs/docs/scheme-intro/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ You can call this macro to create alist based on its arguments:
;; ==> (("foo" . 10) ("bar" . 20) ("baz" . 30))
```

**Note** recursive call is inside quote and only argument is unquoted. This is required since
:::info

Recursive call is inside quote and only argument is unquoted. This is required since
recursive macro call needs to appear in the expansion. If you call macro recursively and don't return
macro call as output list you will end up in ifninite recursive call.

:::

You can see the macro will expand with macroexpand:

```scheme
Expand Down Expand Up @@ -543,9 +547,13 @@ The output may be different depending on implementation.
By default Scheme `syntax-rules` macros don't allow creating anaphoric macros like lisp macro do.
But with [SRFI-139](https://srfi.schemers.org/srfi-139/srfi-139.html) you can implement such macros.

**Note**: that not every scheme implementation support this <abbr title="Scheme Request For
:::info

Note that not every scheme implementation support this <abbr title="Scheme Request For
Implementation">SRFI</abbr>.

:::

Here is example of `awhen` anaphoric macro that use this <abbr title="Scheme Request For
Implementation">SRFI</abbr>:

Expand Down
7 changes: 6 additions & 1 deletion docs/docs/scheme-intro/next-step.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ If you want to learn more about lisp macros, there are two great books:

## Scheme hygienic macros

**NOTE**: Unfortunately, there are no good books about Scheme hygienic macros. But you can read
:::info

Unfortunately, there are no good books about Scheme hygienic macros. But you can read
those documents:

:::

* [Writing Powerful Macros in Scheme](https://github.com/mnieper/scheme-macros) by [Marc
Nieper-Wißkirchen](https://github.com/mnieper).
* [JRM’s Syntax-rules Primer for the Merely Eccentric](http://www.phyast.pitt.edu/~micheles/syntax-rules.pdf)
Expand Down
12 changes: 10 additions & 2 deletions docs/docs/scheme-intro/what-is-lisp.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ write the same expression as:

Is that in Lisp there are no operators. The above expression is just procedure application (function call).

**NOTE**: We will use procedure and function interchangeably in this tutorial.
:::info

We will use procedure and function interchangeably in this tutorial.

:::

Plus is not an operator, only a symbol that point into an addition procedure that is executed. So in
fact in other programming languages this should be written as:
Expand Down Expand Up @@ -93,10 +97,14 @@ scheme>

And you can type your scheme code and press enter to execute it (it's often called evaluation of the expression).

**NOTE**: you can run [LIPS bookmarklet](/#bookmark) while reading this tutorial. But note that it
:::info

You can run [LIPS bookmarklet](/#bookmark) while reading this tutorial. But note that it
doesn't yet support [continuations](/docs/scheme-intro/continuations) and TCO ([Tail Call
Optimization](/docs/scheme-intro/core#tail-call-optimization)).

:::

### Standards

Scheme is standardized in form of [R<sup>n</sup>RS documents](https://standards.scheme.org/).
Expand Down

0 comments on commit c602896

Please sign in to comment.