home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 243,186 of 243,242   
   Michael S to Bart   
   Re: printf and time_t   
   08 Feb 26 10:52:46   
   
   From: already5chosen@yahoo.com   
      
   On Fri, 6 Feb 2026 13:04:34 +0000   
   Bart  wrote:   
      
   > On 06/02/2026 12:47, Michael S wrote:   
   > > On Fri, 6 Feb 2026 12:39:55 +0000   
   > > Bart  wrote:   
   > >   
   > >> On 06/02/2026 05:10, Keith Thompson wrote:   
   > >>> Bart  writes:   
   > >>> [...]   
   > >>>> /Some/ compilers with /some/ options will /sometimes/ tell you   
   > >>>> when you've got it wrong.   
   > >>>>   
   > >>>> But you first have to make an educated guess, or put in some   
   > >>>> dummy format code.   
   > >>>>   
   > >>>> Eventually, it will compile. Until someone else builds your   
   > >>>> program, using a slightly different set of headers where certain   
   > >>>> types are defined, and then it might either give compiler   
   > >>>> messages that they have to fix, or it show wrong results.   
   > >>>   
   > >>> That's not how I do it, and I don't think it's how most   
   > >>> programmers do it.   
   > >>>   
   > >>> I know the rules well enough that I can usually write a correct   
   > >>> format string in the first place.  If I make a mistake, gcc's   
   > >>> warnings are a nice check.   
   > >>   
   > >> I guess you've never used printf-family functions via the FFI of   
   > >> another language!   
   > >>   
   > >>   
   > >   
   > > Vararg via FFI? Is it really a good idea?   
   > >   
   >   
   > It's covered by platform ABIs of both Windows and SYS V.   
   >   
      
   My question was not about technical possibility. I understand that with   
   enough of effort everything is possible.   
   I asked whether it is a good idea.   
   Is not it simpler for you and for your potential users to declare that   
   your language can not call external C functions with variable number of   
   arguments? To me it does not sound like this ability is either necessary   
   or very valuable.   
      
   Above I assume that we are talking about your scripting language.   
      
   W.r.t. your other language, I have no strong opinion. But my weak   
   opinion is that it also does not need it, possibly with exception for   
   ability to do few (very few, hopefully) historically idiotically   
   defined Unix system calls that can be handled individually as special   
   cases.   
      
   > This is printf called from an interpreted language with dynamic   
   > typing:   
   >   
   >    a := 12345678987654321   
   >    b := pi   
   >    c := "A"*10   
   >    d := &a   
   >    printf("%lld %f %s %p\n", a, b, c, d)   
   >   
   > Output is:   
   >   
   > 12345678987654321 3.141593 AAAAAAAAAA 00000000036A1D48   
   >   
   > (Strings are converted to zero-terminated form for the FFI.)   
   >   
   > If I try it like this however:   
   >   
   >    printf("%lld %f %s %p\n", d, c, b, a)   
   >   
   > It will go wrong (crashing inside the C library). With the built-in   
   > print feature, that doesn't happen:   
   >   
   >    println a, b, c, d   
   >    println d, c, b, a   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca