Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #123743

Re: Some kind of contextual modulo operator?

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Some kind of contextual modulo operator?
Date 2017-12-03 13:55 +1300
Message-ID <f8h0c3FrrtU5@mid.individual.net> (permalink)
References (14 earlier) <ImDUB.111267$W61.42286@fx08.am4> <f8gg0pFrrtU1@mid.individual.net> <0tFUB.85166$sg1.2798@fx43.am4> <f8gn8jFrrtU2@mid.individual.net> <09HUB.67556$7d.15807@fx05.am4>

Show all headers | View raw


On 12/03/2017 01:01 PM, bartc wrote:
> On 02/12/2017 22:20, Ian Collins wrote:
>> On 12/03/2017 11:06 AM, bartc wrote:
>>> On 02/12/2017 20:16, Ian Collins wrote:
>>>> On 12/03/2017 08:42 AM, bartc wrote:
>>>>> On 02/12/2017 16:09, David Brown wrote:
>>>>>
>>>>>> But C function calls are as easy as it gets.
>>>>>
>>>>> And apparently you DO think that! The docs for a typical C function are
>>>>> for the benefit of someone wanting to use the function FROM C. Any
>>>>> other
>>>>> information essential for using that function from elsewhere is not
>>>>> included.
>>>>
>>>> The platform ABI tells you all you need to know.
>>>
>>> About what, the call convention? Which on 32-bit Windows is variable
>>> anyway.
>>>
>>> It doesn't say anything about types that C code has invented and where
>>> the definitions rely on compiling a bunch of C header code.
>>>
>>> Take this function from SDL:
>>>
>>> extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *
>>> modal_window, SDL_Window * parent_window);
>>>
>>> If you're calling it from C, then it's straightforward: you include the
>>> requisite headers, define the appropriate variables of the right types,
>>> and call.
>>>
>>>    From another language however, you can't do that: you have to
>>> painstakingly track down the definitions of each type (and usually they
>>> will be structs consisting of a bunch of other types). You need to
>>> establish the layout and alignment of those structs so as to create
>>> exact duplicates. And if you're unlucky, there will be a mess of
>>> conditional code so that even that is not clear.
>>
>> So in C you can happily call something without understanding it,
> 
> I'm not sure you get it.

Oh I'm sure I do.

> In C you can do this:
> 
>     #include <I.h>
> 
>     struct T x,y,z;
> 
>     F(&a);
> 
> if you want to make use of function F() in a library, which exports its
> interface via a file I.h.
> 
> You don't need to know the details of struct T. You don't need to know
> about the other 100 private types that struct T is built on.

So why would you be calling a function with a type you don't know what 
to do with?  That is the point:  whether you are calling from C or 
another language, you have to know what the type is.  If you don't, why 
would you be using the function?  You are claiming that C interfaces are 
too complex to use because you have to understand them!

>> I'm saying the ABI + understanding what you are doing is all you need.
> 
> How does that help with my example above?

It tells you all you need to know.

> Yes eventually the job can get done, but it means spending an inordinate
> amount of time tracing functions, types and macros in C header files.

That's called understanding the function.

> But /that/ is the problem. Someone is just not that interested in C or
> its quirks, but in making use of a library.

Libraries define types as well as functions.  You can't use the latter 
without knowing the former.  If you do, you are fumbling around in the 
dark (something you appear to do often).

> The real problem is that there is no mainstream low-level language which
> can take on this task, and that could do a better job of it.

There isn't anything (except assembler) lower level than C.  If you 
think that you can design a language which provides libraries of just 
functions with no types, go ahead.

> It doesn't even need to be an actual language: Stylised C written using
> strict guidelines would do. But no one actually bothers doing that.

Yes they do.  POSIX did it, Solaris and the BSDs do it and more and more 
these days even Linux does it.

> Except perhaps me; the C I produce is very clean and very clear in
> comparison with most I've seen.

You need to look further.

>>> This stuff is always going to be a big job, but C and the way C is
>>> typically written makes it much harder than necessary.
>>
>> So that's why it has become the near universal interface language?  I've
>> often wondered why.
> 
> I don't know why; perhaps because there is no other choice and so it's
> effectively being forced down people's throats?

If there was a better choice, don't you think it would have gained a 
following over the past 40 odd years?

