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

Re: tangentially relevant...



You can write a function taking a list of unspecified length, but then that's a 
heap allocated structure being checked at runtime, which could also throw an 
exception if it gets a list of unexpected length.  The Printf is meant to be 
safely checked at compile time instead.

It's impossible to write a type of *variable* arguments that depend on a 
previous type.  This would be a simple form of dependent typing as you are 
computing over the values of types to generate more types (the format string -> 
the subsequent format arguments).

In a similar vein, you can't write a pattern match over a tuple of variable 
elements...

Anil

On 4 Aug 2011, at 13:58, Richard Mortier wrote:

> naive type theory question here- presumably that's to do with the desire to 
> be able to curry arguments?  since i can certainly write a function taking a 
> list of unspecified length...
> 
> On 3 Aug 2011, at 23:01, Anil Madhavapeddy wrote:
> 
>> Interestingly in OCaml, the format strings in Printf/Scanf are parsed 
>> statically at compile time, and an error is thrown if they cannot be 
>> statically determined. This is because it's otherwise impossible to 
>> statically type a function with a variable number of arguments...
>> 
>> Anil
>> 
>> On 3 Aug 2011, at 22:48, Richard Mortier wrote:
>> 
>>> http://morepypy.blogspot.com/2011/08/pypy-is-faster-than-c-again-string.html
>>> 
>>> benefits of dynamic vs static compilation- but seems not unrelated to the 
>>> arguments about compiling the entire stack...
>>> -- 
>>> Cheers,
>>> 
>>> R.
>>> 
>>> This message and any attachment are intended solely for the addressee and 
>>> may contain confidential information. If you have received this message in 
>>> error, please send it back to me, and immediately delete it.   Please do 
>>> not use, copy or disclose the information contained in this message or in 
>>> any attachment.  Any views or opinions expressed by the author of this 
>>> email do not necessarily reflect the views of the University of Nottingham.
>>> 
>>> This message has been checked for viruses but the contents of an attachment
>>> may still contain software viruses which could damage your computer system:
>>> you are advised to perform your own checks. Email communications with the
>>> University of Nottingham may be monitored as permitted by UK legislation.
>> 
> 
> -- 
> Cheers,
> 
> R.
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.