• Prime Mover (unregistered)
    Comment held for moderation.
  • dpm (unregistered)

    It is clear to me that the method name was actually spelled "evil()".

  • Rantanplan (unregistered)
    Comment held for moderation.
  • (nodebb)

    I admit, I'm guilty as charged: this is the simple most ridiculous thing I've seen in a loooong while, and I've never seen this exact "pattern" before in my life. My will to live has gone down a few notches, for sure.

  • Yikes (unregistered)

    It's nice because it avoids that pesky syntax highlighting! There are lots of great uses for JIT compiling for HPC. An easy one that comes to mind is if certain conditions change only at runtime and you'd normally need a plethora of if-statements to handle them. By evaluating those if-statements once to generate a streamlined block of code, you are allowing (nearly) all predictive execution by the compiler to be valid!

  • Yikes (unregistered) in reply to Yikes
    • predictive execution by the CPU
  • (nodebb)

    I've heard of someone doing this (or its moral equivalent), assembling their application classes dynamically by fetching snippets of source code out of a database. I'm really pleased that I didn't call the guy a dangerous lunatic to his face.

  • Jeremy (unregistered)
    Comment held for moderation.
  • MaxiTB (unregistered)

    I am confused, this code has nothing to do with C# at all, my guess is it's Java/Javascript because Application is in C# a static class (at least for WinForm applications) and method names in C# are always Pascalcase, not Camelcase.

    And yes, you can JIT compile code with the compiler as a service API, but that looks completely different.

  • Jonny (unregistered)
    Comment held for moderation.
  • Alex (unregistered)
    Comment held for moderation.
  • (nodebb)

    Dynamic Code Generation has been a part of the [full] Framework forever. In fact many of the key web technologies are based on it

    https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/dynamic-source-code-generation-and-compilation. Wrapping it as an eval (even neglecting MaxiTB's observation) is an "interesting" approach semantically, but that is about it...

  • MaxiTB (unregistered) in reply to TheCPUWizard

    Compiler as a service is around since Roslyn; it has nothing to do with CodeDOM ;-) Yes, you could emit IL before that; and yes, with expression trees it became easier, but before CaaS directly compiling code without going over MSBuild was not possible ;-)


    And again, the syntax is not valid C#.

  • EnormousTurd (unregistered) in reply to MaxiTB

    You have no idea what you are talking about.

  • club21ids (unregistered)
    Comment held for moderation.
  • arbaz khan (unregistered)
    Comment held for moderation.

Leave a comment on “Classic WTF: Pure Eval”

Log In or post as a guest

Replying to comment #:

« Return to Article