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


Groups > alt.os.development > #8806

Re: Smaller C

From "James Harris" <james.harris.1@gmail.com>
Newsgroups alt.os.development
Subject Re: Smaller C
Date 2015-09-14 23:17 +0100
Organization A noiseless patient Spider
Message-ID <mt7gth$cmh$1@dont-email.me> (permalink)
References (16 earlier) <op.x4v45jxsyfako5@localhost> <mt3fgt$jot$1@dont-email.me> <op.x4wjvxy0yfako5@localhost> <mt4ga8$gku$1@dont-email.me> <op.x4xiljipyfako5@localhost>

Show all headers | View raw


"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message 
news:op.x4xiljipyfako5@localhost...
> On Sun, 13 Sep 2015 14:48:24 -0400, James Harris 
> <james.harris.1@gmail.com> wrote:
>
>> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message
>> news:op.x4wjvxy0yfako5@localhost...
>>> On Sun, 13 Sep 2015 05:28:45 -0400, James Harris
>>> <james.harris.1@gmail.com> wrote:
>>>> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message
>>>> news:op.x4v45jxsyfako5@localhost...
>
>>>> You can modify your local copy of x in the function but the 
>>>> compiler
>>>> should stop you modifying your y and w (thereby giving you 
>>>> assurance
>>>> in
>>>> a long function that you can always access the original values
>>>> anywhere
>>>> in that function knowing that no other part of the function code 
>>>> has
>>>> changed them).
>>>
>>> s/updated/changed/
>>>
>>> I take issue with your use of "updated" when you meant "changed" 
>>> here.
>>> To me, "updated" means being modified and returned from the 
>>> function.
>>
>> Semantics nonsense (IMO)! Whether you say that the local copy is
>> updated/changed/modified/altered or whatever, all mean the same 
>> thing.
>
> Well, I'm not looking to provoke an argument on this issue, but I very
> **STRONGLY**  disagree with your opinion here.  I just didn't want to
> come off as angry or hostile towards you when I take issue with your
> opinion ...

That's OK. This is a discussion group after all and we have different 
opinions. I recognise that my opinion is just an opinion too. I added 
the "(IMO)" for that reason. The Semantics nonsense! part was just my 
surprise that you had seemed to attach a different semantics to a single 
word and build so much on that different interpretation.

> I programmed in PL/1 for a number of years and learned from it that
> pass-by-reference is all you need.  You don't need pass-by-value at
> all.

Sure.

> I literally used pass-by-value only once for PL/1.

That takes me back. You mean PL/1 let you choose the passing mode? I 
hated PL/1.

> One of C's
> largest mistakes, if not it's biggest, was pass-by-value being default
> instead of pass-by-reference.

Again, I am surprised you feel that way. As you know, any value can 
effectively be passed by reference by passing its address. That doesn't 
work for expressions but if a compiler passed by reference it would 
still have to find space for such results.

>> Whichever word you use the local copy is still the one affected,
>> not the caller's copy.
>
> IMO, not true.
>
> From what I've seen, I'm confident that most C programmers use
> pass-by-reference which passes the modified value back to the caller.

That's easy to do.

> The exception is if they wish to intentionally preserve the passed
> value in the caller, which is rarely needed.

OK. Wow! I wouldn't want a callee to be able to change my vars without 
me specifically letting it do so.

> C is most effective
> when used as a pointer and integer based language.

Interesting view.

...

>> Or
>>
>> 4) Use 'const' where you can so that the compiler will do the check 
>> for
>> you. (And it makes a useful addition to the documentation for free.)
>
> Which is still a waste of time and overcompensation for an event which
> you're not even sure has any likelyhood at all that it will ever occur 
> ...
>
> You can call it "proactive" or "cautious" if you wish, and maybe the
> cost of doing so is trivial to you, but without having any rational
> justification at all for doing this, AFAICT, why would you? ...

...

>> Or,
>>
>> Why would you make a function or, worse, a variable accessible to
>> every module in your project unless it needed to be?
>
> What modules?

Different source code files.

> As stated elsewhere, most of my programs are
> single file.  Those that aren't, don't have namespace collisions
> due to the happenstance of having different purposes.

