Yep, I totally copped this pattern from Ruby
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u5tqk/
It seems to me, no one wants to use cpp for anything but C. Lots of people will defend its power, but you don't see it used on projects of other languages like you would 'make'.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u4dca/
While you can indeed run anything through it, using the C preprocessor with C# code is not a very widely accepted practice; and so that possibility is generally excluded when talking about the ca...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u473e/
> as far as I know there's no way to just run the code through > preprocessing like you can with C); You can run anything through cpp.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u3gge/
Unfortunately somebody somewhere is looking at this code and taking notes.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u3c7o/
Correct, of course. Although Mono does provide some compiler-as-a-service features, Eval and a REPL and so forth (strength of magic present varies depending on your perspective), largely facilita...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u3bxe/
Thanks for the thoughtful explanation.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u39u5/
The example they show is pretty useless compared to more powerful logging tools such as Apache Log4j
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u3641/
> Actually this is a feature I really like in (Common) Lisp (and miss > in Clojure): An empty list is equivalent to nil, so no null > coalescing operator for lists i...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u352n/
Actually this is a feature I really like in (Common) Lisp (and miss in Clojure): An empty list is equivalent to nil, so no null coalescing operator for lists is needed. For everything else, there...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2xgi/
It's pretty common to do it that way in e.g. Python: def foo(items): lst = items or [] ... or Ruby: def foo items items ||= [] ... end Though generally, I'd just let that ...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2rpg/
And that's what I like about languages with preprocessors (obviously you could always make a preprocessor for any language, but any solution that requires more specialized tools is a bad solution...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2qhc/
Then, again, I guess many so called "C# programmers" can't use google and don't really know anything about C# :)
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2qe9/
Yeah just didn't think to implement it like that (Enumerable.Empty that is)
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2qbc/
> I'd heard of the first but not the second.
It's the same feature in both cases. Unless you're considering
Enumerable.Empty
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2q3b/
This sadly reads like a normal design meeting in big software shops. If I had read any of that post to them they wouldn't think twice about it.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2p7n/
The preprocessor strips out comments before doing macro expansion. So that's equivalent to #if NDEBUG #define DEBUG #else #define DEBUG #end That is, completely pointless.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2ov1/
I'd heard of the first but not the second.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2nmt/
#if NDEBUG #define DEBUG #else #define DEBUG // #end No use in generating evaluations you know become static at compiletime. Yes I know the compiler will optimize if (true) and if (f...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2l0f/
Not a Java expert, but can't you do that with @annotations and a custom class loader that removes annotated functions ?
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2j7m/
This feature is not little-known.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2fso/
Does this seem like a terrible feature to anyone else? Code is already hard enough to read and follow, but now I have to consider the possibility that the method calls are silently being elided! ...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2b6u/
Here's another little-known feature, the null coalescing operator: void Foo(string bar) { // Now we don't have to check bar for Null bar = bar ?? "Default"; // Read '??' a...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u2ana/
Scala has it.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u29oc/
I normally try to avoid using the C# debug option or having different copy path for different build type since the code path will be different for debug and release. In my mind, it might cause ne...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u29fy/
A language's compiler being written in itself doesn't imply anything about macros or metaprogramming ability -- it's merely an implementation curiosity. Microsoft's C# compiler is C-based because...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u278r/
C# 5.0 will be written in C#, so macros and metaprogramming assumptions about C# should be revisited then.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u24s5/
I have my popcorn. Ready for part 2, please.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u24k6/
> how well know a feature is, is related to what? It's related to the number of people who know of that feature.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u21y2/
It's not a preprocessor though (as its handled during compilation, as far as I know there's no way to just run the code through preprocessing like you can with C); and certainly not a macro prepr...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1vqh/
Plus, the #define all has to be at the top. @Whoot for actually being useful for what you want it for without screwing up the whole rest of the language.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1uq6/
That's what the preprocessor is for.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1skt/
They should do something like that for Java, too. Or pretty much any language... especially in performance-critical parts of a program it's nice to be able to have log calls that will completely ...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1mf9/
If there is a particular class you need that on a lot, and that's probably the case, then you can set the [] operator to do what you want since it can contain an expression. If you're using this ...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1jrq/
I think the limited preprocessor in C# is a feature, have you seen what people have done in C and C++? :D
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1iyr/
no? apart from being a basic feature (#DEFINE is a very common feature in many languages, one of the first I've learned in C#, exactly for debug purpose), it is neither hidden nor obscure, it's ...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1hdf/
There is no correlation between the date of implementation and how well known it is.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1glu/
little known?? it's there from version 1
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1fx1/
> C# doesn't have a macro preprocessor Well it sort-of does, but it's far less capable that C's. It only supports "#define" (symbol only, no value e.g. "#define DEBUG", not "#define FOO 3"...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1fmv/
this is little known?
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1egu/
Not little known to anyone who has read Effective C#. I read that after 2 years of working in C# and learned quite a bit (I also knew quite a bit of it.) However, it was written for framework v...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1a3m/
> ...I use the ternary op too often If you haven't already, try some functional programming. The ternary op is really all you have for "if"-style branching :) (Except it usually looks a...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u19mp/
There's always attrgetter('b', 'c')(a) but your coworkers are going to hate you for it unless you put it into a utility method. But really, I find it very weird that you'd use such a cons...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1486/
I thought it'd be about how C# has a feature I'd like in Python, but for which I'm too incapable with grammar munging to produce (Nevermind the conservative dev of python): a.(b if c else d) inst...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u12ys/
That's correct. It's closer in practice to a C macro that's conditionally defined as either nothing, or a call to the method based on an define; as opposed to sprinkling "#ifdef DEBUG" everywhere...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1287/
The method is still compiled and included in your output regardless of whether the compile settings of the assembly containing the method match the conditional or not. The reason for this is beca...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u1233/
Yep, it would be pretty useless otherwise I think. There are some limitations as well; conditional methods must return void and not use any out parameters. http://msdn.microsoft.com/en-us/lib...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u10vi/
Yes. That way you'll not be surprised with a host of errors when the flag is defined and the code IS included. And the compiler has to do some work anyway so it can recognize the method to skip...
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u10oi/
The compiler uses time checking code which is sometimes compiled. The C# compiler is actually pretty zippy despite some things like this.
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u10f8/
I don't get it. The compiler wastes time checking code which isn't compiled?
https://www.reddit.com/r/programming/comments/cocww/deleted_by_user/c0u0vu9/