|
Message Removed
modified 1-Feb-23 10:22am.
|
|
|
|
|
What languages, wishlists do you have for your favorite programming languages?
C and where applicable, C++:
preprocessor definitions that are private to the actual (in this case header) file they are contained in.
namespaces that are private to their header.
and/or a standard way to separate the implementation of templates into a cpp file
a way to predeclare templates (not template instantiations) such that you can access them before they are defined.
C#:
Mainly I want its code generation to have DSL (domain specific language) capabilities. This means you can create code generation facilities that introduce new keywords into the language, for doing things like AOP and cross-cutting functionality orthogonal to any specific class. The only problem with it is I think it would be overused.
To err is human. Fortune favors the monsters.
|
|
|
|
|
Some of your desiderata can already be approximated in C++, at least.
honey the codewitch wrote: preprocessor definitions that are private to the actual (in this case header) file they are contained in.
With the exception of conditional compilation, I have little use for the preprocessor in C++. Defining an anonymous namespace inside a named namespace will allow scoping of C++ (not preprocessor) definitions even in a header file.
honey the codewitch wrote: namespaces that are private to their header.
You already have something close to this in C++ - define a namespace in the header with an anonymous internal namespace. Only functions declared in the (named) namespace may access the definitions in the anonymous namespace.
namespace foo
{
namespace
{
int bar();
}
}
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
How did I not know about that?
Thanks!
To err is human. Fortune favors the monsters.
|
|
|
|
|
honey the codewitch wrote: you can create code generation facilities that introduce new keywords into the language
This will be a nightmare for code maintenance. It's hard enough keeping code sensible so that any dev can step in and understand and safely maintain it, what with all the syntactic sugar being added. Allowing this to be non-standard and ad-hoc will just massively increase the surface area of confusion.
cheers
Chris Maunder
|
|
|
|
|
In C# and C++ an "in" and "!in" operators. For example, if we have"
if(var1 == param1 || var1 == param2 || !(var1 == param3))
{
}
to be able to translate to:
if(var1 in (param1, param2, !param3))
{
}
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
And an isnt operator, to avoid !( x is y ) ?
|
|
|
|
|
Can we also have the redneck version called aint ?
Jeremy Falcon
|
|
|
|
|
How about the "aint not" operator?
(Hillbilly?)
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Daniel Pfeffer wrote: How about the "aint not" operator?
That would be t'aint
PartsBin an Electronics Part Organizer - An updated version available!
JaxCoder.com
|
|
|
|
|
I reckon so.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
and for set inclusion, the all_yall function.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
You totally read my mind.
I want this. I need this.
if (var1 in all yall (param1, param2, !param3)) {
}
Jeremy Falcon
|
|
|
|
|
for (hold_my_bear in watch_this)
{
}
PartsBin an Electronics Part Organizer - An updated version available!
JaxCoder.com
|
|
|
|
|
Well, let's not, else we may wind up with multiple inheritance problems.
|
|
|
|
|
|
Jeremy Falcon wrote: Can you explain a binary search family tree with no branches loops?
FTFY
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
+10!
Software Zen: delete this;
|
|
|
|
|
YES !!!!
and as in :
if (ch in [A..Z,0..9])
as it is in Pascal.
|
|
|
|
|
I make a static Hashset for that (C#).
|
|
|
|
|
That's cool. The build-in contains/subset functions are native and fast.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
Well, yes, but ... In all the Pascals I have been in touch with, it is implemented as a bit map. A few orders of magnitude lighter, I guess.
There are several other Pascal features I certainly would welcome in C#. Such as decent enumerations, as a first class data type - not just symbolic names for integers, that cannot even be used as integers! In particular: The enum we are offered cannot even be used as an array index type.
Closely related: I would welcome Pascal style subrange types. Define a type Year = 1900..2050, and assigning a value outside this range to a variable of type Year is caught by the runtime system (or the compiler, if it can be determined statically).
Related to this: An array with index type Year, so valid index values run from 1900 to 2050.
To go a little beyond Pascal: I wish we had a mechanism for defining incompatible types: If I could define 'new type Speed = float;' and 'new type Volume = float;', variables of type Speed and Volume would be incompatible, and the compiler would give an error if you try to add them (without a proper operator definition for the two types, or an explicit cast).
|
|
|
|
|
Oh, well, yeah, for individual (ASCII) characters a bitmap or similar may be best. I was thinking of a more general technique.
Edit: As in making a Hashset and putting various (UNICODE) quote characters or whitespace characters in it to test against.
Yes, there are many things Pascal does which are handy. But I haven't used Pascal in decades, not since learning C.
modified 2-Feb-23 9:47am.
|
|
|
|
|
Pascal had bitmaps as a first class type ('SET OF'), with operations for inserting and removing elements, intersection / union / difference operators and membership tests. I guess that the C code I have written for doing the same things were at least as efficient as the Pascal compiler could have done it (it probably would have added a lot of range tests), but I certainly have often missed the syntactic simplicity of Pascal for such operations!
|
|
|
|
|
I am rusty in C/C++, but thought typedef would do that for you in C and C++.
Need a cast to assign between the typedefs even if they are both native float.
|
|
|
|