-- 
Ian.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-29 10:41 -0800
  Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-11-29 11:12 -0800
    Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-11-29 19:22 +0000
      Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-11-29 19:43 +0000
        Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-11-29 12:33 -0800
          Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-11-29 23:22 +0000
            Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-11-29 20:53 -0800
              Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-11-30 12:17 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 15:08 +0000
                Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-12-01 07:31 -0800
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-01 16:32 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 17:07 +0000
                Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-12-01 09:15 -0800
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-01 18:14 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 19:03 +0000
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-01 20:54 +0000
                Re: Some kind of contextual modulo operator? Keith Thompson <kst-u@mib.org> - 2017-12-01 12:09 -0800
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 21:56 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 23:11 +0000
                Re: Some kind of contextual modulo operator? supercat@casperkitty.com - 2017-12-01 15:16 -0800
                Re: Some kind of contextual modulo operator? David Brown <david.brown@hesbynett.no> - 2017-12-02 17:09 +0100
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-02 19:42 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-03 09:16 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-02 22:06 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-03 11:20 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 00:01 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-03 13:55 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 02:14 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-03 16:13 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 12:28 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 14:26 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-04 10:49 +1300
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-04 10:38 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 23:00 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-04 12:10 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-03 23:33 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-04 13:18 +1300
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-04 12:19 +0000
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-05 07:58 +1300
                Re: Some kind of contextual modulo operator? David Brown <david.brown@hesbynett.no> - 2017-12-04 00:30 +0100
                Packed structs (was Re: Some kind of contextual modulo operator?) scott@slp53.sl.home (Scott Lurndal) - 2017-12-04 15:02 +0000
                Re: Packed structs (was Re: Some kind of contextual modulo operator?) David Brown <david.brown@hesbynett.no> - 2017-12-04 16:34 +0100
                Re: Packed structs (was Re: Some kind of contextual modulo operator?) Keith Thompson <kst-u@mib.org> - 2017-12-04 09:23 -0800
                Re: Packed structs (was Re: Some kind of contextual modulo operator?) scott@slp53.sl.home (Scott Lurndal) - 2017-12-04 18:31 +0000
                Re: Packed structs (was Re: Some kind of contextual modulo operator?) supercat@casperkitty.com - 2017-12-04 15:37 -0800
                Re: Some kind of contextual modulo operator? supercat@casperkitty.com - 2017-12-04 08:39 -0800
                Re: Some kind of contextual modulo operator? "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2017-12-03 18:13 -0800
                Re: Some kind of contextual modulo operator? Ian Collins <ian-news@hotmail.com> - 2017-12-03 14:50 +1300
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-04 15:00 +0000
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-04 15:53 +0000
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-04 18:26 +0000
                Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-12-04 10:34 -0800
                Re: Some kind of contextual modulo operator? David Brown <david.brown@hesbynett.no> - 2017-12-03 19:40 +0100
                Re: Some kind of contextual modulo operator? David Kleinecke <dkleinecke@gmail.com> - 2017-12-03 11:35 -0800
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-04 14:59 +0000
                Re: Some kind of contextual modulo operator? Keith Thompson <kst-u@mib.org> - 2017-12-01 08:56 -0800
                Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-12-01 08:58 -0800
                Re: Some kind of contextual modulo operator? scott@slp53.sl.home (Scott Lurndal) - 2017-12-01 18:16 +0000
                Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-12-01 10:28 -0800
                Re: Some kind of contextual modulo operator? David Brown <david.brown@hesbynett.no> - 2017-12-01 20:19 +0100
                Re: Some kind of contextual modulo operator? Gareth Owen <gwowen@gmail.com> - 2017-12-01 22:22 +0000
                Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-12-01 07:49 -0800
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 16:54 +0000
                Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-12-01 09:34 -0800
                Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-12-01 18:48 +0000
                Re: Some kind of contextual modulo operator? jameskuyper@verizon.net - 2017-12-01 11:27 -0800
      Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-29 12:17 -0800
        Re: Some kind of contextual modulo operator? bartc <bc@freeuk.com> - 2017-11-30 12:27 +0000
          Re: Some kind of contextual modulo operator? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-30 06:11 -0800
    Re: Some kind of contextual modulo operator? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-11-29 15:02 -0500
  Some kind of contextual modulo operator? mcheung63@gmail.com - 2017-12-08 23:20 -0800

csiph-web