lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Jan 24, 2012 at 8:34 PM, Tony Finch <> wrote:
> You might design a system with more precisely typed data, where the type
> of a string corresponds to its formal language, i.e. the syntax of the
> string. So strings aren't just strings, they are SQL strings or JSON
> strings or passwords, etc. Then each slot in a template needs to know the
> type of string that it accepts.

I like this general concept and since I provide a simple template
implementation in Penlight I thought that I could extend it so that
one can optionally use 'type annotations' in the template.

So for, instance these slots have type 'name'

res,err = substitute("Name $(first:name) $(second:name)", {first =
'fred', second = 'bloggs'})

Examples of "not a name" is "23" or "Bobby '; DROP TABLES", etc.
There can be a few defined types, like number, iden and so forth, and
a means to define new types using string patterns/verification

(Templates like this can also be used to _parse_ strings, which is the
idea behind pl.sip, although using another notation)

No implementation so far, just throwing a simple idea into the arena.

steve d.