On 6/7/16 9:42 PM, Carl Vogel wrote:
Hi,
What's the best way, when using a Callable as a template parameter, to
constrain it by signature?
For example, if you have a function that sorts an array like so:
T[] sortArray(alias less, T)(T[] arr) { ... }
Then you know that you'd want `less` to hav
Hi,
What's the best way, when using a Callable as a template
parameter, to constrain it by signature?
For example, if you have a function that sorts an array like so:
T[] sortArray(alias less, T)(T[] arr) { ... }
Then you know that you'd want `less` to have signature (T, T) ->
bool.
Now,
On Tuesday, 7 June 2016 at 22:28:57 UTC, Steven Schveighoffer
wrote:
It's news to me that while opCast for all other types is for
explicit
casting, opCast for bool works for implicit casting.
as ag0... mentioned in another thread, opCast is NOT implicitly
being invoked here, but rather expl
On 6/7/16 6:15 PM, Ali Çehreli wrote:
On 06/06/2016 08:28 AM, Adam D. Ruppe wrote:
On Monday, 6 June 2016 at 15:23:50 UTC, chmike wrote:
I would like an implicit conversion of Info to bool that return false
if category_ is null so that I can write
add:
bool opCast(T : bool)() {
return wha
On 06/08/2016 12:02 AM, cy wrote:
import std.stdio;
void foo(Callable)(Callable bar) {
bar();
}
void foo2(Callable)(Callable bar, int baz) {
bar(baz);
}
void main() {
foo({
writeln("okay");
});
foo2((bar) {
writeln("got",bar);
},42);
foo2((bar) => writeln
On 06/06/2016 08:28 AM, Adam D. Ruppe wrote:
On Monday, 6 June 2016 at 15:23:50 UTC, chmike wrote:
I would like an implicit conversion of Info to bool that return false
if category_ is null so that I can write
add:
bool opCast(T : bool)() {
return whatever;
}
to the struct and it should w
On Monday, 6 June 2016 at 21:57:20 UTC, Pie? wrote:
On Monday, 6 June 2016 at 21:31:32 UTC, Alex Parrill wrote:
But reading sensitive data at compile-time strikes me as
dangerous, depending on your use case. If you are reading
sensitive information at compile time, you are presumably
going to
This program errors out, when I try to pass lambdas that take
arguments. How am I getting the syntax wrong here? Is there some
reason you can't do this?
import std.stdio;
void foo(Callable)(Callable bar) {
bar();
}
void foo2(Callable)(Callable bar, int baz) {
bar(baz);
}
void main() {
On Monday, 6 June 2016 at 21:55:00 UTC, ag0aep6g wrote:
On 06/06/2016 11:25 PM, Alex Parrill wrote:
You might be able to get away with casting the const away, if
you are
sure it won't modify the hash or equality check.
Casting away const and then mutating has undefined behavior.
The compiler
On 06/07/2016 08:50 PM, ParticlePeter wrote:
On Tuesday, 7 June 2016 at 14:31:40 UTC, Alex Parrill wrote:
I don't think opCast gets called for implicit conversions; it only
gets called for explicit casts. I'll test it later.
It does for type bool, but I fear that's the only exception.
No, op
On Tuesday, 7 June 2016 at 14:31:40 UTC, Alex Parrill wrote:
I don't think opCast gets called for implicit conversions; it
only gets called for explicit casts. I'll test it later.
It does for type bool, but I fear that's the only exception.
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote:
Hello
I'm writing some code that I want to be portable across Posix
and Windows.
What is the recommended code convention for such type of code ?
80% of the class implementation is the same for both OS.
Should I write the following and c
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote:
or should I do it the C way with multiple embedded static if...
In your example, `version` would also work instead of `static if`.
I would not copy much code needlessly, and go with the embedded
version/static ifs.
- Johan
On Monday, 6 June 2016 at 15:34:18 UTC, chmike wrote:
On Monday, 6 June 2016 at 15:28:35 UTC, John wrote:
Thank you John and Adam. That was a quick answer !
Too late but another option would have been to put an alias this
on a bool getter:
struct Info
{
bool getStuff()
{
retu
On Tuesday, 7 June 2016 at 15:43:34 UTC, Adam D. Ruppe wrote:
On Tuesday, 7 June 2016 at 15:39:59 UTC, jmh530 wrote:
My sense is that putting it on the GC heap gives the struct
reference semantics.
It doesn't matter what heap it is on, you are just using a
pointer here.
Struct pointers in D
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote:
Hello
I'm writing some code that I want to be portable across Posix
and Windows.
What is the recommended code convention for such type of code ?
80% of the class implementation is the same for both OS.
Should I write the following and c
On Tuesday, 7 June 2016 at 15:39:59 UTC, jmh530 wrote:
My sense is that putting it on the GC heap gives the struct
reference semantics.
It doesn't matter what heap it is on, you are just using a
pointer here.
Struct pointers in D will automatically dereference with a.x, so
no need for the *
I modified one of the first examples from
std.experimental.allocator to put a struct on the heap (below).
My sense is that putting it on the GC heap gives the struct
reference semantics. I was struck by two things. First, I didn't
have to use (*a).x, I could just use a.x. Also, when I assign a
Hello
I'm writing some code that I want to be portable across Posix and
Windows.
What is the recommended code convention for such type of code ?
80% of the class implementation is the same for both OS.
Should I write the following and copy past the 80%
version( Windows ) {
import core.s
On Tuesday, 7 June 2016 at 04:31:56 UTC, ParticlePeter wrote:
On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote:
They'd be the same type, since you would define the vulkan
functions to take these structures instead of pointer or
integer types.
It relies on a lot of assumptions about
On Tuesday, 7 June 2016 at 03:55:03 UTC, none wrote:
import std.algorithm.iteration : map;
import std.algorithm : castSwitch;
import std.format : format;
class A { int value; this(int value) { this.value = value; }}
interface I { }
class B : I { }
Object[] arr = [new A(5), new B
On Tuesday, 7 June 2016 at 08:49:16 UTC, TheDGuy wrote:
On Friday, 3 June 2016 at 16:20:53 UTC, TheDGuy wrote:
On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote:
colorize works. You meant "serial-port" ?
Does Coedit have the possibility to debug?
Yes / No?
No
On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote:
It relies on a lot of assumptions about the ABI that make a raw
pointer work the same as a structure containing just one
pointer, which is why I did not give it much consideration.
At least some of those assumptions could be verified
On Friday, 3 June 2016 at 16:20:53 UTC, TheDGuy wrote:
On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote:
colorize works. You meant "serial-port" ?
Does Coedit have the possibility to debug?
Yes / No?
Are there any test frameworks for D that are not specifically unit test
frameworks?
I thought testing had gone beyond being obsessed with units.
Has anyone got property-based testing with shrinking?
--
Russel.
=
Dr Russ
25 matches
Mail list logo