Commit Graph

9 Commits

Author SHA1 Message Date
Kartik K. Agaram 618b49fbf3 use markdown syntax for images
Now they render right on non-Github forges.
2023-11-26 18:06:52 -08:00
Kartik K. Agaram 4a90a28a15 fake to stand in for start_reading in tests 2022-03-18 09:24:53 -07:00
Kartik K. Agaram b9c187d259 stop using tasks in start_reading/start_writing
We just need queues/streams for file I/O. No need to complect
concurrency concerns with them.
2022-03-16 17:03:38 -07:00
Kartik K. Agaram 2b47f76308 just always temp files to be created
Implication: os.rename now needs to be sandboxed. Hopefully it's
tractable to treat it as conceptually identical to opening two files.
2022-03-07 21:57:11 -08:00
Kartik K. Agaram a0674f7b85 hokey primitive to create temporary file
The trouble with os.tmpname() is that it always creates in /tmp.
If /tmp is in a different volume from our real filename, os.rename()
will fail.

This new primitive doesn't support primitive paths yet.

I'm also again nervous about the security implications of my whole
approach. What if we create an inner function called start_writing?
Would we be able to do anything inside it? I'm starting to suspect this
whole approach of going by caller name is broken. An app could also
create inner functions called 'main'..
2022-03-07 19:14:02 -08:00
Kartik K. Agaram 6a3098d0e9 use method syntax where possible
Perhaps this is a bad idea. It feels arbitrary, what methods Lua happens
to include in string and table objects without having to go through the
respective modules.
2022-03-06 16:38:49 -08:00
Kartik K. Agaram 5758f6c082 reading from file a character at a time 2022-03-06 09:52:37 -08:00
Kartik K. Agaram f07eb03492 local functions broke start_reading/start_writing
Looks like Lua's local functions lose access to outer scopes (upvalues)
or something like that..
2022-03-06 09:49:33 -08:00
Kartik K. Agaram 38ff2ddf11 move start_reading/start_writing out of template
When should code go in the template used by new apps vs the .lua files
distributed with Teliva?

- from a privilege perspective there's no difference
- from a compatibility perspective stuff in .tlv will not get upgraded
  with Teliva.
- for me the maintainer, functions in .lua files are easier to upgrade
  in a single place.
- for the reader of an app, functions in .lua files will not show up to
  be edited. They can still be overloaded, but the current version isn't
  as discoverable. Putting something in the app is a slight nudge to
  readers that they're encouraged to mess with it.
- Stuff in .lua files can use local functions and so have more internal
  complexity. Apps can also hide details within functions, but that'll
  make them more likely to run into limitations with Teliva's editing
  environment.

I'm not yet sure how to reason about the second point in practice.
  - Stuff in .tlv files I don't have to worry about compatibility
    guarantees for.
  - Stuff in .lua files I _do_ have to worry about compatibility
    guarantees for.

Perhaps this means I'm doing things exactly wrong in this commit?
Functions like map/reduce/filter/append seem more timeless, whereas I'm
still just feeling my way around with start_reading and start_writing.

We'll see. For now I'm ruled by the fourth point. Messing with tasks and
the scheduler is much more advanced than anything else in template.tlv;
it seems to make sense to add some friction to modifying them.

Bottomline: Complex sub-systems go in .lua files. Simple, self-contained
definitions go into apps. Both are probably equally burdensome now from
a compatibility perspective.
2022-03-06 09:21:32 -08:00