←back to thread

The Grammar According to West

(dwest.web.illinois.edu)
65 points surprisetalk | 1 comments | | HN request time: 0.203s | source
Show context
layer8 ◴[] No.45077545[source]
> Note the difference between "where" and "such that". "Where" is used when the preceding notation is being defined; "such that" is used when it is already defined and its value is being restricted.

I found this interesting. SQL and Swift use “where” for restrictions. Any other examples in programming languages?

If a programming language wanted to use a keyword for restrictions that isn’t “where” (and still is a single word, hence “such that” doesn’t qualify), what word would be suitable instead? “With”? “Having”?

replies(3): >>45077717 #>>45078657 #>>45089150 #
1. gizmo686 ◴[] No.45089150[source]
Haskell uses where in the sense the article describes.

E.g

   f x = y + 1
     where y = 2 * x
Haskell also has a "let" notation

    f x = let y = 2 * x
      in y + 1
> If a programming language wanted to use a keyword for restrictions that isn’t “where” (and still is a single word, hence “such that” doesn’t qualify), what word would be suitable instead? “With”? “Having”?

If? Python does so with it's list comprehensions:

  [ x for x in range(100) if x % 2 == 0 ]