Skip to content

Commit

Permalink
[demo/survey-loop] List comprehension
Browse files Browse the repository at this point in the history
[doc/framing] Notes on HTTP
  • Loading branch information
Andy C committed Feb 2, 2025
1 parent 04df113 commit 513bf99
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
16 changes: 15 additions & 1 deletion demo/survey-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ for x in mylist:
if x == 2:
mylist.append(99)
print(x)
'

echo ---
echo PY comp

python3 -c '
def myappend(li, i):
if i == 1:
li.append(99)
print(i)
return i
mylist = [1,2,3]
y = [myappend(mylist, i) for i in mylist]
print(y)
'
}

Expand Down Expand Up @@ -95,5 +110,4 @@ compare-mutate() {
mutate-ysh
}


"$@"
22 changes: 19 additions & 3 deletions doc/framing.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,23 @@ Traditional shells mostly support newline-based records. YSH supports:

1. Length-prefixed records
1. Delimiter-based records
- fixed delimiter: newline or `NUL`
- chosen delimiter: TODO? with regex capture?
- fixed delimiter: newline or `NUL`
- chosen delimiter: TODO? with regex capture?
1. Escaping-based records with [JSON][] and the [J8 Notation][] extension.
- But we avoid formats that are purely based on escaping.
- But we avoid formats that are purely based on escaping.

[J8 Notation]: j8-notation.html

## Appendix

### Notes on HTTP 1.1

It has a messy mix of strategies:

- The HTTP headers and body are separated by a blank line - a fixed **delimiter**
- The `Content-Length:` header is a **length prefix** for the request or
response body
- But you can also use `Transfer-Encoding: chunked`, which makes the body a
**stream** of length-prefixed chunks. The stream is terminated by a sentinel
(a delimiter).
- Multipart MIME file uploads use a **chosen delimiter** to separate files.

0 comments on commit 513bf99

Please sign in to comment.