Hacker News new | past | comments | ask | show | jobs | submit login

Since C# is starting to look more like JavaScript (i.e. local functions) and vice versa (i.e. arrow aka lambda expressions). I'm going to throw my pocket change into a couple features I've been growing old hoping to see:

1. Regex expressions just like Regexp in JS:

    /^\s+$/.IsMatch("  "); // or
    Regex r = /^\s+$/;
2. DateTime expressions, similar to regex, something like:

    DateTime clockTowerLightning = #1955/11/12 10:04PM#;



> 1. Regex expressions just like Regexp in JS:

I don't know about the current state of C#'s grammar, but ambiguities between this regex construct and eg. division contributes to the complexity of correctly parsing JavaScript code.

https://tc39.github.io/ecma262/#sec-ecmascript-language-lexi...


I'll take DateTime literals, for sure. But only if they require using ISO date format. A slight munge of omitting the timezone to mean 'system local timezone' would be fine too.

My main objection is over the month/day confusion with other formats. Is that November, or December?


ISO-serialized datetimes are the only serialized datetimes. At least if you want to avoid painfulness. Similarly, UTC is good. If there's one thing I've learned, it's that, for my own sanity, datetimes should be localized and formatted at the last possible instant, just before a human has to see them, and kept in a consistent, canonical form at all other times.


To be clear, local functions long predate Javascript. Though a handy regex notation would be nice, I could've used that on a couple projects that I had (corporate environment) to do in C# when it wasn't really best suited to the task (at least in terms of brevity/clarity compared to other languages like python or perl for generating reports and similar behaviors.


Algol and Lisp already had local functions....


For item 1, extension methods and implicit conversions would get you really close:

Definition: https://gist.github.com/noblethrasher/5edffb4cb2efa4ed9174fb...

    //Usage: 

    var is_match = "  ".IsMatch("^\s+$");

    //OR

    regexp rgx = "^\s+$";

    is_match = rgx.IsMatch("   ");


The first is almost certainly better off as it is in F#: active patterns. That'll let you define patterns that'll execute arbitrary code to match, making regex a simple library feature, vs a special one-off. C# should have focused on having proper extensible syntax vs hard coding random features (like duck typed foreach or collection initializers).

But given the constraints of mscorp and the target users perhaps they made the right decisions.


DateTime literals... something I wish C# would borrow from VB.NET




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: