jameskuyper@alumni.caltech.edu: Jun 19 09:25AM -0700 On Tuesday, June 19, 2018 at 9:04:47 AM UTC-4, Rick C. Hodgin wrote: > finished: > While "pass" should only ever be valid, what do you think about > a need to test the unexpected condition with the "default:" ? As Öö Tiib points out, that's a weird way to write the code; it could be written much simpler. But let's assume that it's some more reasonable context, such as removing the break statements, so each pass through the loop executes a smaller subset of the code. The loop-switch then provides a convenient way to re-use the code that's shared between different passes through the loop. My own general rule is that if the validity of a variable's value is clearly and absolutely guaranteed by code within the same source code file, there's no need to write code to deal with the possibility that it's invalid. Otherwise, it's mandatory to check the validity at least once between evaluation of any code that could cause it to become invalid, and the execution of code that would be problematic if it is invalid. This rule works fairly well for me, in part because I don't believe in writing source code files that are so large that it's hard to verify such things. Encapsulation helps too, because it often avoids having to check code in other modules. |
Lew Pitcher <lew.pitcher@digitalfreehold.ca>: Jun 19 12:38PM -0400 Rick C. Hodgin wrote: > // Code common to all passes goes here > } > finished: Gaak! WTF are you doing? Clearly, you've coded logic of the "Loop/Switch" antipattern (https://en.wikipedia.org/wiki/Loop-switch_sequence). Don't do that. > While "pass" should only ever be valid, what do you think about > a need to test the unexpected condition with the "default:" ? I think that you should not code to that antipattern. Instead, you package your "common code" into a function or macro. Then you unroll the loop, and invoke your "common code" after each discrete step. -- Lew Pitcher "In Skills, We Trust" PGP public key available upon request |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 12:42PM -0400 On 6/19/2018 12:38 PM, Lew Pitcher wrote: > Gaak! ... are you doing? If you have any desire to communicate with me, and I with you, then remove profanity from your posts. I'm fine with your decision either way, Lew. -- Rick C. Hodgin |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 12:43PM -0400 On Tuesday, June 19, 2018 at 11:51:13 AM UTC-4, Öö Tiib wrote: > finished: > That is clearly superior way to write same thing as it is more > straight and robust? Your rewrite is not the same. It would need to be this: int pass = 1; // Some code unique to pass-1 goes here // Common code here pass = 2; // Some code unique to pass-2 goes here // Common code here pass = 3; // Some code unique to pass-3 goes here // Common code here ----- My question was more along the lines of needing the default: clause there, or if, given the constraint that pass will only be 1..3 in this case, is it needed? And why do you think that? -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 19 05:50PM +0100 On 19/06/2018 17:42, Rick C. Hodgin wrote: > If you have any desire to communicate with me, and I with you, then > remove profanity from your posts. > I'm fine with your decision either way, Lew. OMFG, what profanity you egregious cunt of a cock womble? /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
scott@slp53.sl.home (Scott Lurndal): Jun 19 04:50PM > > Gaak! ... are you doing? >If you have any desire to communicate with me, and I with you, then >remove profanity from your posts. WTF you talkin' about, willis? |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 10:06AM -0700 On Tuesday, June 19, 2018 at 12:50:54 PM UTC-4, Mr Flibble wrote: > [snip] *plonk* If you want to be restored, you know how to email me. I will require no more than an apology, and the promise to not treat me with such disrespect in the future. -- Rick C. Hodgin |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 10:06AM -0700 On Tuesday, June 19, 2018 at 12:51:05 PM UTC-4, Scott Lurndal wrote: > [snip] *plonk* If you want to be restored, you know how to email me. I will require no more than an apology, and the promise to not treat me with such disrespect in the future. -- Rick C. Hodgin |
jameskuyper@alumni.caltech.edu: Jun 19 11:01AM -0700 On Tuesday, June 19, 2018 at 1:07:08 PM UTC-4, Rick C. Hodgin wrote: > If you want to be restored, you know how to email me. I will > require no more than an apology, and the promise to not treat > me with such disrespect in the future. You deserve more respect than that? Why? You don't deserve to receive any more respect than you give to other people, and you pay no respect to the rules of usenet etiquette about using appropriate forums to discuss your religious beliefs. |
"Öö Tiib" <ootiib@hot.ee>: Jun 19 11:07AM -0700 On Tuesday, 19 June 2018 19:43:23 UTC+3, Rick C. Hodgin wrote: > pass = 3; > // Some code unique to pass-3 goes here > // Common code here I usually put common code that I need several times into a function. > My question was more along the lines of needing the default: clause > there, or if, given the constraint that pass will only be 1..3 in > this case, is it needed? And why do you think that? That default can only happen because of programming error. For example you extend passes to 1..5, add handler to pass 4 but forget to add pass 5. I would leave it there but make it to abort or assert(false). Such checks help to detect errors as early as possible. There are no much point to handle it in any other way because programs can not fix programming errors; only programmers can. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 02:16PM -0400 > any more respect than you give to other people, and you pay no respect > to the rules of usenet etiquette about using appropriate forums to > discuss your religious beliefs. The things I teach people are not religion. They're about forgiveness of sin and the gaining of eternal life. Religion has nothing to do with it. Religion destroys men. What He's offering frees men and restores them to eternity. Bottom line: Forgiveness of sin is required to enter in to the Kingdom of God. The One I teach about hands out total forgiveness for the asking. ----- It's important, James. There are no more important things. And in addition, as I've cited many times, Matthew 28:18 states that all authority in Heaven and Earth has been given to Him, and that He then gives a command to all disciples to "go ye therefore and teach all nations." The reference there to "all nations" is not of geography or land or buildings or structures. It's the people who live in those nations. Someday everyone here will see the value in my teachings. My prayer for all of them is it's before they leave this world so they are for- given, and enter into eternity alive. -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 19 07:53PM +0100 On 19/06/2018 19:16, Rick C. Hodgin wrote: >> to the rules of usenet etiquette about using appropriate forums to >> discuss your religious beliefs. > The things I teach people are not religion. Christianity is a religion mate. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 12:02PM -0700 On Tuesday, June 19, 2018 at 2:53:24 PM UTC-4, Mr Flibble wrote: > On 19/06/2018 19:16, Rick C. Hodgin wrote: > > The things I teach people are not religion. > Christianity is a religion mate. The world sees Christianity as a religion, Leigh. It's not at all what I'm talking about. I'm talking about forgiveness of sin through the atoning sacrifice of Jesus Christ at the cross. It is about what it written in John 3: https://www.biblegateway.com/passage/?search=John+3&version=KJV 3 Jesus answered and said unto him, Verily, verily, I say unto thee, Except a man be born again, he cannot see the kingdom of God. You must be born again, Leigh. It's the only way to enter into the Kingdom of God. It's not religion. And religion is not what I teach. I teach that you are a sinner and you must be forgiven if you want to escape literal Hellfire. It's the same for all people world-wide. -- Rick C. Hodgin PS -- I still see your posts on Google Groups. If you want to learn more about this, the Bible's right there. The churches are in your city. There are forums dedicated to this type of teaching. There are YouTube videos. And more. Are you willing to seek the truth? Are you willing to test your beliefs against true teachings of God? |
Keith Thompson <kst-u@mib.org>: Jun 19 09:18AM -0700 David Brown <david.brown@hesbynett.no> writes: [...] > or b", which is the maximum of two boolean values. If you like > axiomatic set theory and the Peano integers, then "maximum" is the same > as set union ∪, and "minimum" is set intersection ∩. I would oppose defining either "a ∨ b" or "a \/ b" as max(a, b) because most readers (myself included) are going to assume the symbol means "min". I would oppose defining either "a ∨ b" or "a \/ b" as min(a, b) because it's apparently the opposite of mathematical usage. I'm not at all convinced that min and max operators, with whatever syntax, are worth adding to the language at all. If they were to be added, agreeing on a syntax would be difficult. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> 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" |
jameskuyper@alumni.caltech.edu: Jun 19 09:32AM -0700 On Monday, June 18, 2018 at 2:54:55 PM UTC-4, Rick C. Hodgin wrote: > b \/= a; // Equivalent of b = min(b, a) > // Max of b and a is assigned to b > b /\= a; // Equivalent of b = max(b, a) In IDL, "a < b" gives the minimum of a or b, and "a > b" gives the maximum. This can be particularly useful when either operand is an array. "a lt b" and "a gt b" are how you do the equivalent of C's "a < b" and "a > g". Most IDL newbies get burned with this at least once before learning that distinction. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 12:48PM -0400 > array. "a lt b" and "a gt b" are how you do the equivalent of C's > "a < b" and "a > g". Most IDL newbies get burned with this at least once > before learning that distinction. I've tried to come up with a single-character operator for this. I like Stefan's idea of the T-like character, and the inverted T-like character, but they can't easily be typed. I suppose using T and !T might work. If anyone has better ideas, I'm all for them. So far, I like the /\ max and \/ min combos. They can be rendered graphically in the editor into some other character. -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 19 05:52PM +0100 On 19/06/2018 17:48, Rick C. Hodgin wrote: > If anyone has better ideas, I'm all for them. So far, I like the > /\ max and \/ min combos. They can be rendered graphically in the > editor into some other character. You like them? So what? They would never make it into C++ and we don't care about your kooky god bothering custom language. -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jun 19 03:52PM +0100 On Tue, 19 Jun 2018 14:43:22 +0200 David Brown <david.brown@hesbynett.no> wrote: [snip] > With enough effort, you can get a variadic hygienic polymorphic min and > max macro in C11. Do you know enough about C11 macros to show how that is done? (I would be interested for that matter in how you get a non-variadic hygienic macro in C, if that is by using a different technique from the one I mentioned. I am still stuck on C89/90 as far as C pre-processors are concerned.) |
David Brown <david.brown@hesbynett.no>: Jun 19 08:18PM +0200 On 19/06/18 17:47, Rick C. Hodgin wrote: > As I say, I wouldn't waste my time worrying about anything related to me > or CAlive, David. Life's too short. Let it go. I am not worrying about you or CAlive. I'm just giving general advice to people who post in groups I follow. Perhaps my posts will help people, perhaps they will lead to discussions, perhaps I will learn from other posts. That's my motivation. Whether you agree with what I write or not is up to you - I really don't mind one way or the other. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jun 19 02:22PM -0400 On 6/19/2018 2:18 PM, David Brown wrote: > I am not worrying about you or CAlive. Good to hear. -- Rick C. Hodgin |
David Brown <david.brown@hesbynett.no>: Jun 19 08:26PM +0200 On 19/06/18 18:18, Keith Thompson wrote: > I would oppose defining either "a ∨ b" or "a \/ b" as max(a, b) > because most readers (myself included) are going to assume the > symbol means "min". Agreed. > I would oppose defining either "a ∨ b" or "a \/ b" as min(a, b) > because it's apparently the opposite of mathematical usage. Agreed. > I'm not at all convinced that min and max operators, with whatever > syntax, are worth adding to the language at all. If they were to be > added, agreeing on a syntax would be difficult. Agreed. The mathematical usage of these symbols can be surprising to people not familiar with these fields. And even those that know them - for example, in boolean logic - may not have considered them as maximum and minimum operators. But I would be opposed to having symbol choices that are a direct opposite of the mathematical ones. So /if/ I were adding such operators to a language (and I almost certainly would not), I'd be inclined to look at something different - such as the old gcc <? and >? operators. Perhaps APL's maximum and minimum operators a⌈b and a⌊b would be an option with existing practice, but which would be equally unknown to almost everyone. |
David Brown <david.brown@hesbynett.no>: Jun 19 08:29PM +0200 On 19/06/18 18:01, Keith Thompson wrote: > Which is why it's traditional to write macro names in all-caps (MIN() > and MAX()) so the reader is reminded that they're macros and can have > odd interactions with side effects. Personally, I am not a fan of all-caps macro names in general. But I think they help in cases like this, where they indicate that you have to avoid side-effects (or be /really/ sure you know what you are doing!). If a function-like macro is as safe as a function - perhaps using gcc's extensions here - then I prefer a small letter name. |
Robert Wessel <robertwessel2@yahoo.com>: Jun 19 02:00PM -0500 On Tue, 19 Jun 2018 20:26:31 +0200, David Brown >such as the old gcc <? and >? operators. Perhaps APL's maximum and >minimum operators a?b and a?b would be an option with existing practice, >but which would be equally unknown to almost everyone. Old HP-2000 BASIC just used MIN and MAX as the binary infix operators. I also remember another language, which I can't remember right now, that also had binary infix MIN and MAX operators, but used them in the reverse sense (a MAX 10) would be interpreted as use A, but with a maximum value of 10, so in effect it was what was more commonly MIN IIRC, it also had more conventional MIN() and MAX() functions. Presumably I remember that because it bit me on the posterior. Probably not very applicable to C. |
Lynn McGuire <lynnmcguire5@gmail.com>: Jun 19 01:17PM -0500 "What's all the C Plus Fuss? Bjarne Stroustrup warns of dangerous future plans for his C++" https://www.theregister.co.uk/2018/06/18/bjarne_stroustrup_c_plus_plus/ "Language creator calls proposals 'insanity'" Hat tip to: https://www.codeproject.com/script/Mailouts/View.aspx?mlid=13685&_z=1988477 Lynn |
ram@zedat.fu-berlin.de (Stefan Ram): Jun 19 12:21PM >Off the top of my head -- and based on absolutely no relevant >experience -- I would expect the addition of a new digraph or trigraph >to be almost as unpopular but with a better chance at success. On could use "⊤" for "max" and "⊥" for "min" akin to their usage in lattice theory. 2 ⊥ 8 == 2 2 ⊤ 8 == 8 |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment