On Wednesday, 12 June 2013 at 11:05:22 UTC, bearophile wrote:
Rob T:
Rather disappointing that this fails. Anyone know if this is
an expected limitation of UFCS or a bug?
Probably no one thought on this case. Why do you think it's
useful?
Bye,
bearophile
If we're to use UFCS as a means t
On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
On 06/11/2013 07:55 PM, Alex Horvat wrote:
On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
On 06/11/2013 05:56 PM, Alex Horvat wrote:
TreeStore store = cast(TreeStore)tvTreeView.getModel();
In this case store == null
I thi
On Wednesday, 12 June 2013 at 16:15:08 UTC, Craig Dillabaugh
wrote:
Do you have access to the source code of the library? Or are you
just linking to it?
I do some-what.
I don't want to change the source code of the library itself, but
I can change the C/C++ code of the binding that is used b
Carlos:
What do I have to know about how D works with data ?
If you want to avoid the overflow, then use a BigInt from
std.bigint:
import std.stdio, std.bigint;
void main() {
foreach (immutable i; 0 .. 100)
writeln(i, " ", 2.BigInt ^^ i);
}
Bye,
bearophile
On Thursday, 13 June 2013 at 02:03:35 UTC, Jonathan M Davis wrote:
On Thursday, June 13, 2013 03:46:59 Carlos wrote:
import std.stdio;
import std.math : pow;
void main()
{
cast(ulong)count;
That line won't compile.
foreach (count; 1 .. 33){
write((2)^^(count), " : ", count, "\n");
}
}
same
On Thursday, June 13, 2013 03:46:59 Carlos wrote:
> import std.stdio;
> import std.math : pow;
>
> void main()
> {
> cast(ulong)count;
That line won't compile.
> foreach (count; 1 .. 33){
> write((2)^^(count), " : ", count, "\n");
> }
> }
>
> same output.
If you want to set the type of count,
import std.stdio;
import std.math : pow;
void main()
{
cast(ulong)count;
foreach (count; 1 .. 33){
write((2)^^(count), " : ", count, "\n");
}
}
same output.
I have this code :
import std.stdio;
import std.c.stdlib;
void main()
{
foreach (count; 1 .. 33){
write((2)^^(count), " : ", count, "\n");
}
exit (0);
}
And here is the output :
2 : 1
4 : 2
8 : 3
16 : 4
32 : 5
64 : 6
128 : 7
256 : 8
512 : 9
1024 : 10
2048 : 11
4096 : 12
8192 :
On Thursday, 13 June 2013 at 00:27:33 UTC, bearophile wrote:
Carlos:
Thank you for your time.
That's one bitwise operator. You want ^^
Bye,
bearophile
I didn't understoof in the first try but Infiltrator told me on
the #d irc chat and here is the new code.
import std.stdio;
import std.c
Carlos:
Thank you for your time.
That's one bitwise operator. You want ^^
Bye,
bearophile
On Thursday, 13 June 2013 at 00:24:18 UTC, Carlos wrote:
So I have this code I'm working on but I get weird results.
What am I doing wrong ?
Code :
import std.stdio;
import std.c.stdlib;
void main()
{
foreach (count; 1 .. 16){
write("Result : ", (2)^(count), " from : ", count, "\n");
So I have this code I'm working on but I get weird results. What
am I doing wrong ?
Code :
import std.stdio;
import std.c.stdlib;
void main()
{
foreach (count; 1 .. 16){
write("Result : ", (2)^(count), " from : ", count, "\n");
}
}
Prints:
Result : 3 from : 1
Result : 0 from
On 06/12/2013 03:49 PM, Dylan Knutson wrote:
> DPaste has stopped responding to requests at the time of writing,
Being an old ;) old-timer I never understood the need for those sites.
>
> import std.algorithm : map;
> import std.range : isInputRange, ElementType;
As a workaround, make tha
Hello! I'm trying to make a deepMap function which operates on
the deepest non-range element of an array. I think that this
function should theoretically work, however there are some
compiler errors that I can't quite understand.
Here's the code: http://dpaste.dzfl.pl/97918311
And the compile
DPaste has stopped responding to requests at the time of writing,
so here's the code in case its still down by the time someone
reads this:
import std.algorithm : map;
import std.range : isInputRange, ElementType;
// Doesn't work
//template deepMap(alias pred, Range)
//if(isInputRange!Ra
On 06/12/2013 03:45 PM, Dylan Knutson wrote:
Hello! I'm trying to make a deepMap function which operates on the
deepest non-range element of an array. I think that this function should
theoretically work, however there are some compiler errors that I can't
quite understand.
Here's the code: http
On 06/12/2013 02:56 PM, matovitch wrote:
On Wednesday, 12 June 2013 at 21:52:46 UTC, Ali Çehreli wrote:
Here is one way:
void func(V, alias def_val) (uint i, V v)
if (is (typeof(def_val == V.type)))
Oops. It should be:
if (is (typeof(def_val) == V.type))
Hmmm. How come the other on
matovitch:
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
I think something like that is not yet possible, but maybe it
will be possible later.
Your code has also allowed me to find a new small compiler bug
that
On Wednesday, 12 June 2013 at 21:52:46 UTC, Ali Çehreli wrote:
Here is one way:
void func(V, alias def_val) (uint i, V v)
if (is (typeof(def_val == V.type)))
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
Ali
Thank you !
On 06/12/2013 02:47 PM, matovitch wrote:
To be more precise the code below doesn't compile :
struct Vector(T, uint N)
{
alias T type;
enum dimension = N;
T data[N];
}
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
To be more precise the code below doesn't compile :
struct Vector(T, uint N)
{
alias T type;
enum dimension = N;
T data[N];
}
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
void main()
{
On 06/12/2013 02:26 PM, matovitch wrote:> Hello,
>
> I got a simple vector template :
>
> struct Vector(T, uint N)
> {
>alias type T;
You later corrected that it should be
alias T type;
But still, prefer the new syntax over the backward C syntax:
alias type = T;
>T data[N]
On 06/11/2013 07:55 PM, Alex Horvat wrote:
On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
On 06/11/2013 05:56 PM, Alex Horvat wrote:
TreeStore store = cast(TreeStore)tvTreeView.getModel();
In this case store == null
I think that one should work, how are you setting/creating the Tre
On Wednesday, 12 June 2013 at 21:36:38 UTC, H. S. Teoh wrote:
On Wed, Jun 12, 2013 at 11:26:40PM +0200, matovitch wrote:
Hello,
I got a simple vector template :
struct Vector(T, uint N)
{
alias type T;
[...]
This line should read:
alias type = T;
And it should work as you wan
On Wed, Jun 12, 2013 at 11:26:40PM +0200, matovitch wrote:
> Hello,
>
> I got a simple vector template :
>
> struct Vector(T, uint N)
> {
> alias type T;
[...]
This line should read:
alias type = T;
And it should work as you wanted.
T
--
If you look at a thing nine hundred an
Hello,
I got a simple vector template :
struct Vector(T, uint N)
{
alias type T;
T data[N];
}
And I'd like to call a function like :
void func(V, V.type default_value)(args...);
But this (of course) doesn't work. Is there a simple and nice way
to do this ? (I'm sure there is ;-))
On 06/12/2013 12:12 PM, Maxime Chevalier-Boisvert wrote:
The closest is to put both classes and the function in the same
module. Things all in the same module can see the private members of
each other.
Good enough for my needs. Thanks.
Sometimes 'package' is more suitable than 'private'.
Ali
I think you've hit bug city in the associative array
implementation. The "this" in there doesn't seem to point at
anything meaningful. This is probably worthy of a bug report.
A potential workaround is to store pointers to your structs in
the associative array, that way you can set them up ahe
On 06/12/2013 01:12 PM, gedaiu wrote:
> Hi,
>
> Can anyone help me why this code goes wrong? I get exit code 139 with
> DMD 2.063
>
>
> import std.stdio;
>
>
>
> struct Test {
> string val = "";
> string[] key;
>
> /**
> * operator "=" overload
> */
> Test opAssign
On 06/12/2013 01:20 PM, MaB wrote:
Hi!
I want to bulid up a IndexArray with a structure like this (PHP code):
$arrIndex = array(
"A" => array(
"B" => array()
),
"B" => array(
"B" => array("C" => array())
)
);
The Keys are of Type string and the valu
I was referring to the COM server support stuff in the Juno
library, which allocates COM objects outside the GC heap so the
GC will never collect them.
See
https://github.com/JesseKPhillips/Juno-Windows-Class-Library/blob/master/juno/com/core.d#L3147
for an example.
Hi,
Please look at this thread. You might find your answer there:
http://forum.dlang.org/thread/vphniyxyvgsiazutt...@forum.dlang.org
Bogdan
On Wednesday, 12 June 2013 at 20:20:09 UTC, MaB wrote:
Hi!
I want to bulid up a IndexArray with a structure like this (PHP
code):
$arrIndex = array(
Hi!
I want to bulid up a IndexArray with a structure like this (PHP
code):
$arrIndex = array(
"A" => array(
"B" => array()
),
"B" => array(
"B" => array("C" => array())
)
);
The Keys are of Type string and the values can be arrays with the
same structur
Hi,
Can anyone help me why this code goes wrong? I get exit code 139
with DMD 2.063
import std.stdio;
struct Test {
string val = "";
string[] key;
/**
* operator "=" overload
*/
Test opAssign(string val){
this.val =
The closest is to put both classes and the function in the same
module. Things all in the same module can see the private
members of each other.
Good enough for my needs. Thanks.
Does D have something like the concept of friend classes and
functions in C++? I'd like to have a function that can access
private members of two classes at the same time.
On Wednesday, 12 June 2013 at 19:01:24 UTC, Maxime
Chevalier-Boisvert wrote:
Does D have something like the concept of friend classes and
functions in C++?
The closest is to put both classes and the function in the same
module. Things all in the same module can see the private members
of each
On Wednesday, 12 June 2013 at 19:01:24 UTC, Maxime
Chevalier-Boisvert wrote:
Does D have something like the concept of friend classes and
functions in C++? I'd like to have a function that can access
private members of two classes at the same time.
No (t really), you have to stick the two clas
Dmitry Olshansky:
There is no ambiguity, 1 is not a Regex object but it seems
like template constraint in std.regex blows up.
@Temtaime please file a bug on this.
http://d.puremagic.com/issues/
std.algorithm.splitter(arr, 1);
I think this bug already surfaced some time ago... Maybe it's
al
12-Jun-2013 17:28, bearophile пишет:
Temtaime:
How i can avoid this?
You have to qualify where the function comes from. One way to do it is
to use:
There is no ambiguity, 1 is not a Regex object but it seems like
template constraint in std.regex blows up.
@Temtaime please file a bug on
On 2013-06-11 19:48, captaindet wrote:
On 2013-06-11 07:35, Adam D. Ruppe wrote:
On Tuesday, 11 June 2013 at 10:12:27 UTC, Temtaime wrote:
ubyte k = 10;
ubyte c = k + 1;
This code fails to compile because of: Error: cannot implicitly
convert expression (cast(int)k + 1) of type int to ubyte
T
On Wednesday, 12 June 2013 at 04:05:22 UTC, Jeremy DeHaan wrote:
Hey guys,
I have something I am curious about, but haven't had much luck
with when doing research and experimenting.
Basically, I am working with a library that uses ostreams
internally and I want to somehow redirect that to wh
"Richard Webb" writes:
> On Wednesday, 12 June 2013 at 14:41:05 UTC, finalpatch wrote:
>
>>
>> This feels even more cumbersome than in C++ because in C++ we can
>> simply
>> delete this in the Release() method, there's no need to store a
>> reference in a global place.
>>
>
>
> Juno does this by
On Wednesday, 12 June 2013 at 14:41:05 UTC, finalpatch wrote:
This feels even more cumbersome than in C++ because in C++ we
can simply
delete this in the Release() method, there's no need to store a
reference in a global place.
Juno does this by allocating the object on the non-gc heap,
On Wednesday, 12 June 2013 at 10:59:42 UTC, Szymon Gatner wrote:
I know how to iterate over members when type is known at
compile time (with __traits) but I can't find a documentation
of how to get them polymorphically, I mean:
It hasn't been implemented in the runtime yet (though all the
pie
Oh, thanks very much.
Hi Sean,
Thanks for your reply. I have no problem with client side COM
programming in D. What I'm asking is if I write a COM object in D (in
this case the D code is a COM server), then it looks like I have to
store a reference to that COM object in some globally reachable place
(eg. add it to a gl
Ahh, looks like the stack trace is supported only in debug mode.
-g option made the exception to spit out the function names.
$ rdmd -g t.d
object.Exception@t.d(5): in f1
0x0040CC9C in char[][]
core.sys.windows.stacktrace.StackTrace.trace()
0x0040CB27 in core.sys.windows.stack
Could someone please tell me how can I get the stack trace when
an exception is thrown? My test code:
Code: -
void f1() {
throw new Exception("in f1");
}
void f2() {
f1();
}
void f3() {
f2();
}
void main() {
f3();
}
Output: ---
On 6/11/2013 10:38 PM, finalpatch wrote:
A typical COM server would create a new object (derived from IUnknown),
return it to the caller (potentially written in other languages).
Because the object pointer now resides outside of D's managed heap, does
that mean the object will be destroyed when t
Temtaime:
How i can avoid this?
You have to qualify where the function comes from. One way to do
it is to use:
std.algorithm.splitter(arr, 1);
Bye,
bearophile
I know the reason to mark a method as trusted from the docs:
Trusted functions are guaranteed by the programmer to not
exhibit any undefined
behavior if called by a safe function. Generally, trusted
functions should be kept
small so that they are easier to manually verify.
Undefined behavior
Hello guys!
http://dpaste.1azy.net/9c4c3eb8
http://dpaste.1azy.net/afd8d20b
How i can avoid this?
denizzz:
says what sfTime* can not be implictly converted to sfTime*
Maybe it's a diagnostic bug. Please create a minimal example.
Bye,
bearophile
Rob T:
Rather disappointing that this fails. Anyone know if this is an
expected limitation of UFCS or a bug?
Probably no one thought on this case. Why do you think it's
useful?
Bye,
bearophile
Hi,
I am trying to get members of a class via pointer to Object.
I know how to iterate over members when type is known at compile
time (with __traits) but I can't find a documentation of how to
get them polymorphically, I mean:
class Foo
{
int x, y;
}
Object o = new Foo();
auto ci = o.cla
On Wednesday, 12 June 2013 at 10:09:07 UTC, Simen Kjaeraas wrote:
On Wed, 12 Jun 2013 11:44:19 +0200, Zhenya
wrote:
OK,you say that TypeTuple!("foo","bar") is a cool value of type
TypeTuple!(string,string),right?
Well, yes and no, not really. It's a bit magical. In your case,
it's assigned
On Wed, 12 Jun 2013 11:44:19 +0200, Zhenya wrote:
OK,you say that TypeTuple!("foo","bar") is a cool value of type
TypeTuple!(string,string),right?
Well, yes and no, not really. It's a bit magical. In your case,
it's assigned to an auto variable, and that variable gets that type.
There are oth
On Wednesday, 12 June 2013 at 08:14:06 UTC, Simen Kjaeraas wrote:
On Wed, 12 Jun 2013 10:01:59 +0200, Zhenya
wrote:
Hi!
I was just surprised when realized, that this code compiles
and runs:
import std.typetuple;
import std.stdio;
void main()
{
auto foo = TypeTuple!("foo","bar");
writeln
On Wed, 12 Jun 2013 10:01:59 +0200, Zhenya wrote:
Hi!
I was just surprised when realized, that this code compiles and runs:
import std.typetuple;
import std.stdio;
void main()
{
auto foo = TypeTuple!("foo","bar");
writeln(typeid(typeof(foo)));
writeln(foo);
}
If I were compiler expert,I
Hi!
I was just surprised when realized, that this code compiles and
runs:
import std.typetuple;
import std.stdio;
void main()
{
auto foo = TypeTuple!("foo","bar");
writeln(typeid(typeof(foo)));
writeln(foo);
}
If I were compiler expert,I'd say that it's a bug.But I am not)
So, can anybody
61 matches
Mail list logo