arclanguage / anarki

Community-managed fork of the Arc dialect of Lisp; for commit privileges submit a pull request.
http://arclanguage.github.io
Other
1.17k stars 160 forks source link

Template functions not behaving as expected #140

Closed Kinnardian closed 5 years ago

Kinnardian commented 5 years ago
arc> (deftem pipeline name nil stacks nil)
((name #<procedure: g2070>) (stacks #<procedure: g2070>))
arc> (save-table (inst 'pipeline 'name "templPipe" 'stacks '("col1" "col2" "col3" "col4")) "./pipelines/templPipe")
hash-for-each: contract violation
  expected: hash?
  given: '#(tagged tem (pipeline #hash((name . "templPipe") (stacks . ("col1" "col2" "col3" "col4" . nil))) #hash()))
  argument position: 1st
  other arguments...:
   #<procedure: tablist>
  context...:
   /usr/local/Cellar/arc/ac.rkt:1194:15: maptable
   /usr/local/Cellar/minimal-racket/7.0/share/racket/collects/racket/private/kw.rkt:592:14:  tablist
   /usr/local/Cellar/minimal-racket/7.0/share/racket/collects/racket/private/kw.rkt:592:14: zz
   /usr/local/Cellar/minimal-racket/7.0/share/racket/collects/racket/private/kw.rkt:592:14:  save-table
   /usr/local/Cellar/arc/ac.rkt:1327:4

temstore works and yields this file: ((name "templPipe") (stacks ("col1" "col2" "col3" "col4")))

But temload also behaves unexpectedly:

(temload 'pipeline "./pipelines/templPipe")
#(tagged tem (pipeline #hash((name . "templPipe") (stacks . ("col1" "col2" "col3" "col4" . nil))) #hash()))
akkartik commented 5 years ago

I don't understand. Why are you trying to save-table if temread works? And how is temload's result unexpected?

Kinnardian commented 5 years ago

I'd expect #hash((name . "templPipe") (stacks . ("col1" "col2" "col3" "col4" . nil))) from temload per the docs here: https://arclanguage.github.io/ref/template.html

I'm fine using temstore but I was guessing that what appears to be going on is related.

akkartik commented 5 years ago

Those docs are [edit: unfortunately] for Arc 3.1, and Anarki isn't compatible. (I think its behavior is superior.) For your purposes you shouldn't care what the internals of a template look like, only that getting/setting fields works as expected.

Kinnardian commented 5 years ago

I was having trouble getting/setting, I figured out why: keys must be quoted