[Ur] Key-value store extension
Adam Chlipala
adamc at csail.mit.edu
Wed Jan 31 16:32:40 EST 2018
That's an interesting idea. It is not a feature that has ever occurred
to me to suggest. I prefer to settle configuration at compile time, so
that the compiler can specialize code to chosen settings. Have you
considered that path, too?
On 01/29/2018 10:43 AM, Athene Noctua wrote:
> Hi all,
>
> I find it useful to have a module for storing global configuration
> settings and the likes in my applications, using a single table with
> key and value fields and a simple get/set interface. Unfortunately
> this approach breaks the nice encapsulation properties you get with
> Ur/Web tables, as there's no way to control which module can access
> which key, and trying to generate the keys to avoid collisions would
> likely be cumbersome and break through multiple versions of the same
> application.
>
> I was wondering if this was a useful enough feature to be added into
> the language, and if I should bother trying to hack it into the
> compiler, or if I should just stick with writing a functor and make a
> key-val table for each module that needs it instead.
>
> For example:
>
> key test : string
>
> fun set_test { Test = t } =
> storeSet test t
>
> val main =
> t <- storeGet test;
> return <xml>
> The value of test is {[Option.get "test" t]}.
> <form><textbox{#Test}/><submit action={set_test}/></form>
> </xml>
>
> "key" is probably not a very good name, as adding it as a keyword it
> would likely break a lot of existing code, but that's easy to change.
>
> What do you think?
>
> - Francesco
More information about the Ur
mailing list