News for hackers. Stuff that matters.
Re:How many keywords I can fit into a single C# expression? by lalaithion on Thursday February 07, 2019 @04:44AM (#19104123)
Haskell:

    case x of _ -> True 
is a valid expression of type boolean for all values of `x`.

    if b then True else False
is a valid expression if `b` is a boolean.

These can be nested recursively infinitely, but that's not very interesting, so let's move on.

    let x = z in y
this is another valid expression for any y and z values.

    do e
this is a valid expression if e is a type that implements the Monad typeclass.

Basically every other keyword is for type declarations or module importing, and those both aren't expressions, and seem much harder.

So, my final expression is:

    let x = x in do case if let x = x in True then False else False of _ -> return False
where `in do case if let` is my longest expression.
Re:How many keywords I can fit into a single C# expression? by FBT on Thursday February 07, 2019 @07:51AM (#19104876)
You can add `infixl` or `infixr` to that:

    let x = x in do case if let infixr 7 `x`; x = x in True then False else False of _ -> return False
And with the RecursiveDo extension, you can throw `mdo` in there:

    let x = x in mdo do case if let infixr 7 `x`; x = x in True then False else False of _ -> return False
That brings us to `in mdo do case if let infixr` as the longest string of consecutive (distinct) keywords that I can come up with in Haskell.
Re:How many keywords I can fit into a single C# expression? by victorNicollet on Thursday February 07, 2019 @07:29AM (#19104780)
Given the rule:

  expr := 'if' expr 'then' expr 'else' expr
An expression may start with a sequence 'if if if if ...' of arbitrary length (and will contain that same number of 'then' and 'else' keywords, although not as a sequence).
Re:How many keywords I can fit into a single C# expression? by FBT on Thursday February 07, 2019 @07:55AM (#19104886)
A simpler variation of the same concept is to use the fact that for every expression `expr`, `do expr` is a valid expression, allowing you to start a sequence with any number of `do`s.

But the challenge as I see it is to stack as many distinct keywords in a row. In javascript you can do the same thing with `await`: for every expression `expr`, `await expr` is a valid expression, so you can start with a sequence of any number of `await`s. That's great, but ultimately not a challenge: the real puzzle is in stacking as many unique keywords as possible.

Re:How many keywords I can fit into a single C# expression? by lelf on Thursday February 07, 2019 @07:56AM (#19104894)
> do e > this is a valid expression if e is a type that implements the Monad typeclass.

That is not necessary,

  do do do ()
Re:How many keywords I can fit into a single C# expression? by majewsky on Thursday February 07, 2019 @08:26AM (#19105034)
> where `in do case if let` is my longest expression.

Not every string of tokens is an expression.