Hello,
I was recently exposed to this template in core.atomic:
private
{
template HeadUnshared(T)
{
static if( is( T U : shared(U*) ) )
alias shared(U)* HeadUnshared;
else
alias T HeadUnshared;
}
}
Could someone please explain/elaborate on wha
On Wed, 11 Jun 2014 23:01:31 +
matovitch via Digitalmars-d-learn
wrote:
> About alias working with identifier but not with (runtime)
> expression. Alias should work with compile time expression like
> map!(x=>2*x) right ? So a static cast should work isn't it ?
> (though static_cast doesn't e
On Wednesday, 11 June 2014 at 18:29:27 UTC, Mike wrote:
Hello.
Here's the link to the repo: http://bit.ly/1mIuGhv
Hi, sorry didn't read through your code yet, but while ago I
wrote some encoders/decoders for jpeg and png
(https://github.com/callumenator/imaged, haven't compiled it in a
while
On Wednesday, 11 June 2014 at 14:45:22 UTC, simendsjo wrote:
I must say I really like your writing-style as well as the
down-to-earth and precise and concise presentation of the
material. So kudos to you!
thanks, don't forget to tell that to amazon review readers too :P
Really looking forward
If I quote de documentation :
"Any casting of a class reference to a derived class reference is
done with a runtime check to make sure it really is a downcast.
null is the result if it isn't. Note: This is equivalent to the
behavior of the dynamic_cast operator in C++."
I explicitly kept tra
On Wednesday, 11 June 2014 at 20:53:21 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
I don't believe that it's legal to use a cast in an alias
declaration, and
that's certainly what the error seems to be indicating. Also,
using ref in a
cast is definitely illegal regardless of where the
modulo of a negative number can give some surprising results. A
negative index in that array would cause it to throw a range
error, so my guess is that's what you're getting. If you do
%array.length though it becomes an unsigned math and thus will
never be negative, explaining the different res
On Wednesday, 11 June 2014 at 22:32:45 UTC, Taylor Hillegeist
wrote:
I have a simpleish bit of code here that always seems to give
me an error, and i can't figure out quite why.
modulo takes the sign of the dividend:
http://en.wikipedia.org/wiki/Modulo_operation#Common_pitfalls
It works with le
On Wednesday, 11 June 2014 at 22:38:02 UTC, Taylor Hillegeist
wrote:
On Wednesday, 11 June 2014 at 22:35:39 UTC, Taylor Hillegeist
wrote:
On Wednesday, 11 June 2014 at 22:32:45 UTC, Taylor Hillegeist
wrote:
I have a simpleish bit of code here that always seems to give
me an error, and i can't f
On Wednesday, 11 June 2014 at 22:35:39 UTC, Taylor Hillegeist
wrote:
On Wednesday, 11 June 2014 at 22:32:45 UTC, Taylor Hillegeist
wrote:
I have a simpleish bit of code here that always seems to give
me an error, and i can't figure out quite why. If I have a
constant 43 in the modulo if breaks.
On Wednesday, 11 June 2014 at 22:32:45 UTC, Taylor Hillegeist
wrote:
I have a simpleish bit of code here that always seems to give
me an error, and i can't figure out quite why. If I have a
constant 43 in the modulo if breaks. however if i use
points.length it seems to be ok?
import std.stdio
I have a simpleish bit of code here that always seems to give me
an error, and i can't figure out quite why. If I have a constant
43 in the modulo if breaks. however if i use points.length it
seems to be ok?
import std.stdio;
void main(){
int points[43] = [0, 1153, 1905, 1996, 1392, 305,
-8
On 11/06/14 16:22, Adam D. Ruppe via Digitalmars-d-learn wrote:
On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote:
I believe the correct answer should be "Buy my book!".
ah, of course! I should just make a .sig file lol
http://www.packtpub.com/discover-advantages-of-programming-in-d
https://github.com/D-Programming-Language/druntime/pull/825
I updated
https://github.com/nordlow/justd/blob/master/pprint.d
with two versions of shortDurationString(). DMD picks the right
one using
static if (__VERSION__ >= 2066L)
// new
else
// old
I hope I it right this time.
You can safely change your code to use total!"weeks" instead.
Ok.
Thx
On Wednesday, 11 June 2014 at 21:06:42 UTC, Kapps wrote:
On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote:
Can somebody explain the meaning of split in the error message
Deprecation: function core.time.Duration.weeks is deprecated -
Please use split instead. weeks was too frequently c
On Wed, 11 Jun 2014 16:59:24 -0400, Nordlöw wrote:
Can somebody explain the meaning of split in the error message
Deprecation: function core.time.Duration.weeks is deprecated - Please
use split instead. weeks was too frequently confused for total!"weeks".
given by function
shortDurationSt
On Wednesday, 11 June 2014 at 18:07:44 UTC, matovitch wrote:
source/app.d(5): Error: basic type expected, not cast
source/app.d(5): Error: no identifier for declarator int
source/app.d(5): Error: semicolon expected to close alias
declaration
source/app.d(5): Error: Declaration expected, not 'ca
On Wednesday, 11 June 2014 at 20:59:25 UTC, Nordlöw wrote:
Can somebody explain the meaning of split in the error message
Deprecation: function core.time.Duration.weeks is deprecated -
Please use split instead. weeks was too frequently confused for
total!"weeks".
given by function
shortDura
Can somebody explain the meaning of split in the error message
Deprecation: function core.time.Duration.weeks is deprecated -
Please use split instead. weeks was too frequently confused for
total!"weeks".
given by function
shortDurationString()
at
https://github.com/nordlow/justd/blob/mast
I don't believe this is possible. Perhaps you would be able to
How about adding
__traits(sourceFile, T)
__traits(sourceLine, T)
__traits(sourceColumn, T)
to DMD?
T of course must be a user-defined type.
> Sent: Wednesday, June 11, 2014 at 8:07 PM
> From: "matovitch via Digitalmars-d-learn"
> To: digitalmars-d-learn@puremagic.com
> Subject: Multiple alias this failed workaround...obscure error message
>
> I was looking for a workaround to multiple alias this (or
> opImplicitCast) the following tr
On Tuesday, 10 June 2014 at 20:58:41 UTC, Nordlöw wrote:
Is there a way to, programatically (trait), lookup the source
file and position of a user defined type either dynamically or,
even better, statically?
I don't believe this is possible. Perhaps you would be able to
generate the .json file
Hello.
I am new to D and I must admit I really like the language. In my
opinion it takes the best from C++ and, say, Python and combines
it really elegantly. Great work!
I am currently working on my first library in D - related to
TARGA image format.
Here's the link to the repo: http://bit.ly/1
On 06/11/14 16:05, monarch_dodra via Digitalmars-d-learn wrote:
> Well, (IMO) it's a problem with no real solution. But for what it's worth,
> most (if not all) of the algorithms in the standard lib know how to handle
> strings efficiently and correctly (split, find, etc...). Things only start
>
Is there an existing way to do it or do I have to roll my own?
unittest{
assert(escapeC(`a"bc\ndef`~"\n") == `"a\"bc\\ndef\n"`);
}
Likewise with escapeD (pastable in D code), which would return something
like: `r"..."` for more readability
I was looking for a workaround to multiple alias this (or
opImplicitCast) the following trick doesn't work (why shouldn't
it ?). The error message is quite obscure to me.
import std.stdio;
class A(Derived)
{
alias cast(ref Derived)(this).x this;
}
class B : A!B
{
float x;
}
class C
On Wednesday, 11 June 2014 at 17:11:51 UTC, Tim wrote:
On Wednesday, 11 June 2014 at 10:09:50 UTC, FreeSlave wrote:
I conclude that because I have similar errors when trying to
build 64-bit library on 32-bit system.
/usr/bin/ld:
/usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o):
reloc
On Wednesday, 11 June 2014 at 10:09:50 UTC, FreeSlave wrote:
I conclude that because I have similar errors when trying to
build 64-bit library on 32-bit system.
/usr/bin/ld:
/usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o):
relocation R_X86_64_32 against `.rodata' can not be used when
On Tuesday, 10 June 2014 at 15:52:29 UTC, Poyeyo wrote:
Hello, has anyone used this
https://github.com/andersonpd/decimal implementation?
I'm learning D and want to know where to start for the decimal
(or bigfloat) stuff.
The goal is to be able to read and write some data from a SQL
DB with
I have a Node.js module written in D and exposed through C++
interface. I'd like to implement a proper async API which is
pretty straightforward using libuv in the C++ glue part. On the D
side I have a data structure that's build once and then queried
from Node (possibly torn down and rebuild l
On Tue, 10 Jun 2014 23:28:16 -0400, Kapps wrote:
On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote:
In Mr. Cehreli's book it says
Additionally, the length of dynamic arrays can be changed by assigning
a value to this property:
int[] array; // initially empty
array.length = 5;
On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote:
On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote:
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Example: I have this C function that is compiled into a
library
//File: factorial.h
int factorial(int n);
//File
On Wednesday, 11 June 2014 at 15:14:19 UTC, Colin wrote:
On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote:
On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote:
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Example: I have this C function that is compiled into a
li
On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote:
On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote:
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Example: I have this C function that is compiled into a
library
//File: factorial.h
int factorial(int n);
//File
On 06/11/2014 04:22 PM, Adam D. Ruppe wrote:
> On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote:
>> I believe the correct answer should be "Buy my book!".
>
> ah, of course! I should just make a .sig file lol
>
> http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/
On Wednesday, 11 June 2014 at 14:22:51 UTC, Adam D. Ruppe wrote:
On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote:
I believe the correct answer should be "Buy my book!".
ah, of course! I should just make a .sig file lol
http://www.packtpub.com/discover-advantages-of-programming-in-
On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote:
I believe the correct answer should be "Buy my book!".
ah, of course! I should just make a .sig file lol
http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
chapter 4 talks about this kind of thing :P
So I was hoping for a learning experience, and I got it. With a
little playing around, looking at phobos, and TDPL, I think I've
figured out how lowerBound gets its predicate. It learns it from
assumeSorted. So I can do this:
order.assumeSorted!((a, b) => number[a] < number[b])
.lowerBoun
On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote:
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Example: I have this C function that is compiled into a library
//File: factorial.h
int factorial(int n);
//File: factorial.c
#include "factorial.h"
int factorial(int n)
{
On 06/11/2014 03:54 PM, Adam D. Ruppe wrote:
> On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
>> Question: How do I use it from D?
>
> Write the prototype in your D file with extern(C):
> extern(C) int factorial(int n);
>
> then just call the function normally in D. Make sure you inclu
On Wednesday, 11 June 2014 at 13:44:25 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
There is a reason why I never use D's std lib.
artur
Well, (IMO) it's a problem with no real solution. But for what
it's worth, most (if not all) of the algorithms in the standard
lib know how to handle
On 06/11/14 15:44, Artur Skawina wrote:
> If, instead, you create a string-specific 'countUntil' that returns
> a type that holds both the byte and code-point counts and implicitly
> converts to the latter, then you can have a 'takeExactly' overload
> that uses the extra info to avoid the unnecessa
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Question: How do I use it from D?
Write the prototype in your D file with extern(C):
extern(C) int factorial(int n);
then just call the function normally in D. Make sure you include
all the C object files when you compile the D program
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
Example: I have this C function that is compiled into a library
//File: factorial.h
int factorial(int n);
//File: factorial.c
#include "factorial.h"
int factorial(int n)
{
if(n!=1)
return n*factorial(n-1);
}
Question: How do
Example: I have this C function that is compiled into a library
//File: factorial.h
int factorial(int n);
//File: factorial.c
#include "factorial.h"
int factorial(int n)
{
if(n!=1)
return n*factorial(n-1);
}
Question: How do I use it from D?
On 06/11/14 14:40, monarch_dodra via Digitalmars-d-learn wrote:
> For example, you should avoid "countUntil" and "takeExactly" when dealing
> with strings, since these are not O(1) operations, and don't actually return
> string slices. EG:
> string s = "someGGGreatVariableName".slicer().front;
>
On Wednesday, 11 June 2014 at 13:25:03 UTC, John Colvin wrote:
On Wednesday, 11 June 2014 at 13:20:37 UTC, Andrew Brown wrote:
You are correct. assumeSorted and lowerBound will provide
better time complexity than countUntil
I'm sorry, one final question because I think I'm close to
understa
On Wednesday, 11 June 2014 at 13:20:37 UTC, Andrew Brown wrote:
You are correct. assumeSorted and lowerBound will provide
better time complexity than countUntil
I'm sorry, one final question because I think I'm close to
understanding. Map produces a forward range (lazily) but not a
random a
You are correct. assumeSorted and lowerBound will provide
better time complexity than countUntil
I'm sorry, one final question because I think I'm close to
understanding. Map produces a forward range (lazily) but not a
random access range? Therefore, lowerBound will move along this
range un
On 6/11/2014 2:14 PM, Matt wrote:
window = SDL_CreateWindow (cfg["window"]["caption"].str.ptr,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height,
SDL_WINDOW_SHOWN);
I'm curious -- does cfg[""][""].str ensure that the string is null
terminated? Because if it doesn't, you
On Wednesday, 11 June 2014 at 11:50:36 UTC, Andrew Brown wrote:
map is fully lazy.
However, if you've already got the sorted indices in `order`,
I would do this:
auto numLessThanN = numbers.indexed(order).countUntil!((x) => x
>= N)();
That indexed command is perfect though, does the trick,
On Wednesday, 11 June 2014 at 11:38:07 UTC, Andrew Brown wrote:
My question about this is how lazy is map? Will it work on
every value of order and then pass it to lowerBound, or could
it work to evaluate only those values asked by lowerBound? I
guess probably not, but could a function be com
On Wednesday, 11 June 2014 at 11:42:42 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
On 06/11/14 00:31, "Nordlöw" via Digitalmars-d-learn wrote:
Either way, it shouldn't be too hard to implement. Base it
off "splitter!pred", which is actually quite trivial. AFAIK,
your
What do you mean by
map is fully lazy.
However, if you've already got the sorted indices in `order`, I
would do this:
auto numLessThanN = numbers.indexed(order).countUntil!((x) => x
>= N)();
That indexed command is perfect though, does the trick, thank you
very much.
On 06/11/14 00:31, "Nordlöw" via Digitalmars-d-learn wrote:
>> Either way, it shouldn't be too hard to implement. Base it off
>> "splitter!pred", which is actually quite trivial. AFAIK, your
>
> What do you mean by basing it off splitter!pred - should I start with some
> existing splitter algori
My question about this is how lazy is map? Will it work on
every value of order and then pass it to lowerBound, or could
it work to evaluate only those values asked by lowerBound? I
guess probably not, but could a function be composed that
worked in this way?
Thank you very much
Andrew
m
On Wednesday, 11 June 2014 at 11:22:08 UTC, Andrew Brown wrote:
Hi there,
The problem this question is about is now solved, by writing my
own binary search algorithm, but I'd like to ask it anyway as I
think I could learn a lot from the answers.
The problem was, given an array of numbers, do
Hi there,
The problem this question is about is now solved, by writing my
own binary search algorithm, but I'd like to ask it anyway as I
think I could learn a lot from the answers.
The problem was, given an array of numbers, double[] numbers, and
an ordering from makeIndex size_t[] order, I
On Wed, 11 Jun 2014 02:30:00 +
WhatMeWorry via Digitalmars-d-learn
wrote:
> In Mr. Cehreli's book it says
>
> Additionally, the length of dynamic arrays can be changed by
> assigning a value to this property:
>
> int[] array; // initially empty
> array.length = 5; // now has 5 elements
>
> wh
I conclude that because I have similar errors when trying to
build 64-bit library on 32-bit system.
/usr/bin/ld:
/usr/lib/x86_64-linux-gnu/libphobos2.a(format_712_5b3.o):
relocation R_X86_64_32 against `.rodata' can not be used when
making a shared object; recompile with -fPIC
/usr/lib/x86_64
It seems like you're trying to compile 64-bit code when you are
on 32-bit system and you have 32-bit libphobos.
On Tuesday, 10 June 2014 at 20:58:41 UTC, Nordlöw wrote:
Is there a way to, programatically (trait), lookup the source
file and position of a user defined type either dynamically or,
even better, statically?
I don't know about the source file, per se, but std.traits has
the fullQualifiedName!
On Tuesday, 10 June 2014 at 14:06:58 UTC, bearophile wrote:
Juanjo Alvarez:
Probably I pretty simple question, how could I mark some code
to be compiled when in debug OR unittest mode? (or both, ||)
At first I tough I could do:
version(unittest, debug) {}
You can define a enum boolean valu
On Wednesday, 11 June 2014 at 05:46:07 UTC, Ali Çehreli wrote:
On 06/10/2014 08:06 PM, Matt wrote:
> On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote:
>> int[] array; // initially empty
>> array.length = 5; // now has 5 elements
>>
>> while in Mr. Alexandrescu's book, it says
>>
>>
On Tuesday, 10 June 2014 at 22:31:37 UTC, Nordlöw wrote:
Either way, it shouldn't be too hard to implement. Base it off
"splitter!pred", which is actually quite trivial. AFAIK, your
What do you mean by basing it off splitter!pred - should I
start with some existing splitter algorithm in Phobos
66 matches
Mail list logo