is a bit more free than Swift now).
Bear hugs,
bearophile
. It just needs to
be implemented correctly.
Bye,
bearophile
://www.reddit.com/r/programming/comments/49y7sc/11_myths_about_ada/
Bye,
bearophile
xenon325:
Doesn't http://wiki.dlang.org/DIP25 fix this ?
I think DIP25 is designed to be only a partial solution, it's not
a complete memory safety story.
Bye,
bearophile
having any experience of
template metaprogramming, CTFE, and the like, and gradually
absorb language features as you go. Phobos is pretty readable,
on the whole. I agree with bearophile about GC making it
easier in the beginning.
bearophile:
"I am sometimes able to write working D code al
overlapping in their
purposes and niches.
Bye,
bearophile
I don't know if
such safety features will be added to Rust, I am dubious.
In the C/Ada world you have language subsets like MISRA/SPARK
that people use in high integrity system. I think Rust still
lacks something like that.
Bye,
bearophile
FreeSlave:
On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:
Not directly. You can declare cdecl function on Free Pascal
side and call it as extern(C).
What about extern(Pascal)?
https://dlang.org/spec/attribute.html#linkage
Bye,
bearophile
#Faster_Version
You can also add a constructor to such struct, for safety and
disallow default construction.
Bye,
bearophile
Yazan D:
On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote:
ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof];
Better to use the actual size:
ubyte[] b = (cast(ubyte*) )[0 .. a.sizeof];
Bye,
bearophile
BBaz:
So I don't know...and I ask, should the garbages from
bearophile be closed ?
Hello, I use D every day, and there are several functions that
I'd like in Phobos. I think all/most of them can be of general
usefulness. While I am often wrong, those ERs come from plenty of
experience
Namal:
Hello I am trying to convert BigInt to string like that while
trying to sort it:
void main() {
import std.stdio, std.algorithm, std.conv, std.bigint,
std.string;
auto n = 17.BigInt ^^ 179;
n.text.dup.representation.sort().release.assumeUTF.writeln;
}
Bye,
bearophile
void main() {
import std.stdio, std.algorithm, std.conv, std.bigint,
std.string;
auto n = 17.BigInt ^^ 179;
n.text.dup.representation.sort().release.assumeUTF.writeln;
}
Better:
n.to!(char[]).representation.sort().release.assumeUTF.writeln;
Bye,
bearophile
Namal:
std::vector foo(int N){
std::vector V(N);
int some_array[N];
VLAs are not present in D.
Bye,
bearophile
#Third_version
Bye,
bearophile
ponce:
Paper: http://vlang.org/dvcon2014.pdf
I'd say that's pretty huge!
Very nice.
Bye,
bearophile
without SIMD,
perhaps about as nice as the Ada ones (D sometimes offers good
enough tools to build what you need).
Posible use:
PackedDynamicArray!6 pa; // On heap.
PackedFixedArray!(6, 300) pfa; // On stack.
Bye,
bearophile
Dennis Ritchie:
There is an array of values to store each of which sufficiently
6 bits.
As it is written down on the D?
You can't do it directly in D. Someone has to write a packed
array data structure to do it.
Bye,
bearophile
:-)
Bye,
bearophile
signed integer. D allows implicit assignment of a
32 bit size_t to int but not a 64 bit size_t to an int. I agree
that it's a bit of a mess.
Bye,
bearophile
presence around
here is becoming useless.
Bye,
bearophile
.
Probably there are ways to make that code more dry, using a
TypeTuple of pairs like (SDL_QUIT, quit).
Bye,
bearophile
(
0, FizzBuzz,
3, Fizz,
5, Buzz,
6, Fizz,
9, Fizz,
10, Buzz,
12, Fizz,
/*else*/ i.text))
.reverseArgs!writefln(%-(%s\n%));
}
Bye,
bearophile
interactions and make complexity more manageable. His finding
seems a design mistake.
Bye,
bearophile
. But this idea was refused for D
(also because it goes against UFCS chains).
Bye,
bearophile
,
bearophile
Martin Krejcirik:
So, should the case b compile or not ? Is the spec too
restrictive here, or is it a bug ?
Apparently it's a WONTFIX mess. The spec should be updated.
WalterAndrei refused to fix a design bug here.
Bye,
bearophile
Walter Bright:
On 4/22/2015 2:58 PM, bearophile wrote:
D is less stack-friendly than Ada (and probably Rust too),
??
In Ada standard library you have safe fixed-size stack-allocated
associative arrays. In D you can't even allocate safely a
dynamically-sized 1D array on the stack
everything on the heap. D is less
stack-friendly than Ada (and probably Rust too), but in D you
allocate lot of small stuff on the stack.
Bye,
bearophile
(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}
Bye,
bearophile
Phobos. Sometimes
you can use another Phobos function that simulates an improved
switch. Or often you can just give up at using ADTs in D and use
what other solutions D offers you (like OOP).
Bye,
bearophile
of the video, where he shows an annotation to compile
functions for different CPUs, where the compiler updates function
pointers inside the binary according to the CPU you are using,
making the code safe and efficient.
Bye,
bearophile
Russel Winder:
it is all part of
guerilla marketing undertaken by anyone with anything to market.
It's still not a correct behavour, regardless how many do it.
Bye,
bearophile
() shown here, because I prefer the
alignment to be part of the type), and a way to tell the type
system that some array slices are fully distinct (the __restrict
seen here, I think this information doesn't need to be part of a
type).
Bye,
bearophile
doesn't look very useful.
Perhaps a named enum is safer.
Bye,
bearophile
Márcio Martins:
app.put(foo);
app.put(var);
app.put(bar);
I'd like put() to accept a lazy range...
Bye,
bearophile
weaselcat:
It's reddit, that's not really surprising.
Do you know a place better than Reddit for general programming
discussions?
The lambda the ultimate blog is not generic.
Bye,
bearophile
don't forget to put branches added by the compiler, so it's
safer.
Generally you prefer something that's guaranteed to be allocated
on the stack when it's small and there's enough stack. An array
allocation annotated with scope, perhaps.
Bye,
bearophile
,
bearophile
.
They are uncommonly used because they are not supported by the D
compiler, and it doesn't track the memory ownership well enough.
But a well designed system language needs to push programmers to
use the stack as much as possible.
Bye,
bearophile
asks for safety on default and opt-out on request.
See also @safe by default:
https://issues.dlang.org/show_bug.cgi?id=13838
Bye,
bearophile
Paul D Anderson:
Is there a way to return the name of a function (a string) from
a pointer to that function?
Perhaps creating a string[void*] AA and initializing with all the
function pointers you care about.
Bye,
bearophile
Steven Schveighoffer:
What do you think?
I asked for this fix almost five years ago, so I think it's about
time :-)
Bye,
bearophile
wobbles:
Have just tested, it is!
But with the current D front-end it's not a good idea to generate
too many combinations at compile-time. Efficient code doesn't
save you from bad usages.
Bye,
bearophile
Jack Applegame:
writeln(a.find(4).empty ? No : Yes);
canFind?
Bye,
bearophile
a look at the versions here, the usable one is the third:
http://rosettacode.org/wiki/Combinations#D
Bye,
bearophile
tcak:
I am planning to implement Iterator class. But looking at
foreach statement, it takes a range only.
Unless you are just experimenting, it's better to not go against
a language and its std lib.
Bye,
bearophile
deadalnix:
foreach (name; names.parallel) {
name.writeln;
}
no.please
I think foo.writeln; is acceptable. You just need to get a bit
used to it.
Bye,
bearophile
ddos:
same behavior when overriding methods of base classes
This is by design.
Bye,
bearophile
Vladimir Panteleev:
std.conv doesn't return NaN if you try to convert banana to a
double.
I have suggested to add a nothrow function like maybeTo that
returns a Nullable result.
Bye,
bearophile
a good reason to do
it, and you know what you are doing (and most times you don't
know it).
More generally, minimize the number of cast() in your D programs.
You can use a search to count how many cast( there are in your
whole D codebase, and you can try to reduce that number.
Bye,
bearophile
w0rp:
It doesn't amaze me at the moment, as it's slightly faster for
integers, and slightly slower for strings at the moment.
One problem with D strings is that they don't cache their hash
value.
Bye,
bearophile
not linear and not intuitive. As Walter has said at the the start
of this thread, arrays come out as more efficient in a large
number of cases...
Bye,
bearophile
std
lib).
Bye,
bearophile
is mine:
https://github.com/Dgame/m3/blob/master/source/m3/List.d
In 99%+ of cases it's a bad idea to use a linked list.
Bye,
bearophile
Walter Bright:
I'm not convinced of the need for overloading on 'scope'.
Do you want to explain some of the advantages and disadvantages
of that? It will help understand your reasons.
Bye,
bearophile
,
bearophile
. Sometimes C++ is a bad example to follow
(like with permutations generations, that currently is not a
Range in Phobos for the wrong reasons).
Bye,
bearophile
Andrei Alexandrescu:
Oh boy all classes with one-liner non-final methods. Manu must
be dancing a gig right now :o). -- Andrei
Yes, the right default for D language should be final, because
lot of programmers are lazy and they don't add attributes.
Bye,
bearophile
replace the *w multiplications with an increment of
an index each loop, but this time saving is dwarfed by the
reverse().
Bye,
bearophile
integer operations. So is the API very well compatible
with those intrinsics?
Bye,
bearophile
.
This is interesting. For the final D programmer what's the
practical difference between your proposed subset compared to the
full proposal?
Bye,
bearophile
of a next JavaScript update :-)
Bye,
bearophile
Brian Schott:
Do this instead:
ulong u = 1L 63;
I suggest a more explicit:
ulong u = 1UL 63;
Alternative:
ulong u = 2UL ^^ 63;
Bye,
bearophile
w0rp:
Every now and then I want a set type,
I think you can implement good enough sets in Phobos, do you
agree?
But you can't do the same with tuples. So I prefer sets in Phobos
and tuples in the language.
Bye,
bearophile
bitwise:
I'm a little confused at this point why this doesn't work
either:
const and immutable are rather different between C++ and D, I
suggest you to take a look at the documentation:
http://dlang.org/const-faq.html
Bye,
bearophile
of const
objects?
You meant to say associative array with const objects as
values. I think the short answer is that you can't. This is a
breaking change, I think, it broke some of my code too. But
perhaps something like Rebindable could be used.
Bye,
bearophile
zhmt:
In short words, I want to catch something like
NullPointerException.
Is this possible?
One solution is to add null tests to D in nonrelease mode. A
better solution is to modify D to remove all or most chances of
dereferencing null pointers and class references.
Bye,
bearophile
Jean pierre:
This is a problem, you, the D core has: you're crippled by your
orthodoxism.
Nothing will be added because of this: **rules**.
The current level of acceptance of Phobos patches seems roughly
correct to me.
Bye,
bearophile
and learn. They are sometimes tricky
to get right, but it's not a problem of ugly syntax.
I wondered if you could check statically that the type could
implement an interface *if it wanted to* that is, without
inheriting it...
Template constraints don't require inheritance.
Bye,
bearophile
Nordlöw:
I have graph traversal algorithm that needs to keep track of
the N best node visit.
std.algorithm.topNCopy?
Bye,
bearophile
:
void main() {
import std.stdio, std.algorithm, std.typecons;
auto arr = [7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1,
2, 2, 8, 5, 8, 8];
arr
.schwartzSort!(x = tuple(-arr.count!(y = y == x), x))
.writeln;
}
Bye,
bearophile
.schwartzSort!(x = tuple(-arr.count!(y = y == x), x))
But calling count for each item is not efficient (in both C#
and D). If your array is largish, then you need a more efficient
solution.
Bye,
bearophile
Ali Çehreli:
Do you know the story about groupBy?
It's a long messy story. Look for it with another name, like
chunkBy or something like that.
Bye,
bearophile
are doing in this thread.
Bye,
bearophile
, std.array;
[7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8, 5,
8, 8]
.sort()
.groupBy!((a, b) = a == b)
.map!array
.array
.sort!q{a.length b.length}
.joiner
.writeln;
}
Bye,
bearophile
Ola Fosheim Grøstad:
Downplaying other languages makes the D crowd look desperate...
That kind of articles are bad for the image of the D community
(and the D code shown in that article is not the best).
Bye,
bearophile
,
avoiding the map, to, and join, something like:
writefln(%(%d %), arr);
Bye,
bearophile
Vlad Levenfeld:
Anything going on with this? Been looking forward to seeing it
for awhile.
It will happen.
Bye,
bearophile
Nordlöw:
Ahh, a Binary Heap perfectly matches my needs.
https://en.wikipedia.org/wiki/Binary_heap
http://dlang.org/phobos/std_container_binaryheap.html
But isn't topNCopy using a heap?
Bye,
bearophile
Jacob Carlborg:
Although I would like that the D syntax allowed to drop the
curly braces, like with if-satements. That would result
in much nicer one-liner functions.
See:
https://issues.dlang.org/show_bug.cgi?id=7176
Bye,
bearophile
Andrei Alexandrescu:
You may want to answer there, not here. I've also posted a
response.
There is this, with an attach:
https://issues.dlang.org/show_bug.cgi?id=11810
Bye,
bearophile
that allocates inside that function.
Bye,
bearophile
in the
opposite direction, and for good reasons. An explanation:
https://channel9.msdn.com/Events/GoingNative/2013/Cpp-Seasoning
Bye,
bearophile
are often slower than
low-level code, so in some cases you don't want to use them.
So as usually you have to choose wisely, because most solutions
aren't perfect if you use them everywhere, there are many ways to
write bad code if you don't keep your eyes and brain switched on.
Bye,
bearophile
Baz:
https://github.com/D-Programming-Language/phobos/pull/3058
I suggest to replace litteral with literal, as in computer
science:
http://en.wikipedia.org/wiki/Literal_%28computer_programming%29
Bye,
bearophile
Marc Schütz:
Here's the new version of my scope proposal:
http://wiki.dlang.org/User:Schuetzm/scope2
Let's see what Andrei and Walter think about this all :-)
Bye,
bearophile
Robert burner Schadek:
... from all Unicode characters in an idiomatic D way?
Perhaps by rejection? I mean, generating a uint, test if it's a
character and repeat until the result is true.
Bye,
bearophile
Andrei Alexandrescu:
That opens the question whether we want only ubyte[] for hex
bytes or all integral types.
I suggest to implement only ubyte[] first. And wait for
enhancement requests.
Bye,
bearophile
that wants to
be a little functional. Alternative ways to allocate memory are
needed by some people. The GC needs improvements. Purity is not
yet finished. And there are minor things that can be improved. D3
is not planned, so the only way is to improve D2.
Bye,
bearophile
user-defined error
messages to template constraints, and is such enhancement a good
idea?
Bye,
bearophile
Walter Bright:
I'd also prefer to get rid of /+ +/ comments, I thought they'd
be more useful than they are.
I prefer to get rid of /* */ instead :-) Because /++/ can do
things /**/ can't.
Bye,
bearophile
Marc Schütz:
Can we make it so it returns a ubyte[]?
There is an enhancement request on this (for the built in hex
strings).
Bye,
bearophile
are experiencing those problems it's probably the way
D/Phobos to tell you to not use basic tuples for your purpose.
Use tuples with named fields (or even structs).
Take also a look at Algebraic in std.variant.
Bye,
bearophile
Andrei Alexandrescu:
hexString and hexBytes. -- Andrei
Can you show me one or two different use cases of hexString?
Bye,
bearophile
/show_bug.cgi?id=5909
Bye,
bearophile
dnewer:
but,C# cant compiled to native code.
Soon you will be able to compile C# natively.
Bye,
bearophile
to Sage.
Bye,
bearophile
, then probably you also like to read a language with
the help of a book.
Bye,
bearophile
dlang git repository
dmd 2.066.1 cannot build phobos 2.066.1
I will try to get something out of those threads, thank you :-)
Bye,
bearophile
1 - 100 of 10824 matches
Mail list logo