update plan and notes
This commit is contained in:
54
Plan.org
54
Plan.org
@@ -647,11 +647,55 @@ Viewer:
|
|||||||
- Optional disk cache of tiles and plates, keyed by a hash of the
|
- Optional disk cache of tiles and plates, keyed by a hash of the
|
||||||
settings.
|
settings.
|
||||||
- Go-to-coordinates, PNG export of the current view.
|
- Go-to-coordinates, PNG export of the current view.
|
||||||
- Later: gravel-beach layer; exact ore deposits
|
- Later: gravel-beach layer; deposits, see below.
|
||||||
(=GenDeposits.GeneratePartial= and the disc generators). That would
|
|
||||||
place real ore blocks, make the pick readings exact, and read
|
** Next: deposits (planned, after the Sex fixes)
|
||||||
silver, gold and peridot. Checking it needs the save's chunk
|
Placing the deposits themselves, not just the pick's reading of them.
|
||||||
blocks decoded.
|
Soil deposits come first: they sit at the surface, so they don't need
|
||||||
|
the 3D rock column, and the steps up to the disc are the first half of
|
||||||
|
exact ore deposits anyway.
|
||||||
|
|
||||||
|
*Soil deposits.* Clay (red, blue, fire), peat, and terra preta
|
||||||
|
(=soil-compost=) from =deposits/soil/*.json=. All use
|
||||||
|
=disc-followsurfacebelow= at depth 0, with a climate gate and
|
||||||
|
=maxYRoughness= 1. They have no ore map, so the pick never reads them;
|
||||||
|
showing them means placing them.
|
||||||
|
1. *Where each deposit starts.* =GenDeposits.GeneratePartial= runs one
|
||||||
|
=chunkRand=, positioned at the chunk, through every top-level deposit
|
||||||
|
in load order. Per deposit it takes one =NextInt(100)= for the
|
||||||
|
fractional try. Per try it takes two =NextInt(32)= for the position
|
||||||
|
and one =NextInt(10000000)= for the deposit's own seed. A deposit's
|
||||||
|
try count depends only on its ore map, which matches the save
|
||||||
|
already. The deposit's own work runs on =depositRand=, and a failed
|
||||||
|
climate check returns before using =chunkRand=. So every deposit's
|
||||||
|
centre and seed per chunk replays without generating any ore. Child
|
||||||
|
deposits come after the main loop and don't disturb it.
|
||||||
|
2. *Climate gate* (=GenDeposits.GenDeposit=). Uses rain and temperature
|
||||||
|
from the climate map at the centre, adjusted for the =RainHeightMap=
|
||||||
|
height, and the relative Y against =minY=/=maxY=. The climate map
|
||||||
|
and the terrain height are ported. =RainHeightMap= at this pass
|
||||||
|
should be the terrain or the water surface; check that.
|
||||||
|
3. *Disc shape.* =DiscGenerator.GenDeposit=: radius, the shape
|
||||||
|
distortion noise, =maxYRoughness=, and thickness. The ore deposits
|
||||||
|
need the same port.
|
||||||
|
4. *Topsoil.* =inblock= is =soil-{fertility}-{cover}=, low or medium
|
||||||
|
fertility with cover none to normal; fire clay wants bauxite sand or
|
||||||
|
gravel. Fertility and grass cover come from =GenBlockLayers= and
|
||||||
|
=blocklayers.json=, which are not ported. Without them, patches show
|
||||||
|
where the game puts them on sand, gravel or rich soil.
|
||||||
|
- *Checking.* The save stores surface blocks only in chunk blobs, which
|
||||||
|
aren't decoded yet. Until they are, walk to a few patches in game.
|
||||||
|
|
||||||
|
*Exact ore deposits.* The same replay, then the disc, sea-level,
|
||||||
|
anywhere and child generators placing into the strata column. That
|
||||||
|
places real ore blocks and makes the pick readings exact: the pick's
|
||||||
|
column holds the ore of its own chunk's deposits. It also reads silver
|
||||||
|
and gold (children of quartz) and peridot (a child of olivine), whose
|
||||||
|
host is their parent's ore. Checking needs the chunk blocks decoded.
|
||||||
|
|
||||||
|
*Meanwhile, cheap:* the gold and silver ore maps already match the
|
||||||
|
save. They could go in the Minerals list as "ore map only", marked as
|
||||||
|
not a pick reading.
|
||||||
|
|
||||||
* Risks
|
* Risks
|
||||||
- *Bit-exactness* of the noise and the Rivers trigonometry. The
|
- *Bit-exactness* of the noise and the Rivers trigonometry. The
|
||||||
|
|||||||
@@ -3,13 +3,17 @@
|
|||||||
Language bugs and friction met while building vs-map-viewer, against
|
Language bugs and friction met while building vs-map-viewer, against
|
||||||
sexc at ~/dev/sex. Newest first. Unless said otherwise, sexc dfafe8b.
|
sexc at ~/dev/sex. Newest first. Unless said otherwise, sexc dfafe8b.
|
||||||
|
|
||||||
* =-INFINITY= is one symbol
|
* DONE =-INFINITY= is one symbol
|
||||||
|
Fixed in sexc f9fafd7 (sex#63): =-NAME= reads as =(- NAME)=.
|
||||||
|
|
||||||
=(var best double -INFINITY)= emits =_INFINITY=: the reader takes
|
=(var best double -INFINITY)= emits =_INFINITY=: the reader takes
|
||||||
the whole token as a symbol and the leading =-= is mangled like any
|
the whole token as a symbol and the leading =-= is mangled like any
|
||||||
other. =(- INFINITY)= works. Negative literals like =-1= are fine, so
|
other. =(- INFINITY)= works. Negative literals like =-1= are fine, so
|
||||||
it's only symbolic constants, but the mangled name reads like a typo.
|
it's only symbolic constants, but the mangled name reads like a typo.
|
||||||
|
|
||||||
* A cast of a bitwise expression loses its parentheses
|
* DONE A cast of a bitwise expression loses its parentheses
|
||||||
|
Fixed in sexc db98013 (sex#62).
|
||||||
|
|
||||||
=(cast (c-bit-or xn 1) float)= emits =(float)xn | 1=, which C reads as
|
=(cast (c-bit-or xn 1) float)= emits =(float)xn | 1=, which C reads as
|
||||||
=((float)xn) | 1=: a compile error here, but with an integer target
|
=((float)xn) | 1=: a compile error here, but with an integer target
|
||||||
type it would silently cast only =xn=. Arithmetic operands are
|
type it would silently cast only =xn=. Arithmetic operands are
|
||||||
@@ -19,20 +23,26 @@ In this project they have cost more time than every other entry put
|
|||||||
together, mostly through =(if ...)= in arithmetic, which keeps coming
|
together, mostly through =(if ...)= in arithmetic, which keeps coming
|
||||||
back because it reads so naturally.
|
back because it reads so naturally.
|
||||||
|
|
||||||
* A cast as the object of =.= loses its parentheses
|
* DONE A cast as the object of =.= loses its parentheses
|
||||||
|
Fixed in sexc db98013 (sex#61).
|
||||||
|
|
||||||
=(. (cast pa (* const wanted)) distance)= emits
|
=(. (cast pa (* const wanted)) distance)= emits
|
||||||
=(const wanted *)pa->distance=, which C reads as a cast of
|
=(const wanted *)pa->distance=, which C reads as a cast of
|
||||||
=pa->distance= on a =void *=. Like the conditional entry below, the
|
=pa->distance= on a =void *=. Like the conditional entry below, the
|
||||||
writer doesn't parenthesize a lower-precedence operand. Bound to a
|
writer doesn't parenthesize a lower-precedence operand. Bound to a
|
||||||
typed local first, it works.
|
typed local first, it works.
|
||||||
|
|
||||||
* Arrays of a header type with a symbolic size misparse
|
* DONE Arrays of a header type with a symbolic size misparse
|
||||||
|
Fixed in sexc 97eb123 (sex#60).
|
||||||
|
|
||||||
=(workers [pthread-t MAX_WORKERS])= emits =pthread_t MAX_WORKERS
|
=(workers [pthread-t MAX_WORKERS])= emits =pthread_t MAX_WORKERS
|
||||||
workers[];=, reading =MAX_WORKERS= as a second type word. =[u16
|
workers[];=, reading =MAX_WORKERS= as a second type word. =[u16
|
||||||
CHUNK_AREA]= works, presumably because =u16= is known to Sex and
|
CHUNK_AREA]= works, presumably because =u16= is known to Sex and
|
||||||
=pthread_t= only to C. A literal size, =[pthread-t 32]=, works.
|
=pthread_t= only to C. A literal size, =[pthread-t 32]=, works.
|
||||||
|
|
||||||
* A conditional expression as an operand loses its parentheses
|
* DONE A conditional expression as an operand loses its parentheses
|
||||||
|
Fixed in sexc db98013 (sex#59).
|
||||||
|
|
||||||
#+begin_src scheme
|
#+begin_src scheme
|
||||||
(/ (* 100.0 matched) (if (> compared 0) compared 1))
|
(/ (* 100.0 matched) (if (> compared 0) compared 1))
|
||||||
#+end_src
|
#+end_src
|
||||||
@@ -60,7 +70,11 @@ this project found four such sites that had compiled cleanly with
|
|||||||
Only the generated C showed them. The fix is the same: bind to a
|
Only the generated C showed them. The fix is the same: bind to a
|
||||||
variable first.
|
variable first.
|
||||||
|
|
||||||
* An import doesn't bring the types its interface needs
|
* DONE An import doesn't bring the types its interface needs
|
||||||
|
Fixed in sexc 360470d and a8f8b23 (sex#58): a module =pub import=s
|
||||||
|
what its pub forms hold, constants included, and sexc refuses one
|
||||||
|
that doesn't. A type only C knows, like =cJSON=, it can't check.
|
||||||
|
|
||||||
Module =save= takes a =(* region-maps)= from module =maps=. Importing
|
Module =save= takes a =(* region-maps)= from module =maps=. Importing
|
||||||
=save= pastes its prototypes but not =region-maps=, so every importer
|
=save= pastes its prototypes but not =region-maps=, so every importer
|
||||||
has to import =maps= itself, and before =save=:
|
has to import =maps= itself, and before =save=:
|
||||||
@@ -72,13 +86,19 @@ save.sex:284:52: error: unknown type name 'region_maps'
|
|||||||
=vsmv.sex= now imports eight modules in dependency order to use three.
|
=vsmv.sex= now imports eight modules in dependency order to use three.
|
||||||
Imports are at least idempotent (a diamond works).
|
Imports are at least idempotent (a diamond works).
|
||||||
|
|
||||||
* A pub record with a field of a private record type
|
* DONE A pub record with a field of a private record type
|
||||||
|
Fixed in sexc 360470d (sex#57): behind a pointer, the type's
|
||||||
|
declaration goes out with the pub forms; held by value, it is an error
|
||||||
|
at the definition.
|
||||||
|
|
||||||
=(pub record natural-shape (... (slots (* shape-cell)) ...))= with
|
=(pub record natural-shape (... (slots (* shape-cell)) ...))= with
|
||||||
=shape-cell= not =pub= compiles in its own module, and in the importer
|
=shape-cell= not =pub= compiles in its own module, and in the importer
|
||||||
fails with =unknown type name 'shape_cell'=. Either an error at the
|
fails with =unknown type name 'shape_cell'=. Either an error at the
|
||||||
definition or exporting the type would do.
|
definition or exporting the type would do.
|
||||||
|
|
||||||
* =[(* T) N]= fields break in importers
|
* DONE =[(* T) N]= fields break in importers
|
||||||
|
Fixed in sexc 97eb123 (sex#56).
|
||||||
|
|
||||||
A pub record field =(noises [(* simplex-sum) 32])= compiles in its own
|
A pub record field =(noises [(* simplex-sum) 32])= compiles in its own
|
||||||
module but not when pasted into an importer:
|
module but not when pasted into an importer:
|
||||||
=Error: pointer chains are written flat, as (* * T), not nested:
|
=Error: pointer chains are written flat, as (* * T), not nested:
|
||||||
@@ -86,7 +106,9 @@ module but not when pasted into an importer:
|
|||||||
=[* simplex-sum MAX_STRATA]= works, while a local
|
=[* simplex-sum MAX_STRATA]= works, while a local
|
||||||
=(var names [(* const char) 6])= is fine either way.
|
=(var names [(* const char) 6])= is fine either way.
|
||||||
|
|
||||||
* =define= bodies are pasted raw
|
* DONE =define= bodies are pasted raw
|
||||||
|
Fixed in sexc df3aa17 (sex#55).
|
||||||
|
|
||||||
=(define K (/ (cast 255 float) (cast 60 float)))= emits
|
=(define K (/ (cast 255 float) (cast 60 float)))= emits
|
||||||
=#define K cast(255, float) / cast(60, float)=: not translated, and
|
=#define K cast(255, float) / cast(60, float)=: not translated, and
|
||||||
not parenthesized. With =(define D (/ -1.0 6.0))=, =(* x D)= becomes
|
not parenthesized. With =(define D (/ -1.0 6.0))=, =(* x D)= becomes
|
||||||
@@ -94,7 +116,9 @@ not parenthesized. With =(define D (/ -1.0 6.0))=, =(* x D)= becomes
|
|||||||
from multiplying by the folded constant. Bit-exact code needs literal
|
from multiplying by the folded constant. Bit-exact code needs literal
|
||||||
values or typed =var=s.
|
values or typed =var=s.
|
||||||
|
|
||||||
* =#line= splits a ternary in a call argument
|
* DONE =#line= splits a ternary in a call argument
|
||||||
|
Fixed in sexc ea0bed6 (sex#54).
|
||||||
|
|
||||||
=(if c a b)= in expression position becomes =c ? a : b=. Inside a
|
=(if c a b)= in expression position becomes =c ? a : b=. Inside a
|
||||||
multi-line call, though, the statement anchor lands between the
|
multi-line call, though, the statement anchor lands between the
|
||||||
ternary's parts, and the C doesn't compile:
|
ternary's parts, and the C doesn't compile:
|
||||||
@@ -110,7 +134,9 @@ dump.sex:128:1: error: expected expression
|
|||||||
=-C= output, without the directives, is fine. The build now passes
|
=-C= output, without the directives, is fine. The build now passes
|
||||||
=--line-directives=toplevel= to every Sex unit.
|
=--line-directives=toplevel= to every Sex unit.
|
||||||
|
|
||||||
* A typedef of a function pointer type crashes the compiler
|
* DONE A typedef of a function pointer type crashes the compiler
|
||||||
|
Fixed in sexc 8774400 (sex#53).
|
||||||
|
|
||||||
#+begin_src scheme
|
#+begin_src scheme
|
||||||
(typedef colour-fn (fn ((i32)) u32))
|
(typedef colour-fn (fn ((i32)) u32))
|
||||||
#+end_src
|
#+end_src
|
||||||
@@ -120,59 +146,83 @@ Error: (cdr) bad argument type: u32
|
|||||||
|
|
||||||
No location. The same type written inline in a parameter list works.
|
No location. The same type written inline in a parameter list works.
|
||||||
|
|
||||||
* =sizeof= of a pointer type reads as a dereference
|
* DONE =sizeof= of a pointer type reads as a dereference
|
||||||
|
Fixed in sexc 08044ce (sex#52).
|
||||||
|
|
||||||
=(sizeof (* char))= becomes =sizeof(*char)=. There's no way to spell
|
=(sizeof (* char))= becomes =sizeof(*char)=. There's no way to spell
|
||||||
the type; =(sizeof x)= on an expression works.
|
the type; =(sizeof x)= on an expression works.
|
||||||
|
|
||||||
* =case= bodies share one scope
|
* DONE =case= bodies share one scope
|
||||||
|
Fixed in sexc 1dc0c1a (sex#51): a body that declares is braced.
|
||||||
|
|
||||||
A =case= body isn't braced, so =(var bits u64 ...)= in one case and
|
A =case= body isn't braced, so =(var bits u64 ...)= in one case and
|
||||||
=(var bits u32 ...)= in the next is a C redefinition. Clang also warns
|
=(var bits u32 ...)= in the next is a C redefinition. Clang also warns
|
||||||
"label followed by a declaration is a C23 extension". Wrapping each
|
"label followed by a declaration is a C23 extension". Wrapping each
|
||||||
body in =(do ...)= works around it; the writer could do that itself.
|
body in =(do ...)= works around it; the writer could do that itself.
|
||||||
|
|
||||||
* Constants in array types aren't kebab-converted
|
* DONE Constants in array types aren't kebab-converted
|
||||||
|
Fixed in sexc 9a490a9 (sex#50).
|
||||||
|
|
||||||
=(var xs [u16 CHUNK-AREA])= and record fields like
|
=(var xs [u16 CHUNK-AREA])= and record fields like
|
||||||
=(terrain-height [u16 CHUNK-AREA])= emit =CHUNK-AREA= literally, while
|
=(terrain-height [u16 CHUNK-AREA])= emit =CHUNK-AREA= literally, while
|
||||||
=CHUNK-AREA= in an expression becomes =CHUNK_AREA=. Writing
|
=CHUNK-AREA= in an expression becomes =CHUNK_AREA=. Writing
|
||||||
=CHUNK_AREA= in the type works around it.
|
=CHUNK_AREA= in the type works around it.
|
||||||
|
|
||||||
* =?= is not mangled in names
|
* DONE =?= is not mangled in names
|
||||||
|
Fixed in sexc d5b003e (sex#49): =?= becomes =ʔ= and =!= =ꜝ=, letters
|
||||||
|
C takes.
|
||||||
|
|
||||||
=(fn ident-start? ...)= emits =ident_start?=, which isn't C. Lisp
|
=(fn ident-start? ...)= emits =ident_start?=, which isn't C. Lisp
|
||||||
predicates want =?=; =-= is mangled to =_=, so =?= could become =_p=.
|
predicates want =?=; =-= is mangled to =_=, so =?= could become =_p=.
|
||||||
|
|
||||||
* Relative =SEX_MODULE_PATH= entries resolve from the root
|
* DONE Relative =SEX_MODULE_PATH= entries resolve from the root
|
||||||
|
Fixed in sexc 0d26b1f (sex#48).
|
||||||
|
|
||||||
=SEX_MODULE_PATH=src sexc ...= searches =/src/=. An absolute path works.
|
=SEX_MODULE_PATH=src sexc ...= searches =/src/=. An absolute path works.
|
||||||
|
|
||||||
* No hex literals
|
* DONE No hex literals
|
||||||
|
Fixed in sexc 448b908 (sex#47): written to C in decimal.
|
||||||
|
|
||||||
=0x80= reaches C as =|0x80|= (the Scheme printer escaping a symbol
|
=0x80= reaches C as =|0x80|= (the Scheme printer escaping a symbol
|
||||||
that looks numeric), and =#x80= is rejected by the reader:
|
that looks numeric), and =#x80= is rejected by the reader:
|
||||||
"Unsupported # syntax: #\x". Masks and code points have to be written
|
"Unsupported # syntax: #\x". Masks and code points have to be written
|
||||||
in decimal, which hurts in bit-twiddling code: =(& c 224)= instead of
|
in decimal, which hurts in bit-twiddling code: =(& c 224)= instead of
|
||||||
=(& c 0xE0)=.
|
=(& c 0xE0)=.
|
||||||
|
|
||||||
* Explicit enum values emit raw names
|
* DONE Explicit enum values emit raw names
|
||||||
|
Fixed in sexc 504f357 (sex#46).
|
||||||
|
|
||||||
#+begin_src scheme
|
#+begin_src scheme
|
||||||
(pub enum wire ((wire-varint 0) (wire-fixed64 1)))
|
(pub enum wire ((wire-varint 0) (wire-fixed64 1)))
|
||||||
#+end_src
|
#+end_src
|
||||||
emits =wire-varint = 0, ...=, neither kebab-converted nor accepted by
|
emits =wire-varint = 0, ...=, neither kebab-converted nor accepted by
|
||||||
C. Plain =(enum name (a b c))= works; explicit values need =define=s.
|
C. Plain =(enum name (a b c))= works; explicit values need =define=s.
|
||||||
|
|
||||||
* Member access inside a compound literal ignores the operand's type
|
* DONE Member access inside a compound literal ignores the operand's type
|
||||||
|
Fixed in sexc b73cf36 (sex#45).
|
||||||
|
|
||||||
With =self= a =(* pb)=, =#(pb : (. self p) (. self p) true)= emits
|
With =self= a =(* pb)=, =#(pb : (. self p) (. self p) true)= emits
|
||||||
=self.p=, not =self->p=. The same =(. self p)= outside a literal is
|
=self.p=, not =self->p=. The same =(. self p)= outside a literal is
|
||||||
right. Bound to a local first, it works.
|
right. Bound to a local first, it works.
|
||||||
|
|
||||||
* Methods can only call methods above them
|
* DONE Methods can only call methods above them
|
||||||
|
Fixed in sexc 2d4e5f6 (sex#44).
|
||||||
|
|
||||||
Inside one =ops= block, calling a method defined further down fails
|
Inside one =ops= block, calling a method defined further down fails
|
||||||
with =no such method on pb len=. C needs prototypes, so this is
|
with =no such method on pb len=. C needs prototypes, so this is
|
||||||
consistent, but the block could declare its methods before their
|
consistent, but the block could declare its methods before their
|
||||||
bodies.
|
bodies.
|
||||||
|
|
||||||
* =-o -= crashes instead of meaning stdout
|
* DONE =-o -= crashes instead of meaning stdout
|
||||||
|
Fixed in sexc ce236d8 (sex#43).
|
||||||
|
|
||||||
=--help= says -C output defaults to stdout without =-o=; passing =-o -=
|
=--help= says -C output defaults to stdout without =-o=; passing =-o -=
|
||||||
explicitly dies in getopt-long's argument handling.
|
explicitly dies in getopt-long's argument handling.
|
||||||
|
|
||||||
* A malformed =for= crashes the compiler
|
* DONE A malformed =for= crashes the compiler
|
||||||
|
Fixed in sexc baf2f92 (sex#42): a grouped header is an error naming
|
||||||
|
the line.
|
||||||
|
|
||||||
sexc dfafe8b. Writing the C-style grouped header
|
sexc dfafe8b. Writing the C-style grouped header
|
||||||
|
|
||||||
#+begin_src scheme
|
#+begin_src scheme
|
||||||
@@ -191,7 +241,10 @@ Error: (caddr) bad argument type: ()
|
|||||||
Expected: a diagnostic naming the file, the line and the expected shape
|
Expected: a diagnostic naming the file, the line and the expected shape
|
||||||
of =for=.
|
of =for=.
|
||||||
|
|
||||||
* Spurious "cannot type this" on a header pointer
|
* DONE Spurious "cannot type this" on a header pointer
|
||||||
|
Fixed in sexc 79d9860 (sex#41): the warning stays, and names
|
||||||
|
=(. font handle)=, the part a struct only C knows leaves untyped.
|
||||||
|
|
||||||
sexc dfafe8b. In =src/viewer.sex=:
|
sexc dfafe8b. In =src/viewer.sex=:
|
||||||
|
|
||||||
#+begin_src scheme
|
#+begin_src scheme
|
||||||
@@ -205,7 +258,9 @@ type is written out, so the warning is wrong on both counts: the type
|
|||||||
is known, and the access isn't read as a value. The nearby
|
is known, and the access isn't read as a value. The nearby
|
||||||
=(& (. font handle))= gives no warning.
|
=(& (. font handle))= gives no warning.
|
||||||
|
|
||||||
* No dependency output
|
* DONE No dependency output
|
||||||
|
Fixed in sexc 1998344 (sex#40): =--depfile=.
|
||||||
|
|
||||||
sexc has nothing like =cc -MD=. An =import= pastes the imported
|
sexc has nothing like =cc -MD=. An =import= pastes the imported
|
||||||
module's public forms into the importer, so the Makefile has to make
|
module's public forms into the importer, so the Makefile has to make
|
||||||
every Sex object depend on every =.sex= source.
|
every Sex object depend on every =.sex= source.
|
||||||
|
|||||||
Reference in New Issue
Block a user