Talk:Guard (computer science)
This is the talk page for discussing improvements to the Guard (computer science) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||
|
Add non-Haskel language example
[edit]The guard clause topic should inclue the real world and cross-language pattern of returning from a method/function at the beginning if the boolean condition is met. This reduces the number of nesting levels.
C# example
bool A(int X, int Y, int Z) { if (X > Y) return; if (X > Z) return;
code to process X, Y and Z }
Just another name?
[edit]Is this just Haskell's name for a switch statement? —Preceding unsigned comment added by 130.76.32.15 (talk • contribs)
- Guard is a way more general concept, and any switch, case, or cond statement that uses guards in choosing the branch to take is more expressive than the alternative statements that use equality or set containment tests. --TuukkaH 20:51:12, 2005-09-07 (UTC)
- I know nothing about Haskell beyond what is written here, but reading this article it looks like a guard is basically a conditional in Haskell, as covered by the the section Guard (computer science)#Mathematics. In contrast, in most language is refers to a way of writing the code to avoid some levels of nesting, as covered by Guard (computer science)#Flatter code with less nesting. If that is the case, this should be made clear. If that isn't the case, we need to do a much better job of explaining what is the case. Yaris678 (talk) 15:20, 3 August 2023 (UTC)
Guard vs conditional
[edit]Is there a good reason to discuss Guard (computing) separately from Conditional (programming)? --Abdull (talk) 13:23, 5 October 2010 (UTC)
External links modified
[edit]Hello fellow Wikipedians,
I have just modified 2 external links on Guard (computer science). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
- Added archive https://web.archive.org/web/20050408114902/http://documents.wolfram.com/mathematica/book/section-2.3.5 to http://documents.wolfram.com/mathematica/book/section-2.3.5
- Added archive https://web.archive.org/web/20051129140339/http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html to http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—InternetArchiveBot (Report bug) 22:42, 24 October 2017 (UTC)
Needs first example to be in a language with simpler grammar
[edit]Including python's isInstance() in the first example requires special knowledge of Python. Use something more generic with typed and named parameters without relying on a language feature, library call or exception throw.
int Foo(int x) {
if (x < 0) return 0; return X + 1;