View Single Post
Old 12-16-2020, 05:04 PM   #108
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,501
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
This bit about a separate column for a check is not clear to me.
The idea is to be able to express the following pseudo-code:
Code:
if template() == 'a' then do action 1 fi;
if template() == 'b' then do action 2 fi;
if template() == 'c' then do action 3 fi;
Your idea of having an "action" that can force skipping subsequent actions is very interesting. However, maintenance is an issue, as is knowing the number of actions to skip. That said, your idea leads to what I think is much better than what I proposed, something like this again in pseudo-code.
Code:
v = template_action('foo()')
if v == X then do action 1 fi
if v == X then do action 2 fi
if v == Y then do action 3 fi
Using a template_action would set 'v', a "global variable" in action chains. Subsequent actions would be conditioned by the value of 'v', specified in a column. This way the template returns a value that controls subsequent actions without worrying about changes of state. Any new template_action() would reset that value, permitting expressions like
Code:
v = template1_action('foo()')
if v == X then do action 1 fi
if v == X then do action 2 fi
if v == Y then do action 3 fi
v = template1_action('bar()')
if v == Z then do action 4 fi
if v == W then do action 5 fi
FWIW: if there are additions to the template language that would help, let me know. The main rules are:
  • A template function cannot change metadata.
  • There are no globals, which means that a template cannot know something like "what is the largest series number for this series". Of course user defined template functions can do this, but I think that is out of scope.
  • A template cannot reference more than one book.
chaley is offline   Reply With Quote