durusmail: qp: Re: Another Proposed Template Notation
Another Proposed Template Notation
2007-11-01
Re: Another Proposed Template Notation
2007-11-01
2007-11-01
2007-11-01
2007-11-01
Re: Another Proposed Template Notation
2007-11-02
2007-11-02
2007-11-02
2007-11-02
2007-11-02
Re: Another Proposed Template Notation
Tristan Short
2007-11-01
David Binger wrote:
>
> On Nov 1, 2007, at 2:16 PM, Michael Watkins wrote:
>
>> * David Binger wrote on [2007-11-01 11:28:08 -0400]:
>>> def f(x:int, y:list) -> float:
>>>
>>> I'm proposing using a similar annotation syntax for annotating the
>>> function name, using a colon and either "xml" or "str" to say that
>>> the function is a template and that it should be compiled using
>>> the "xml" transformation, or the "str" transformation.
>>
>> Without any thought at all to whether this would be implementable in
>> Python < 3.x, using Python 3 annotation syntax as a guide. (I say
>> this not knowing if the new annotation syntax is an all or nothing -
>> i.e. both parameters and return values - approach or not.)
>
> No problem there.  The proposed qpy syntax is a SyntaxError in all
> versions of python (except with the qpy compiler).
>
>>
>> Python 3:
>>> def f(x:int, y:list) -> float:
>>
>> Would this make some sense, and is it implementable:
>>
>>     def f(annotated, parameters, or not) -> xml:
>>     def f(annotated, parameters, or not) -> string:
>>
>> Having just written that, it is perhaps not such a good idea as it
>> may perpetuate the notion that only the return value is "xml" or
>> "string".
>
> This would make it impossible to use the annotation to say that
> an ordinary, non-template function returns an xml or string.
> Also, since it would not be a SyntaxError in py3k, you'd run the
> risk of having these compile as non-templates.
>
>>
>> As for your proposal:
>>> def f:xml():
>>> def f:str():
>>
>> I like this better than ``@[xml]`` if for no other reason than it is
>> easier to type. I also think it looks cleaner than the
>> decorator-like syntax.
>
> I think so.
>
For what it is worth I prefer this syntax too, although quite happy with
[html] as well as it is so easy to read.
>
>
> _______________________________________________
> QP mailing list
> QP@mems-exchange.org
> http://mail.mems-exchange.org/mailman/listinfo/qp
>
>

reply