Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Float Vs Double Date: Wed, 10 Aug 2016 09:56:05 -0700 Organization: None to speak of Lines: 39 Message-ID: References: <8a7a94a5-fb11-40a4-b7f7-c0d59859a581@googlegroups.com> <0bae28e0-b651-41ba-b195-d5623c70eb18@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="25213"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181oXZMaY6BEl3uPo2JXLrl" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:7FZFoNiy2aUesJTsetR/mgbb0uk= sha1:pt9KvAdu25p7X0XqNIwDBfpoaI4= Xref: csiph.com comp.lang.c:92084 supercat@casperkitty.com writes: > On Wednesday, August 10, 2016 at 9:43:15 AM UTC-5, David Brown wrote: >> Does CAlive have variable argument functions like printf? If I were >> making a new language, I'd drop such functions - they are error prone, >> hard to implement well, and difficult for compile-time checking or >> typing. > > If I were designing a language, I'd include two kinds of variadic functions > (with a requirement that a prototype identifying the calling convention be in > scope before the call): > > 1. For functions that use a fixed type, I'd have a declaration that would > cause a sequence of arguments to be stored in a temporary array and > have the caller receive the address of the array and its length. On > most implementations, creating the array on the stack would take the > same amount of work as pushing arguments individually, so the only > extra work would be passing the pointer and the length, but the called > function would then be guaranteed to have an actual array, and it would > also be callable with an array. I'd make it possible to pass arrays as arguments (perhaps by reference), and provide a reasonable syntax for constructing an array value. So rather than func(10, 20, 30, 40); you could write something like func([10, 20, 30, 40]); with func taking a single argument of array type, with the bounds made available to the function. It avoids the need for a special kind of variadic function and can be used in other contexts. A number of languages already do something like this. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"