Liste des Groupes | Revenir à cl c |
On 04/06/2024 13:23, bart wrote:On 04/06/2024 12:02, David Brown wrote:
I was responding to your comment:C is not a script language.It is fine if you have a language that has good support for lists, sets, ranges, and other higher-level features - then an "in" keyword is a great idea. But C is not such a language, and that kind of feature would be well outside the scope of the language.>
I disagree. I have a script language where 'in' works with all sorts of data types, and where ranges like a..b and sets like [a..b, c, d, e] are actual types.
>Adding such a feature to your own personal language, for your own personal use, is easy enough (relative to the rest of the work involved in designing your own personal language and making tools for it, which is of course no small feat). Adding it to C with its standards, existing code, toolchains, additional tools, developers, etc., is a whole different kettle of fish.
Yet I also introduced 'in' into my systems language, even though it is very restricted:
>
if a in b..c then
if a in [b, c, d] then
>
This is limited to integer types. The set construct here doesn't allow ranges (it could have done). Neither the range or set is a datatype - it just syntax. (I can't do range r := 1..10.)
I'm catering for a wider readership.You and I are British - the term is "half-arsed" :-)It would be easy enough to write a macro "in_range(a, x, b)" that would do the job. It is even easier, and more productive, that you simply write the "valid_char" function and use it, if that's what you need.>
Yes it would be easier - to provide an ugly, half-assed solution that
Les messages affichés proviennent d'usenet.