Sure. Your choice.

> Who or what is going to use them?  Please answer that.  You keep
> avoiding defining who or what is going to use them or when.  I.e.,
> you seem to be "solving" a problem for which you can't accurately
> define or articulably describe to me.

I am not avoiding anything. Use different source files? Use variables 
and functions which are private to a single module, you mean? Me for 
one. I can only speak for myself.

> Why would other code use them?  The other code already has access
> to the functions which modify these supposed variables.  With all
> the emphasis on portable C code in the C community, I find it hard
> to believe that you'd believe people would _intentionally_ decide
> to use variables they have no need to access.  Obviously, I'm
> excluding hackers or other malicious people by default.

Some would! Others might introduce conflicts by accident. I might even 
do that myself if I went back to a piece of code after 6 months or more.

> If overly cautious or paranoia over "security" or "safety" is your
> driving motivation for doing these things, you should say so.

No. Sensible precautions, though.

...

>> Where it's appropriate you *lose* absolutely nothing by using
>> static at file scope. You gain a good deal.
>
> When is it appropriate?  Other code shouldn't be using your code's
> variables, unless they were intended to be used as externs.

Do you leave your front door unlocked because other people shouldn't be 
coming in without your say so? Do the countries of Europe open their 
borders because migrants and refugees won't cross freely? Er, strike 
that last one!

> Yes, you lose time, and perhaps inability to link to a variable that
> should've been exportable, but was erronously marked 'static'.

If it was erroneously marked then you can unmark it.

...

I have snipped the rest as it seems to go over similar ground. The 
bottom line is that I know from past discussions and here that you like 
large open projects, single source files, to be able to bypass 
interfaces etc. That's your choice. I prefer modularity.

James

Back to alt.os.development | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-11 20:39 -0700
  Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-12 04:24 -0400
    Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-12 03:17 -0700
      Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 03:28 -0400
    Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-12 19:12 +0100
      Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-12 17:09 -0700
      Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-13 11:10 +0100
        Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 23:13 -0400
          Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-14 09:08 +0100
            Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 02:23 -0400
  Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-08-15 02:12 -0700
    Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-06 15:54 -0700
      Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-07 12:19 -0700
        Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-07 13:30 -0700
          Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 19:38 -0700
            Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 19:49 -0700
            Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 20:58 -0700
            Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-10 01:45 -0700
              Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-10 10:45 -0700
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-10 23:20 -0700
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-11 09:26 +0200
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-11 09:50 +0200
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-11 00:58 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 17:38 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-11 23:39 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 19:39 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-12 11:22 +0100
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:21 -0700
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-12 21:53 +0200
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:37 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 09:49 +0100
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 12:58 +0200
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 07:32 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:05 +0100
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-14 13:19 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-15 00:01 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-18 14:48 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-26 16:23 -0400
                Re: Smaller C James Harris <james.harris.1@gmail.com> - 2015-09-27 00:23 +0100
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-26 16:37 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:17 -0400
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:24 -0400
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:46 -0400
                Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-16 16:14 +0000
                Re: Smaller C Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-23 13:20 -0500
                Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-27 13:52 +0000
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:28 -0400
                Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-16 16:31 +0000
                Re: Smaller C Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-23 13:20 -0500
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-18 16:21 +0100
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-20 17:25 -0700
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 12:43 +0200
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 09:21 +0100
                Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 13:02 +0200
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:09 +0100
                Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 13:32 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 18:51 -0400
                Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 18:16 -0700
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:36 -0700
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-12 11:56 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:45 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 10:28 +0100
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 02:53 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:17 -0400
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 16:54 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 21:39 -0400
                Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 20:31 -0700
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 09:03 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:48 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 21:33 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-14 23:17 +0100
                Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-20 17:37 -0400
                Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-20 23:46 +0100
  Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 21:37 -0700
    Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 22:29 -0700
      Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 03:25 -0700
        Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 11:18 -0700
          Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 11:39 -0700
          Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:47 -0400
            Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:31 -0400
          Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 02:00 -0700
            Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:31 -0400
            Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-13 09:15 -0700
    Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:45 -0700
      Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 10:55 -0700
  Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-15 19:23 -0700
    Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-16 03:03 -0700
      Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-16 10:17 -0700

csiph-web