Sean Kelly:
When I use algorithms on strings in D, I always cast them to
ubyte[]. Which is a poor solution.
In Phobos we have representation, and assumeUTF that are
better than naked casts. I use them only sparingly (and I avoid
cast), despite I use strings often.
Bye,
bearophile
Daniel Kozák:
The only one and right solution is print warning message by
default
I am asking for this since some years.
Bye,
bearophile
H. S. Teoh:
In git HEAD, dmd now allows use of deprecated features and
displays a warning by default.
I meant I'd like by default all warnings to be shown :-)
Bye,
bearophile
;
}
}
You can call them a and a_. Why are you not recommending this
solution? It looks cool (if it works).
Bye,
bearophile
to
allocate it from a single allocator.
I don't think this feature will work.
I think he's already using this strategy in production code. So I
think it works. He's just asking for a language feature that
implements this idiom for him in a shorter and cleaner way.
Bye,
bearophile
by Maxime Chevalier-Boisvert).
Bye,
bearophile
Walter Bright:
So how do you tell it to call myfree(p) instead of free(p) ?
I think you can't in the form he has shown. He's far from being a
good language designer, after all :-)
Bye,
bearophile
the names of lstrip and
rsplit of Python string functions.
Bye,
bearophile
: 10, 2: 20];
auto r3 = map!(k = aa[k])(keys); // OK
auto r4 = map!aa(keys); // Error
}
This is a common idiom in Clojure. Arrays and associative arrays
can be seen as functions defined by an enumeration of
input-outputs.
Bye,
bearophile
some time, do the other
language updates that you think are good.
Bye,
bearophile
written also performance
conscious D entries (sometimes I have added various D solutions,
at various levels of performance, succinctness, safety
correctness).
Bye,
bearophile
://news.ycombinator.com/item?id=8363666
Bye,
bearophile
that site is,
It's sufficiently known, but perhaps only for certain
programmers. The ones that care about the design of programming
languages are more likely to know it.
Bye,
bearophile
of the contributors and amount of
time spent, it's also first of all a matter of how much
semantically clean you want to write the code, how many
abstractions you accept to remove from the implementation, how
much you care for many factors more than performance, etc.
Bye,
bearophile
a;
}
Bye,
bearophile
ends you have a x1 reference to
the array data. Such reference x1 is unique, so now 'a' is not
usable any more, you can't pass 'a' to foo once more.
I need to learn more about such stuff of linear typing.
Bye,
bearophile
is a quality regardless of
optimizations, because it makes both unit testing and code
understanding simpler :-) I am not very expert on this stuff, I
need to learn more.
Bye,
bearophile
Andrej Mitrovic:
alias Same_Type_1 = Typedef!(void*, null, cookie);
alias Same_Type_2 = Typedef!(void*, null, cookie);
static assert(is(Same_Type_1 == Same_Type_2)); // unsafe
*only if you request it*
I suggest to not offer this usage possibility.
Bye,
bearophile
Andrei Alexandrescu:
It's the poetic injustice of Typedef is broken/unusable I
have a problem with. -- Andrei
You seem the only one with such problem :-)
Bye,
bearophile
to finish shared libs, to test the patch
from Kenji that fixes the module system, and more.
Bye,
bearophile
;
}
But this design can't be used now in D. So I suggest to add anti
hijacking logic similar to the with() command. When such name
hiding errors are generated by a local import, the programmer has
to list imported names, or use renamed imports.
Bye,
bearophile
and ref?
This seems a bad idea, because GC and scope tracking is a
sufficiently large design implementation space. You can't face
all the large problems at the same time.
Bye,
bearophile
Nick Treleaven:
- It is slow to compile.
Surely that's not an inherent property of Rust?
We don't know yet. Perhaps Rust type inference needs lot of
computations.
Bye,
bearophile
of C#5.
Bye,
bearophile
Andrei Alexandrescu:
I find the requirement for the cookie perfect.
So far you're the only one, it seems. And you have admitted you
have not tried to use them significantly in your code.
Bye,
bearophile
that can wreak a program. Ada (and in
a less intense way D) try to help the programmer write correct
code for some of them too (and other languages are ATS, Whiley,
F*, Idris, etc, cover other forms of correctness).
Bye,
bearophile
Paulo Pinto:
(and other
languages are ATS, Whiley, F*, Idris, etc, cover other forms of
correctness).
...
You can handle units of measure via tuples structs, since you
mention F#.
Here I mentioned F*, not F#:
http://research.microsoft.com/en-us/projects/fstar/
Bye,
bearophile
)
The string a is composed of immutable(char) after all.
For me it's strange that iterating on arrays of immutable chars
or immutable dchars gives an output of different constness.
This looks like a gratuitous breakage of symmetry :-)
Bye,
bearophile
safety is not important
If type safety is not so important in a piece of code, you
probably are already not using a typedef/Typedef/newtype.
Bye,
bearophile
,
bearophile
or later a dirty semantics will bite your ass.
Mine ain't hurting. -- Andrei
This is not surprising because you say you have not used Typedef
much in your code.
Bye,
bearophile
against someone else more deserving?
Bye,
bearophile
.
Bye,
bearophile
), to code in a more handy
way.
Perhaps this new situation (no implicit conversions, plus two
kinds of casts, and few extra literals) is safer than the current
D situation (and I think no C code gains a new working meaning in
this new situation).
Bye,
bearophile
auto-vectorization).
Bye,
bearophile
Andrei Alexandrescu:
Are you suggesting we implement ARC?
Yes. -- Andrei
I think it's better first to design implement a first version
of memory ownership management, and then later add a reference
counting scheme.
Bye,
bearophile
/issues/show_bug.cgi?id=11828
Some other open issues/ERs:
https://issues.dlang.org/buglist.cgi?f1=short_desco1=casesubstringquery_format=advancedresolution=---v1=Typedef
Bye,
bearophile
ketmar:
but i know: octal literals are handy, so they will never make
their way to mainline. typedef construct is handy, so...
A well working Typedef/typedef (named newtype in Haskell, where
it's a built-in) is more commonly useful than octal literals.
Bye,
bearophile
Andrei Alexandrescu:
But it can be used.
Have you used it in your real D code three or more times? I have
tried and I have found many problems.
Bye,
bearophile
Andrei Alexandrescu:
Have you used it in your real D code three or more times?
No, but that doesn't mean much.
It means that I have more experience than you in using Typedef,
and in my experience their usage is not so good.
Bye,
bearophile
against Rust?
Bye,
bearophile
a look in bugzilla, if it's not already present file it.
Bye,
bearophile
Take a look in bugzilla, if it's not already present file it.
https://issues.dlang.org/show_bug.cgi?id=13505
Bye,
bearophile
] is an associative array with I index
and int values. So in another post I have suggested another
syntax.
Bye,
bearophile
Nordlöw:
should be
Enumerator start = Enumerator.min
This also requires the enum to have adjacent values (in general
enums can skip values).
Bye,
bearophile
):
--
void do_something(Entity ?a) {
if (a) {
a.x = 0;
}
}
--
Bye,
bearophile
IgorStepanov:
I've created pull request, which introduces multiple alias this.
Can someone show one or more usage cases?
Thank you,
bye,
bearophile
IgorStepanov:
Do you ask about alias this or about it multiple usage.
Multiple usage is similar to single, but multiple:)
I meant the multiple usage. And none of your examples here are
use cases :-( I'd like to see one use case, or more.
Bye,
bearophile
Andrei Alexandrescu:
Wyatt:
(I wouldn't consider the cookie parameter a better solution; I
would consider it a wart.)
That's the right solution.
The cookie parameter is a ugly wart.
Bye,
bearophile
anonymous:
Here, the pointer to the stack escapes the function. Don't do
that!
Hopefully the D type system will be improved with scoping
tracking management, to turn similar operations into
compilation errors (as in Rust, but perhaps in a less refined
way).
Bye,
bearophile
, and one that shows longer
hairier fast code.
In some cases I'd even like to show a third safe version (that
tries to be more correct), but most Shootout/ComputerGame
benchmarks are not very fit for this (you can see some examples
of this on Rosettacode).
Bye,
bearophile
the various programs will need updates.
Bye,
bearophile
have to copy it's often better
to copy from Lisp/ML/Ada instead of C++).
Bye,
bearophile
H. S. Teoh:
How do you implement a completely GC-free AA with no limit on
number of entries stored?
Ada2012 has a fixed-size hash in the standard library, it can
even be allocated on the stack. But the number of entries is not
unlimited.
Bye,
bearophile
in a flexible
and efficient way. Perhaps the idea can be used in D too. It
suggests the introduction of a hashAppend standard method.
Bye,
bearophile
Andrei Alexandrescu:
Add a sequence number as a uint, defaulted to 0. -- Andrei
See discussion:
https://d.puremagic.com/issues/show_bug.cgi?id=12100
Bye,
bearophile
;
case opt2: fun2(...); break;
case opt3: fun3(...); break;
}
Bye,
bearophile
,
bearophile
for function/ctor
arguments), or features that have a limited scope and don't
increase the general code complexity much (like the partial type
inference patch created by Kenji).
Bye,
bearophile
function(T val1,T val2) ptr = comp;
spiltPoint = partition(list, ptr, left, right);
}
void main() {}
Bye,
bearophile
is not going to help any one.
Bye,
bearophile
reasons.
Bye,
bearophile
Erwig:
http://web.engr.oregonstate.edu/~erwig/papers/C++TemplateErrors_PEPM14.pdf
Bye,
bearophile
Is it a good idea to accept code like this, to shorten some
constants?
void main() {
int x = 1e6;
}
Bye,
bearophile
Manu:
Surely, at very least, an extern(C++) class should be
final-by-default?
Often the less special cases you have, the less bugs you create.
So I suggest final to be handled in the same way in both regular
and extern(C++) classes.
Bye,
bearophile
!int.
...
I think it's better for write(Nullable!int()) to not raise an
error, but to print something like a null etc.
A bigger problem is in the usage of Nullable. I'd like the D type
system to be modified and improved to support Nullables with a
nicer syntax.
Bye,
bearophile
Andrei Alexandrescu:
D offers strong evidence that static if is an enormously useful
construct.
But it's not a complete typing. The Concepts Lite are a more
principled and safer solution.
(Are Rust templates comparable to first order Concepts Lite?)
Bye,
bearophile
Ilya Yaroshenko:
immutable length = r1.length; //Error, can't use function
parameters.
Time ago it was argued that if the use of function parameters is
allowed there (to define constants), you have poor's man
pre-state (old) in D.
Bye,
bearophile
,
bearophile
) is a work in
progress, and there are also some blocking problems (Like:
http://forum.dlang.org/thread/stlslhjndgugecvmb...@forum.dlang.org
). In some cases some functions can't just have all attributes,
because they need to throw, or they are not designed to be pure,
etc.
Bye,
bearophile
it?
At the moment the focus seems to be:
1) C++ interoperability
2) GC (in theory).
Bye,
bearophile
)];
ar2.minimum.writeln;
}
Bye,
bearophile
of memory
areas in D. So I am seeing a priority problem here).
Bye,
bearophile
a QuickCheck-like library needs to become standard
tool used to test most D projects.
There are many other related ideas, like:
http://www.cse.chalmers.se/~nicsma/quickspec.pdf
Bye,
bearophile
John Colvin:
http://www.daemonology.net/blog/2014-09-06-zeroing-buffers-is-insufficient.html
D could incorporate something like this, no?
See:
https://d.puremagic.com/issues/show_bug.cgi?id=10661
Walter seems OK with adding something like that to the D
intrinsics.
Bye,
bearophile
Meta:
let ratio = try!(div(x, y));
becomes
let ratio = match div(x, y)
{
Ok(val) = val,
Err(msg) = { return Err; }
}
Maybe we need a similar solution for @nogc.
Related:
https://d.puremagic.com/issues/show_bug.cgi?id=6840
Bye,
bearophile
ketmar:
and that is why my local D diverges more and more from
mainline D.
This is a bad idea, it leads to an increase of your
dissatisfaction, until you stop using D :-(
Bye,
bearophile
Paulo Pinto:
For some strange reason human life critical systems are written
in Ada, SPARK, MISRA C dialect
If D designers and developers work to make D better for those
usages, someday D could be used to replace the MISRA C and
perhaps even some less strict usages of Ada.
Bye,
bearophile
the
import inside the main, to add a space after the commas, and to
add an immutable to foreach variable.
Bye,
bearophile
fit for a performance bug report. I have to create a
synthetic benchmark that shows just the problem.
Bye,
bearophile
It seems fit for a performance bug report. I have to create a
synthetic benchmark that shows just the problem.
https://issues.dlang.org/show_bug.cgi?id=13410
(Perhaps I have credited the wrong person there, sorry, I will
fix).
Bye,
bearophile
, and x.getAndRemove() too, it's handy sometimes. but this
will need new druntime hook, i think. ;-)
x.pop() sounds nicer :-)
Bye,
bearophile
Ali Çehreli:
Unless there is a specific reason not to, use 'string'. When
you really need random access to characters, then use 'dstring'.
So are the use cases for wstring limited?
Bye,
bearophile
much faster than the D code.
Is it possible to fix the D code to increase its performance
(there are associative array libraries for D, but I have not
tried them in this program).
Bye,
bearophile
Adam D. Ruppe:
If you want to compare the runtime type of a class object, you
can do:
if(typeid(obj_one) == typeid(obj_two))
that should tell you if they are the same dynamic class type.
And what about:
if (is(typeof(obj_one) == typeof(obj_two)))
Bye,
bearophile
templates, so if you don't add their main
function, nothing gets compiled.
Bye,
bearophile
nikki:
I use it to change my d sourcefile slightly (into valid
markdown)
then I use a node module (ghmd) to make sortof sexy html from
that.
Are you going to add popups of the types as in the F# page I have
linked?
Bye,
bearophile
think that an
overlapping memcpy ought to result in unspecified garbage being
written rather than undefined behavior.
Bye,
bearophile
that need to be
compiled.
Bye,
bearophile
] + 2]s;
return sum(a2[]);
}
Bye,
bearophile
call impure function 'temp.Point.feature'
Bye,
bearophile
Jonathan Marler:
What are DSLs? Link?
http://en.wikipedia.org/wiki/Domain-specific_language
Bye,
bearophile
maik klein:
Are there any exercises/challenges for D?
Some exercises here:
http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_D
Please announce them here when you solve some of them :-)
Bye,
bearophile
the time:
gist.github.com/nooodl/e23337d0175ad66ea5f0
Or F# ones:
http://tomasp.net/blog/2014/puzzling-fsharp/
Bye,
bearophile
is possible without doing flow
control or interprocedural analysis.
I remember that Walter has recently said that he's willing to add
some kind of flow analysis to the D front-end.
Bye,
bearophile
comments from a good Rust core
developer, because they have discussed such topics in detail for
lot of time :-)
Bye,
bearophile
);
}
(Note that in D the names of types and structs start with an
upper case).
Bye,
bearophile
Jeremy DeHaan:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
Try:
if (is(T == dchar))
Bye,
bearophile
,
bearophile
the protection violation
Don't use delete, it's deprecated (despite it's not yet
deprecated because D designers love to keep some important things
in such Limbo for several years).
Bye,
bearophile
601 - 700 of 10824 matches
Mail list logo