www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - my wish list

please dont hint me to specification, I have already exploded on 
these things, and would like to remake them as I see it in more 
right behavior/style.
I'm not complaining, I want to make the language better and 
clearer without a rakes in it (you can step on them and get it on 
the forehead or lower)
u have your own opinion and tastes.
I typed whishes as non-ordered, without priority.

1) bool is bool
dont call bool overloaded func when exists other, try call byte, 
int, long, real first.
call bool when other options are not exists. probably user try to 
check that is 0/null or not.

2) dont pass implicitly any enum to something that is not base 
type of it
void fn( bool v ) { "bool %s".writefln( v ); }
void fn( byte v ) { "byte %s".writefln( v ); }
void fn( short v ) { "short %s".writefln( v ); }
void fn( long v ) { "long %s".writefln( v ); }
enum Week : int { Mon, Tue, .. , Sun }
fn( Week.Tue ); // fn( true ) WTF?
fn( Week.Wed ); // fn( byte ) WTF? use integer promotion. next 
for int32 is long, call it.
fn( Week.Mon as bool ); // looks weird but probably I know what I 
do here

another weird shit:
fn( 8-7 ); // fn( true )
fn( 9-7 ); // fn( byte )
fn( 270-7 ); // fn( short )
fn( 99999-7 ); // fn( long )
for arg of one type we called here FOUR DIFFERENT functions.
try to call:
[tuple(8,7),tuple(9,7),tuple(270,7),tuple(99999,7)].each!(t => 
fn( t[0]-t[1]));
u got different behavior for same values. don't you think it's 
weird?

3) tuple as part of language with deconstructing and naming 
(indexing is supported too)
auto (one, two) = { return (1, 2.0); }();
void fn( (int x, real y) arg ) { }
(int a, real b) hz = (5, 6.0);
fn( hz ); // names for tuple fields doesn't matter (like LLVM 
structs)

4) "it" as implicit arg for "one arg" lambdas as Kotlin does
// we already has better tuples so
[(8,7), (9,7), (270,7), (99999,7)].each!fn( it[0]-it[1])

5) cast( Type )val is ugly
too many brackets that makes code non readable
consider option Rust's AS "12345 as byte" that has precedence 
between unary and */%

6) nullable types as language feature not the Phobos
int? x;
real? y;
SomeStuct? z;
with implemented operators
if (x !is null) // cuz we check x than we can use it without any 
actions like suffix!
x! - either value of x or NullReferenceException
z?.meth( "arg" ) - Elvis operator: result is either null (method 
not called for nulls) or ReturnType!method (RTM). when RTM is not 
nullable then total result of such op will be RTM? - can store 
null or RTM
y ?? PI - returns right expression when left is null

7) simpler version of switch as expression with pattern matching
that supports set, lambdas and "else"
auto res = case (val) {
   of 1,2,3,5,7: "small prime",
   of it>10: "big one",
   else "negative", // trailing comma. see next
}; // total result is "string"
its a lil complicated version of ternary "cond ? a : b"

8) trailing comma is allowed
DONT CARE but can be useful for copy-paste
probably it already supported, I just saw it in pred point.
and for tuples too: (5,6,7,) - 3-field tuple, not 4

9) lambdas as func args goes automatically as scoped
dont need explicitly increase the text when it is clear and 
compiler can do best job/choice for us


struct Rect {
   double area() => width * height; // to simplify funcs
}
lambda does not returns implicitly another lambda
(arg) => { float acc; ...; return acc; } // WTF? returns float 
delegate()
when I want to return lambda I can ask it explicitly
(arg) => { float acc; ...; return () => acc; } // I return 
lambda, anybody see it

11) string interpolation

$"pi={PI:F6} e={E:F9}".writeln;
should we change toString() to toString( string fmt =null ) for 
all?

12) (not sure)


// that invokes toString( PI, "F6" ) and toString( E, =null )
or
auto str = #PI ~ #E; // connot request format with prefix
for now u can use .text, .format, to!string..

13) I want selective bounds checking.
for example Release disable the one, but for some arrays I want 
to check bounds in any case cuz I am not sure in indexing calcs 
or it depends from side services (do u add C++ integration? 
probably I mean it)
and I dont want to check it manually for every access writing 
something:
enforce( cast( ulong )calcedIndex < arr.length );
compiler can do such job better than me, it easy for it.
my code is unsafe so I cant use  safe with bounds checking.
I need something like:
 boundcheck
auto arr = ...
its something like Rust attributes, u can change behavior of 
entity, lets name it "manners".
in future u can invent any more useful manners that somehow 
change behaviour.
u can define it something different as attributes for now.

14) versioned modules
import core.memory!2.0 : memcpy;
you have to figure out how to store same files with diff versions.

15) easy using of shared Phobos and runtime
Windows is outsider for this point, but Windows has 90% of all 
computer users.

16) I want interoperate with C++ (DPP)
I want to use C++ STL without headache cuz Phobos STL is not 
enough.
I want to use others libs from world without abandoned wrappers.
do we still needed DIP1014 cuz std::string uses SSO?

17) (not sure but I want that)
precise GC shouldn't scan all DATA segs just some fields with 
using TypeInfo.
if compiler cannot understand where exactly pointers in DATA seg 
add "gcpointer" as new type and scan only it.
any bits in data seg holds unused memory.
and when app is finished for ENoMem without option to catch 
exception u just cannot name language as "safe".

18) "mutable" keyword
same meanings as C++

19) dynamic compilation and scripting like .NET allows
LLVM contains this feature. LDC supports it to a limited extent.

20) do we needed checked math?

 checked manner for vars cuz when we have such var we should 
check all math with it not just 1 op
 checked
long x = ...; // and compiler add checks for us

21) some features from C++ easy/clear than in D
- lambdas with capture clause: u can request which var cap as 
value and which as ref
- "ref" keyword is stodgy (not sure in English meaning) than refs 
in C++
ref int fn( ref float ) { } // D
int& fn( float& ) { } // C++. imo better
NB: ref shouldn't be attribute of func, its attr of input arg 
type and returned type
- when I will remember other I will add here

I am happy with other things :)

PS
I may be mistaken in some points, because my knowledge is not yet 
complete
Jul 23 2019