Skip to content

Commit

Permalink
[61_7] Goldfish: encoding fix
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Dec 25, 2024
1 parent 9ab2645 commit 6452298
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 70 deletions.
67 changes: 35 additions & 32 deletions TeXmacs/plugins/goldfish/doc/goldfish.en.tm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<style|<tuple|tmdoc|old-spacing|old-dots|old-lengths|goldfish>>

<\body>
<\hide-preamble>
<assign|font|math=Latin Modern Math,cjk=Noto CJK SC,CMU>
</hide-preamble>

<tmdoc-title|The Goldfish Scheme plugin>

<hlink|Goldfish Scheme|https://github.com/LiiiLabs/goldfish> is based on
Expand All @@ -19,15 +23,6 @@

<paragraph|Unicode Support>

The string literal in Goldfish Scheme does not support Unicode. In the
Goldfish Scheme session, we use the cork encoding as a workaround.

<\scm-code>
<block|<tformat|<twith|table-width|1par>|<twith|table-hmode|exact>|<table|<row|<cell|Scheme
Code>|<cell|Actual Scheme Code>>|<row|<cell|'\<#4E2D\>\<#6587\>>|<cell|'\<less\>#4E2D\<gtr\>\<less\>#6587\<gtr\>>>|<row|<cell|(length
"\<#4E2D\>\<#6587\>")>|<cell|(length "\<less\>#4E2D\<gtr\>\<less\>#6587\<gtr\>")>>>>>
</scm-code>

<\session|goldfish|default>
<\output>
Goldfish Scheme (based on S7 Scheme 10.11, 2-July-2024)
Expand All @@ -44,25 +39,33 @@
<\unfolded-io>
\<gtr\>\
<|unfolded-io>
'\<less\>#4E2D\<gtr\>\<less\>#6587\<gtr\>
(length "\<#4E2D\>\<#6587\>")
<|unfolded-io>
<goldfish-result|\<#4E2D\>\<#6587\>>
<goldfish-result|6>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(length "\<#4E2D\>\<#6587\>")
(import (liii base))
<|unfolded-io>
<goldfish-result|(rootlet)>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(u8-string-length "\<#4E2D\>\<#6587\>")
<|unfolded-io>
<goldfish-result|14>
<goldfish-result|2>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(length "\<less\>#4E2D\<gtr\>\<less\>#6587\<gtr\>")
"\<#4E2D\>\<#6587\>"
<|unfolded-io>
<goldfish-result|14>
<goldfish-result|"\<#4E2D\>\<#6587\>">
</unfolded-io>

<\input>
Expand All @@ -81,23 +84,23 @@
<\unfolded-io>
\<gtr\>\
<|unfolded-io>
`(document (frac "\<#5206\>\<#5B50\>" "\<#5206\>\<#6BCD\>"))
\0(document (frac "\<#5206\>\<#5B50\>" "\<#5206\>\<#6BCD\>"))
<|unfolded-io>
<frac|\<#5206\>\<#5B50\>|\<#5206\>\<#6BCD\>>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
`(math (frac "1" "2"))
\0(math (frac "1" "2"))
<|unfolded-io>
<math|<frac|1|2>>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
`(with "color" "red" "Hello")
\0(with "color" "red" "Hello")
<|unfolded-io>
<with|color|red|Hello>
</unfolded-io>
Expand Down Expand Up @@ -366,15 +369,15 @@
<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(*goldfish* 'bignum-precision)
(*s7* 'bignum-precision)
<|unfolded-io>
<goldfish-result|128>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(set! (*goldfish* 'bignum-precision) 256)
(set! (*s7* 'bignum-precision) 256)
<|unfolded-io>
<goldfish-result|256>
</unfolded-io>
Expand Down Expand Up @@ -434,7 +437,7 @@
<|unfolded-io>
(floor 1.4)
<|unfolded-io>
<goldfish-result|1>
<goldfish-result|1.0>
</unfolded-io>

<\unfolded-io>
Expand Down Expand Up @@ -522,15 +525,15 @@
<|unfolded-io>
(random 1.0)
<|unfolded-io>
<goldfish-result|0.4550541097362356>
<goldfish-result|0.42902658884751455>
</unfolded-io>

<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(random 3/4)
<|unfolded-io>
<goldfish-result|380585/1487509>
<goldfish-result|837121/2106403>
</unfolded-io>

<\input>
Expand Down Expand Up @@ -602,7 +605,7 @@
<|unfolded-io>
(define test-tb (hash-table 'a 1 'b 2))
<|unfolded-io>
<goldfish-result|(hash-table 'b 2 'a 1)>
<goldfish-result|(hash-table 'a 1 'b 2)>
</unfolded-io>

<\unfolded-io>
Expand Down Expand Up @@ -655,7 +658,7 @@
<\errput>
wrong-number-of-args

goldfish-print: too many arguments: 2
("~S: too many arguments: ~A" goldfish-print 2)
</errput>
</unfolded-io>

Expand Down Expand Up @@ -748,9 +751,9 @@
<\unfolded-io>
\<gtr\>\
<|unfolded-io>
(directory? "/tmp")
(import (liii os))
<|unfolded-io>
<goldfish-result|#t>
<goldfish-result|(rootlet)>
</unfolded-io>

<\unfolded-io>
Expand Down Expand Up @@ -791,7 +794,7 @@
<\errput>
wrong-number-of-args

abs: too many arguments: (abs 1 2)
("~A: too many arguments: (~A~{~^ ~S~})" abs abs (1 2))
</errput>
</unfolded-io>

Expand Down Expand Up @@ -842,7 +845,7 @@
<\errput>
io-error

load: No such file or directory "test.scm"
("~A: ~A ~S" "load" "No such file or directory" "test.scm")
</errput>
</unfolded-io>

Expand Down Expand Up @@ -872,7 +875,7 @@
<\errput>
immutable-error

can't vector-set! #(1 2 3) (it is immutable)
("can't ~S ~S (it is immutable)" vector-set! #(1 2 3))
</errput>
</unfolded-io>

Expand Down Expand Up @@ -900,7 +903,7 @@
<\errput>
immutable-error

can't set! var (it is immutable)
("can't ~S ~S (it is immutable)" set! var)
</errput>
</unfolded-io>

Expand All @@ -912,7 +915,7 @@
<\errput>
wrong-type-arg

let: can't bind an immutable object: ((var 1))
("~A: can't bind an immutable object: ~S" let ((var 1)))
</errput>
</unfolded-io>

Expand Down
Loading

0 comments on commit 6452298

Please sign in to comment.