On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote:
D's std lib implementations are sometimes really awful, but in
this case it's not actually that bad:
print("hi","there");
->
fwrite("hi", 1, 2, 0x7ff68d0cb640) =
2
fwrite(" ", 1, 1,
Let's say I have a socket, and a file, and I want to send the
contents of that file to the socket. What's the best way to do
that? Yes I'm aware that in Linux, you can use a combination of a
pipe and splice(2) to keep all buffers kernel side for that, but
I was thinking more generally. The
Am Sat, 06 Feb 2016 04:28:17 +
schrieb tsbockman :
> On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote:
> >> > 1. Removing 'ref' from the return type
> >
> > Must happen. 'ref' only worked because of the reinterpreting
> > cast which doesn't work in
Mixin templates is the way to go if you want something new on
every use of the template. Otherwise using the template
multiple times with the same arguments will always give you
the first instance.
--
Marco
On Saturday, 6 February 2016 at 06:39:27 UTC, Marco Leise wrote:
using the template multiple times with the same arguments will
always give you the first instance.
Hmm, consider that the argument was a particular line of code
though, and that's not likely to repeat. I didn't test what would
Does the following help?
import std.algorithm.comparison : castSwitch;
import std.stdio;
class A { }
class B : A { }
class C : A { }
auto foo_impl(B b) {
writeln("called foo(B)");
}
auto foo_impl(C c) {
writeln("called foo(C)");
}
auto foo(A a) {
return a.castSwitch!(
(B
https://dlang.org/phobos/core_thread.html#.Thread.join
Yep, munching an Error by default is pretty nasty.
Am Fri, 05 Feb 2016 05:31:15 +
schrieb Saurabh Das :
> On Friday, 5 February 2016 at 05:18:01 UTC, Saurabh Das wrote:
> [...]
>
> Apologies for spamming. This is an improved implementation:
>
> @property
> Tuple!(sliceSpecs!(from, to)) slice(size_t
In my custom multithreaded web-server (non vibe-based) I got
error that is strange for me. I've was looking for a reason
running app under GDB, but I don't understand how to interpret
what I've got.
It's interesting that it fails (without any error or segfault
message) in the case when null
On 2/5/16 12:06 PM, Kagamin wrote:
https://dlang.org/phobos/core_thread.html#.Thread.join
Yeah, but in the meantime, the thread state is not cleaned up, and it's
in the same memory space as everywhere else.
I don't see why if you have an out-of-bounds error in the main thread,
it should
On Friday, 5 February 2016 at 17:39:55 UTC, Uranuz wrote:
In my custom multithreaded web-server (non vibe-based) I got
error that is strange for me. I've was looking for a reason
running app under GDB, but I don't understand how to interpret
what I've got.
It's interesting that it fails
On 02/04/2016 10:41 PM, tcak wrote:
> On Friday, 5 February 2016 at 06:23:09 UTC, Daniel Kozak wrote:
>> V Fri, 05 Feb 2016 03:47:40 +
>> tcak via Digitalmars-d-learn
>> napsáno:
>>
>>> [...]
>>
>> Did you try catch Throwable instead of Exception?
I was
It is purely a way to make throwing an exception use a syntax
similar to assert and save a line of code.
if(!condition)
throw new Exception(msg);
becomes
enforce(condition, msg);
So enforce is just macros on top of:
if(!condition)
throw new Exception(msg);
?
On Friday, 5 February 2016 at 07:31:24 UTC, cy wrote:
I think you might be talking about two very different concepts
here. Unwinding only happens within the context of a certain
scope.
The object itself is the scope (RAII). If you can test for
"uncaught_exceptions" you can implement the
On 02/05/2016 12:01 AM, Suliman wrote:
It is purely a way to make throwing an exception use a syntax similar
to assert and save a line of code.
if(!condition)
throw new Exception(msg);
becomes
enforce(condition, msg);
So enforce is just macros on top of:
if(!condition)
throw new
Usually I want the keys to be declared "immutable" to signal
that their content must not change in order to provide stable
hashes. But when you remove items from the table you need to
call a const/immutable dtor that needs to be written for
everything that can be a hash table key.
What do you put
On 2016-02-05 15:23:53 +, Marc Schütz said:
Does the following help?
...
I thought about it too, but I need it to work with more then one
parameter, so I tried this which doesn't work:
Value nativePlus(Value a, Value b){
// @@ not working, runtime exception
castSwitch!(
(IntV a)
On Wednesday, 14 March 2012 at 05:44:24 UTC, Chris Pons wrote:
I'm new, and trying to incorporate assert and enforce into my
program properly.
My question revolves around, the fact that assert is only
evaluated when using the debug switch. I read that assert
throws a more serious exception
On Wednesday, 3 February 2016 at 22:45:47 UTC, Timon Gehr wrote:
I would use enum forceCTFE(alias expr)=expr; though. With alias
it won't force compile-time evaluation of expressions that can
be interpreted as symbols.
I've a code that build a JSON object using a wrapper over
std.json.
On Friday, 5 February 2016 at 09:36:37 UTC, Andrea Fontana wrote:
On Wednesday, 3 February 2016 at 22:45:47 UTC, Timon Gehr wrote:
I would use enum forceCTFE(alias expr)=expr; though. With
alias it won't force compile-time evaluation of expressions
that can be interpreted as symbols.
I've a
On Friday, 5 February 2016 at 08:45:00 UTC, Minas Mina wrote:
On Wednesday, 14 March 2012 at 05:44:24 UTC, Chris Pons wrote:
I'm new, and trying to incorporate assert and enforce into my
program properly.
My question revolves around, the fact that assert is only
evaluated when using the
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote:
Mind if I elaborate on this a bit? If that is unrolled, I
understand it will unroll into several calls to write, as in
print("1","2","3") => write("1"," ");write("2","
");write("3","\n");
Up to here, yes.
And presumably, write()
On Friday, 5 February 2016 at 09:49:38 UTC, Luis wrote:
Reading/parsing a JSON or a XML using std.json / std.xml could
be done on CTFE ?
parseJSON() from std.json doesn't work with CTFE.
But I can build objects with with my code that works over
std.json.
So if you convert (with mixins)
{
On Friday, 5 February 2016 at 08:45:00 UTC, Minas Mina wrote:
Use assertions when a variable's value should not depend on
external factors.
For example, let's say you want to write a square root function.
The input must be >= 0, and because this depends on external
factors (e.g. user input),
From the docs:
class A { }
class B : A { }
class C : B { }
void foo(A);
void foo(B);
void test()
{
C c;
foo(c); // calls foo(B)
}
I need the other way around. So, at runtime I get an A and depending on
it's dynamic type, I would like to get the correct foo() called.
class A { }
On Friday, 5 February 2016 at 09:50:43 UTC, Suliman wrote:
Will asserts stay after compilation in release mode?
No. The only assert that remains in release mode is assert(false)
or assert(0) as a way to identify that you've reached a piece of
code that shouldn't be executed.
On Thursday, 4 February 2016 at 22:13:36 UTC, Ola Fosheim Grøstad
wrote:
Well, it is probably not the best point in time to have
absolute beginners use D anyway.
That is a ridiculous thing to say and a great way of ensuring a
language dies. Good starting resources help everyone.
On Friday, 5 February 2016 at 10:54:27 UTC, Robert M. Münch wrote:
From the docs:
class A { }
class B : A { }
class C : B { }
void foo(A);
void foo(B);
[...]
sounds like foo should just be a method in the class rather than
a free function
On 02/05/16 08:04, cy via Digitalmars-d-learn wrote:
> On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote:
>>void print(A...)(A a) {
>> foreach (N, ref e; a)
>> write(e, N==A.length-1?"\n":" ");
>>}
>
>>> will be unrolled at compile time
>
> Mind if I
On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote:
call used to print diagnostics. What I saw made me never use or
look at D's std lib again. Except for meta programing and
toy/example programs where it doesn't matter.
What do you use instead? A buffer and Posix write() and
On 2016-02-05 11:10:36 +, Nicholas Wilson said:
sounds like foo should just be a method in the class rather than a free
function
In my particular case I want to keep some stuff outside of claases.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
On Friday, 5 February 2016 at 07:04:27 UTC, cy wrote:
tl;dr speed demons use std.stream.InputStream.read() whenever
you can, and std.stream.OutputStream.write() its result.
Isn't std.stream deprecated?
On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote:
> On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote:
>> call used to print diagnostics. What I saw made me never use or look at D's
>> std lib again. Except for meta programing and toy/example programs where it
On 2/5/16 2:59 AM, Ali Çehreli wrote:
On 02/04/2016 10:41 PM, tcak wrote:
> On Friday, 5 February 2016 at 06:23:09 UTC, Daniel Kozak wrote:
>> V Fri, 05 Feb 2016 03:47:40 +
>> tcak via Digitalmars-d-learn
>> napsáno:
>>
>>> [...]
>>
>> Did you try
On Friday, 5 February 2016 at 22:18:50 UTC, Marco Leise wrote:
But when you remove items from the table you need to call a
const/immutable dtor that needs to be written for everything
that can be a hash table key.
You need to write destructors for hash keys? How would you use
string literals
On Friday, 5 February 2016 at 23:53:15 UTC, Enjoys Math wrote:
SDL_RenderCopy(...) takes two pointers to SDL_Rect's,
I have a property method in another class returning the
SDL_Rect equivalent of a Box (my structure). Taking ampersand
on the left of a call to the property does not give the
SDL_RenderCopy(...) takes two pointers to SDL_Rect's,
I have a property method in another class returning the SDL_Rect
equivalent of a Box (my structure). Taking ampersand on the left
of a call to the property does not give the address (&).
On 02/05/2016 03:53 PM, Enjoys Math wrote:
SDL_RenderCopy(...) takes two pointers to SDL_Rect's,
I have a property method in another class returning the SDL_Rect
equivalent of a Box (my structure).
Returning by reference or by value?
> Taking ampersand on the left of a
call to the property
Am Sat, 06 Feb 2016 03:38:54 +
schrieb cy :
> On Friday, 5 February 2016 at 22:18:50 UTC, Marco Leise wrote:
> > But when you remove items from the table you need to call a
> > const/immutable dtor that needs to be written for everything
> > that can be a hash table
On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote:
> 1. Removing 'ref' from the return type
Must happen. 'ref' only worked because of the reinterpreting
cast which doesn't work in general. This will change the
semantics. Now the caller of 'slice' will deal with a whole new
copy
I'm getting that on the last line of this code:
auto wh = Vec2([loadSurf.w, loadSurf.h]);
wh /= 2;
auto x = wh.plus1Dim(pos[Z]);
this.bbox = Box3(pos - x, pos + x);
Any ideas?
On Friday, 5 February 2016 at 07:44:29 UTC, Rikki Cattermole
wrote:
That code is completely wrong anyway.
Well, obviously it's wrong. If I don't know correct code that
will do what I want, then I can't tell you what I want using
correct code.
But you could do:
alias Derp = TFoo;
Derp
On Saturday, 6 February 2016 at 04:41:26 UTC, Enjoys Math wrote:
I'm getting that on the last line of this code:
auto wh = Vec2([loadSurf.w, loadSurf.h]);
wh /= 2;
auto x = wh.plus1Dim(pos[Z]);
this.bbox = Box3(pos - x, pos + x);
On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote:
Am Fri, 05 Feb 2016 05:31:15 +
schrieb Saurabh Das :
[...]
That is enlightening. I have updated the PR at
https://github.com/D-Programming-Language/phobos/pull/3975 to
incorporate these changes.
On Friday, 5 February 2016 at 08:16:05 UTC, Ola Fosheim Grøstad
wrote:
If you can test for "uncaught_exceptions" you can implement the
equivalent of scope(failure/success) etc within destructors.
Sorry, years of python programming have made me shy of
destructors. It just looks a little less
46 matches
Mail list logo