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


Groups > comp.lang.c > #70338

Re: Improving the program, issues with logical operators, incorrect output

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Improving the program, issues with logical operators, incorrect output
Date 2015-09-12 14:50 +0200
Organization A noiseless patient Spider
Message-ID <mt16v8$8rb$3@dont-email.me> (permalink)
References (2 earlier) <49a5f4a4-8d02-4a48-a338-33a7ebaed71b@googlegroups.com> <lnoahbpc0y.fsf@kst-u.example.com> <c09228f5-8069-467b-a54f-ecadbf7a73a8@googlegroups.com> <ln37ynp0qm.fsf@kst-u.example.com> <db451fc1-efd9-4aac-8404-6b0e573286f3@googlegroups.com>

Show all headers | View raw


On 12/09/15 09:48, fir wrote:
> W dniu czwartek, 10 września 2015 02:38:32 UTC+2 użytkownik Keith Thompson napisał:
>>
>>      min(a,b) {
>>          if( a<b ) return(a);
>>          else return(b);
>>          }
>>
>> So apparently the 1TBS predates C.
>
> imo the { } blocking seems overal bad,
>
> this is mostly probably becouse imo it 'suggest' (as a side effect) that empty space (empty lines etc) are  'part'
> of the function body (and this is imo quite unintended and bad)
>
>        min(a,b)
>           if( a<b ) return(a) ;
>           else return(b);
>
> imo it would be probably better to use ony one enclosing mark (as the opening one after if, for and function header is obvious, Or maybe even detect end of the function by the begining of another one;
> (yet other option is to use two part named
> control structures (like do-while for example) [probably one mark blocks are better than two-marked, but probably no mark blocks are yet better)
>
> also this ; operators imo in todays times should be optional (and in maybe most better cases almost (if not totally) no present in code [on this i was already writing one year ago]
>
>        min(a,b)
>           if( a<b )
>              return a
>           else
>              return b
>
>
> this looks bare but it shows that such code is really simple witout the coat of
> gothic syntax
>

There are a few languages that use whitespace for structuring.  Occam 
and Python come to mind.  In Python, your function would be:

def min(a, b) :
	if a < b :
		return a
	else :
		return b



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


Thread

Improving the program, issues with logical operators, incorrect output Alla _ <modelling.data@gmail.com> - 2015-09-08 06:47 -0700
  Re: Improving the program, issues with logical operators, incorrect output fir <profesor.fir@gmail.com> - 2015-09-08 07:23 -0700
    Re: Improving the program, issues with logical operators, incorrect output Alla _ <modelling.data@gmail.com> - 2015-09-08 07:25 -0700
      Re: Improving the program, issues with logical operators, incorrect output fir <profesor.fir@gmail.com> - 2015-09-08 07:44 -0700
      Re: Improving the program, issues with logical operators, incorrect output Richard Heathfield <rjh@cpax.org.uk> - 2015-09-08 17:04 +0100
      Re: Improving the program, issues with logical operators, incorrect output Keith Thompson <kst-u@mib.org> - 2015-09-08 09:21 -0700
  Re: Improving the program, issues with logical operators, incorrect output Richard Heathfield <rjh@cpax.org.uk> - 2015-09-08 18:32 +0100
  Re: Improving the program, issues with logical operators, incorrect output Barry Schwarz <schwarzb@dqel.com> - 2015-09-08 15:53 -0700
  Re: Improving the program, issues with logical operators, incorrect output bartekltg <bartekltg@gmail.com> - 2015-09-09 15:42 +0200
  Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-09 16:11 +0200
    Re: Improving the program, issues with logical operators, incorrect output Richard Heathfield <rjh@cpax.org.uk> - 2015-09-09 16:01 +0100
      Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-09 21:11 +0200
        Re: Improving the program, issues with logical operators, incorrect output Richard Heathfield <rjh@cpax.org.uk> - 2015-09-09 20:42 +0100
          Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-09 22:23 +0200
          Re: Improving the program, issues with logical operators, incorrect output Keith Thompson <kst-u@mib.org> - 2015-09-09 13:41 -0700
            Re: Improving the program, issues with logical operators, incorrect output Richard Heathfield <rjh@cpax.org.uk> - 2015-09-09 22:21 +0100
            Re: Improving the program, issues with logical operators, incorrect output Les Cargill <lcargill99@comcast.com> - 2015-09-09 18:25 -0500
    Re: Improving the program, issues with logical operators, incorrect output Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-09-09 12:41 -0700
      Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-09 22:24 +0200
      Re: Improving the program, issues with logical operators, incorrect output Keith Thompson <kst-u@mib.org> - 2015-09-09 13:34 -0700
        Re: Improving the program, issues with logical operators, incorrect output Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-09-09 16:25 -0700
          Re: Improving the program, issues with logical operators, incorrect output Keith Thompson <kst-u@mib.org> - 2015-09-09 17:38 -0700
            Re: Improving the program, issues with logical operators, incorrect output fir <profesor.fir@gmail.com> - 2015-09-12 00:48 -0700
              Re: Improving the program, issues with logical operators, incorrect output fir <profesor.fir@gmail.com> - 2015-09-12 00:55 -0700
              Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-12 14:50 +0200
                Re: Improving the program, issues with logical operators, incorrect output fir <profesor.fir@gmail.com> - 2015-09-12 07:12 -0700
        Re: Improving the program, issues with logical operators, incorrect output David Brown <david.brown@hesbynett.no> - 2015-09-10 09:56 +0200
  Re: Improving the program, issues with logical operators, incorrect output gordonb.papec@burditt.org (Gordon Burditt) - 2015-09-11 17:18 -0500
    Re: Improving the program, issues with logical operators, incorrect output Barry Schwarz <schwarzb@dqel.com> - 2015-09-13 01:08 -0700
    Re: Improving the program, issues with logical operators, incorrect output Stephen Sprunk <stephen@sprunk.org> - 2015-09-13 19:03 -0500

csiph-web