I've been working on porting an old D library to D2, and I'm running into a
nasty issue with templates and inheritance. I've got a base class like this:
class Reader {
void get(T)(ref T[] buffer);
}
and a subclass like this:
class SubReader {
void get()(SomeClass param);
}
The problem
In the interim, I'm just redefining the template in the base class, but that's a
really annoying hack to have to perform every single time I have to make a new
form of the template.
Correction: redefining in the *subclass*. Silly me.
Thanks! I guess I'll just have to live with redefining the functions, do some
sort
of interface/mixin thing, or change the class interface. It makes sense that
template functions aren't virtual (how are you supposed to deal with vtables?),
but I wish that at least an alias declaration could work.
I think I got it! This seems to work:
class Derived {
//Pulls in all the template forms in the base class
template get(args ...) {
alias Base.get!args get;
}
//Create new versions of get() here.
}
Shouldn't this go into 'digitalmars.D' ?
== Quote from Denis Shelomovskij (verylonglogin@gmail.com)'s article
[...]
https://github.com/D-Programming-Language/d-programming-language.org/blob/master/bugstats.php.dd#L24
width=48em height=18em
Font size is about 14px so these areas for few digits are very big:
~700px x 250px. Opera
Are there OpenCL/GL API bindings for D?
Hello.
I know D isn't Java, but one trivial thing I liked about Java is
the introduction of 'extends' and 'implements' as keywords as ways
to clarify the class relationships when defining a class. You
know:
class Subclass extends SuperClass implements AnInterface {
...
}
Will they ever add
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Mon, 07 Nov 2011 13:22:07 -0500, %u n...@devnull.com wrote:
In order for such a humongously code-breaking change to occur,
there would
have to be dire reasons why this was necessary. Because you
liked Java
Hello. I'm having problems compiling the following:
// From chapter 1 of D Programming Language.
//
import std.stdio, std.string;
void main() {
uint[string] dictionary;
foreach( line; stdin.byLine()) {
// Break sentence into words
// Add each word in the sentence to the vocabulary
== Quote from bearophile (bearophileh...@lycos.com)'s article
simendsjo:
Shouldn't the original way work too?
I don't remember.
Another point: I recommend compiling with debug symbols as it
gives you
a nice stacktrace.
I think debug symbols should be present on default, to produce a
nice
Hello.
I go to digitalmars to read digitalmars.D.learn newsgroup, but I
have to click the http link. The http interface is kind of
awkward. I'd like to try the newsgroup link.
But, I don't know how to use it. How do I? Is there a client I
can download and use for free that you recommend? I
== Quote from Nick Sabalausky (a@a.a)'s article
%u y...@yo.com wrote in message
news:j655f0$fm8$1...@digitalmars.com...
Hello.
I go to digitalmars to read digitalmars.D.learn newsgroup, but
I
have to click the http link. The http interface is kind of
awkward. I'd like to try
== Quote from Nick Sabalausky (a@a.a)'s article
I guess I don't know how to setup my outlook client to use the
news
link? When I click the news link. Nothing happens.
I don't have access to a Win7 machine ATM, but on both XP and
Vista, you can
do:
Tools - Accounts. There will be a button
nice video
by the way he mentioned Andrei Alexandrescu around 12:00
does D compatibility with C restrict D from evolving ?
and if D drop this will that prevent complexity?
i have qustion why filter can't return int[]
and if lambda return the last Expression without return keyword it would much
cleaner
Nested parallelism.
is this new consept? and is this exist in D?
template factorial(int n) { const factorial = n * factorial!(n-1); }
template factorial(int n : 1) { const factorial = 1; }
i think this pattern matching or like it, can i do the same thing with regular
function
int factorial(int n) {
return n* factorial(n-1);
return 1 ;
}
int factorial(int n
I have 2 issue:
1- i can't install the package, there is problem I don't know what is it?
2-it is not updated.
is there a way to install gdc without gcc because I already have gcc install
in archlunix?
This is off topic but if you're interested you can get it to run using
float if you change the Sphere code to:
FP eps = 1e-2; instead of 1e-4;
You could use the 'scope' keyword, no?
From what I've heard it's being deprecated/removed -- although I'd be
glad to hear otherwise.
'scope' in the position you have it, will not prevent this, no.
What is the purpose of 'scope' in the parameter list?
How do you plan on camelCasing pure, nothrow, out, ref, etc?
An idea for a potential use of annotations:
How about being able to annotate _anything_ with a template?
It would be the equivalent of Python's annotations: the template's
first parameter would be an alias to the thing being annotated, and
its return value would be the code generated for that
related
http://www.blog.spoongraphics.co.uk/articles/a-guide-to-creating-professional-quality-logo-designs
maybe that help
== Quote from Rainer Schuetze (r.sagita...@gmx.de)'s article
The static module constructor causes your module to take part in
the
module initialization phase, so it creates a data structure that
contains info about modules which are imported and should be
initialized
first (referenced directly
Hi!
I'm working on a little kernel with D, and so far, I've been able to
boot it and set up a physical memory manager.
Now, I'm trying to allow for module constructors in the code. However,
as soon as I define one, I see errors like this:
Error 42: Symbol Undefined
== Quote from kenji hara (k.hara...@gmail.com)'s article
Note: A simple way to construct environment for build dmd/druntime/phobos i
s:
1. Expand newest release package.
2. Replace dmd2/src/dmd, dmd2/src/druntime, and dmd2/src/phobos to
checkouted git repositories.
3. Copy
I understand it
thanks
== Quote from Bernard Helyer (b.hel...@gmail.com)'s article
http://www.youtube.com/watch?v=dQw4w9WgXcQ
The answers lie within.
This video is not available in your country. Learn more. Sorry about that.
I've got no idea what the video is about and the YouTube page doesn't offer any
clue.
Hi!
Is this a bug, or is it intentional that this fails? I can't come up
with any case where it would cause a problem, but the compiler doesn't
like the fact that there's a const in the structure:
struct Temp { const int a; int b; }
auto ref foo(Temp* t) { return *t; } //Error
This is what Rebindable(T) is for:
http://www.digitalmars.com/d/2.0/phobos/std_typecons.html
Timon:
What about:
void removeAt(T)(ref T[] arr, size_t index)
{
foreach (i, ref item; arr[1 .. index+1])
item = arr[i - 1];
arr = arr[1 .. $]; //note how no valid data is beyond the end of
the array
}
Clever, but if you do this with a big enough number of items, you'll
exhaust
I have a question,
can I write all functions like this object.function() instead of
functin(object) ?
or that form for some function or cases.
On 05/10/2011 07:06 PM, Piotr Szturmaj wrote:
I forgot to ask. Any comments or suggestions?
This is **beast**.
Just one thing: Would it work correctly if I was using fibers in my
own code?
In Patterns of Human Error, the slide 31 point that you should replce int with
size_t
why that consider an error ?
size_t val1 = int.max+1;
int val2 = int.max+1;
writeln(val1); // 2147483648
writeln(val2); // -2147483648
very clear example
thanks you both
thanks you all, it works.
last thing, I have this
Tuple!(int,int,int)(1, 2, 3)
how can I use the return values individual?
to be more clear if I rturn tuple(a, b, c) can I write in the code
void main() {
//call the function here
writeln(a);
}
Bearophile (you should change your nick or not) wrote:
[I found this litter while walking along the highway]:
If one of the challenges of evolving a widely used language is
that there's a lot of code out there that we don't want to break,
one of the benefits is that there's a lot of code out
I have function which have more than one return, and the code compile and run
but it gives rong result -I guess-, so i use tuple but the compiler can't
return tuple.
how can I return values?
why I can't return tuple?
Is it necessary free memory allocated for member of structure, like in C? I
suppose not (we have gc). Example:
struct BITMAP {
(...)
ubyte[] pixels;
}
BITMAP* bitmap = new BITMAP;
bitmap.pixels = new ubyte[100*100];
(...)
// delete bitmap.pixels; //not necessary?
delete bitmap;
For the time, I'd suggest removing core.dll_helper from your
imports. I believe it's mainly used for Dll's written in D. It'll
need to be looked at to see how GDC should deal with it.
Thanks, yeah that makes the errors go away fortunately, though it
still makes me wonder why that's happening.
The module expects the following TLS symbols:
_tlstart
_tlsend
_tls_callbacks_a
The GCC TLS emulation prefixes all outputted symbols with ___emutls_:
___emutls_t._tlsstart
___emutls_v._tlsend
And does not yet have _tls_callback_a which is a Windows specific symbol.
I imagine that the
core/dll_helper.d has been recently moved to core/sys/windows/_dll.d, so you
might just have the old import file core/dll_helper.di lying around on your disk
without the correspondent file being built into druntime.
Ooh that makes sense, I didn't know that; thanks!
If you could alias the symbols that would work. You may have to use GCC or
GAS
to do it.
#pragma weak symbol1 = symbol2
This pragma declares symbol1 to be a weak alias of symbol2.
I unsure what you could do about _tls_callbacks_a since I have no idea what it
does. I know that TLS
I'm not sure if this is the best place to put this question, but since I'm
guessing people here have managed to get GDC to compile D2, I thought I'd ask:
So I just downloaded GDC from
https://bitbucket.org/goshawk/gdc/downloads/gcc-4.5.2-tdm-1-gdc-r546-20110417.zip
and also TDM's GCC from
I'm not sure if this is the best place to put this question, but since I'm
guessing people here have managed to get GDC to compile D2, I thought I'd ask:
D.gnu is the best place for GDC issues and questions.
Ah okay cool. I'll post the code here since you asked but I'll post things there
next
what is the equivalent for this code in D?
#include stdio.h
main()
{
struct S { int i; };
struct S s, *s_ptr;
s_ptr = s;
s_ptr-i = 9;
printf(%d\n, s_ptr-i);
}
is there any different b/w:
auto arr = new int[10];
and
int[10] arr;
?
Well, 5155 is fairly simple. The bug report details four one line
changes to Object.di and Object_.d. See
http://d.puremagic.com/issues/show_bug.cgi?id=5155
Also, If that doesn't do the trick, please e-mail me as I would like
to fix the root cause. (And let you test the library)
Oops sorry, I
Thanks for the link!
I tried compiling the file, and I got these errors:
variant.d(454): Warning: statement is not reachable
variant.d(454): Warning: statement is not reachable
variant.d(454): Warning: statement is not reachable
variant.d(634): Warning: statement is not reachable
variant.d(660):
Sorry. It was late and I forgot to mention some things. A) My code is
dependent on patch 5155, and B) I forgot about
changes, etc, that I had to make to go from DMD 2.051 to DMD 2.052. I've
uploaded my current working copy and remade the
docs. Let me know if you have any issues with this. (And
I've added reflection capabilities to an update to std.variant I'm working
on. Overloads work.
General functions work. (Although a few bugs with opCall and opDispatch
prevents the ideal syntax:
var.x(5) vs var.x = 5 and var.call(5) vs var(5), but I assume those will be
eventually fixed). I've
please do
I was trying to write a Dynamic class for D, which uses opDispatch
to allow for late binding, but I ran into a problem:
While my class works well for regular methods inside a class, it
fails to work for:
(1) Template methods inside a class
(2) Methods with overloads
(3) Global methods that have
!`')O5R='D@86)S
M=')A8W0@5'EP94EN9F\@='EP94ED*D[#0H)'5B;EC(')E9B!4(%S*%0I
M*D@R!AW-EG0H=AIRYT7!E260@/3T@='EP96ED*%0I*3L@F5T=7)N
M(IC87-T*%0J*71H:7,N%9A;'5E.R!]#0I]#0H-G-T871I8R!B;V]L(ES
M1'EN86UI8RA47!E26YF;R!T*2![(%U=\@87-424-L87-S(#T@8V%S=A4
M7!E26YF;U]#;%SRET.R!R971UFX@87-424-L87-S(%IR!N=6QL(8F
M(AAU1
What's UCFS?
Whoops, typo. xD Uniform Function Call Syntax. :)
Hi--
I just downloaded the dmd installer and ran it on Win7 (64 bit). It clobbered
my Path environment variable entirely, replacing it with C:\D\dm\bin. I
didn't see, much less choose, an option to replace my Path.
Sorry if this is the wrong place to post this; I couldn't find a forum on
== Repost the article of Jens Mueller (jens.k.muel...@gmx.de)
== Posted at 2011/03/22 05:48 to digitalmars.D
%u Ishan Thilina wrote:
Well, The biggest question in my mind is that how many container types
that I should implement?
Sorry to answer with a question: In which are you interested
Well, The biggest question in my mind is that how many container types that I
should implement? Also will I be able to use a hierarchy similar to a
programming
language such as Java or C++ ?
I just thought of a (crazy) idea:
Should D implement a likely keyword for if statements?
Something like:
if likely (x == 2)
{
//do something
}
This would allow the compiler to generate branch prediction code for
the program, allowing the programmer to prevent branch predictions.
It's a
Hi,
I'm interested in the GSoC project idea which is listed in
http://prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas#Containers . But the
problem is that I couldn't find the relevant mentor for the project. Can
somebody help me to find the mentor and contact him?
Thank you...!
Excellent. I highly doubt we care about std.parallelism working on
embedded platforms. (Who the heck has a multicore embedded CPU
anyway?)
I KNOW!!
64k ought to be enough for anybody, right?
Does anyone happen to know what exactly VSI.lib is? I'm trying to
build Visual D in Visual Studio 2008, and I'm getting:
Building ..\bin\Debug\vsi.lib...
The system cannot find the drive specified.
..\bin\Debug\vsi.lib not created!
I've already installed the Visual Studio 2008 SDK, but this
You can use windbg.exe, which is in \dmd\windows\bin. Of course,
you'll also need to download the Digital Mars C++ compiler from
http://www.digitalmars.com/download/freecompiler.html
Hm... I already have WinDbg (and DMC), but I never thought it's any
more efficient to debug with WinDbg than with
I'd like to note that you need to compile with DMC using the
makefiles provided, then cv2pdb -C and debug with Visual Studio.
Ohh so I need to use cv2pdb, that's why! Thanks a lot! :)
== Quote from ZY Zhou (rin...@geemail.com)'s article
std.utf throw exception instead of crash the program. but you still need to
add
try/catch everywhere.
My point is: this simple code should work, instead of crash, it is supposed to
leave all invalid codes untouched and just process the
But for the following case, it is complete wrong if it crash at line 3:
1: char[] c = [0xA0];
2: string s = c.idup;
3: foreach(dchar d; s){}
The expected result is either:
a) crash at line 2, c is not valid utf and can't be converted to string
or:
b) don't crash, and d = 0xDCA0;
I
I tried using Visual Studio to set breakpoints in DMD and everything
(after compiling with -g), but it said that the source file is a
different version (it isn't), and so it doesn't really let me set
breakpoints.
What tools (aka debuggers) do you guys use to debug DMD? Any free
tools we can use
It seems to me that the SpanMode.breadth option when enumerating a
directory does not actually do breadth-first search, but rather
performs a kind of depth-first preorder traversal.
In other words, to me, this is depth-first postorder traversal:
\A
\A\1
\A\1\x
\A\1\y
\A\2
\B
\B\1
whereas this
So apparently, it's incredibly hard (if not impossible) to have a true
breadth-first search that scales up reasonably well to, say, an entire
volume of data:
stackoverflow.com/questions/5281626/breadth-first-directory-traversal-
is-it-possible-with-olog-n-memory
I suggest we rename the option to
I think pitfalls like this one (with the garbage collector, for example)
should definitely be documented somewhere. I would imagine that quite a few
people who try to set the length of an array
won't realize that they can run out of memory this way, especially because it's
nondeterministic
I think the advantage of gtk or Qt is people can reinvest previous
knowledge of the framework. (I mean, they are cross-language in
addition to be cross-platform ;-) I would personly prefere a clearly
designed D-specific GUI system than gtk's huge mess. (Dunno about
Qt, people seem to find it far
Increasing the sizes of an array has always given me the shivers, as
beautiful as it is.
Could someone explain why this code behaves the way it does?
string s = 1234;
s.length = 7;
writefln(\%s\, s);
prints: 1234���
Given that it makes no sense to extend a const-size array,
Huh, interesting, okay.
I think pitfalls like this one (with the garbage collector, for
example) should definitely be documented somewhere. I would imagine
that quite a few people who try to set the length of an array won't
realize that they can run out of memory this way, especially because
it's
I don't think I understand your reasoning. Enum members can't
have names which are also keywords, hence enums should be
capitalised? You could equally well use this argument for *all* D
symbols...
Yes, we could (and in fact, I'd advocate for a D version of C#'s @
symbol for marking keywords as
Fortunately, these are very not any kind of most logical
choices. Neither according to D's own naming convention, nore
(imo) according to plain common sense. I have the same kind of use
case as you, apparently (including even a 'TypeCodes' enum!), and
thank to D's very weird naming, /I/ can use
I just submitted an application for GSoC 2011 on behalf of Digital
Mars. Please review and contribute to the project ideas page:
http://prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas
Thanks,
Andrei
Uh... how helping fix compiler bugs? Could we help with that? I feel
that's *much* more important
Uh... how helping fix compiler bugs? Could we help with that? I
feel that's *much* more important than benchmarking, for instance,
since it doesn't make sense to benchmark something if it has bugs.
:\
The funny thing is that sometimes it makes perfect sense, as
benchmarks _do_ push the limits
Uh... how helping fix compiler bugs? Could we help with that? I feel that's
*much* more
important than benchmarking, for instance, since it doesn't make sense to
benchmark something if
it has bugs. :\
I have the same feeling. I'd like to see such projects. But I believe
students are more
In machine learning it's very common to trade off accuracy for
speed.
Andrei
Er... do you _honestly_ think people will start writing machine
learning programs in D, when we're even having trouble getting them
to use D for more typical applications (because of bugs)?
Also, I (obviously) used
I have the same feeling. I'd like to see such projects. But I
believe students are more likely to pick feature-oriented projects.
The stuff that sounds cool.
And I wouldn't be surprised if Google as well is also more likely
to accepted feature-oriented projects than bug-fix ones.
Wait, I think
Also, I (obviously) used the word accuracy to mean
predictability, not approximation.
Then you were being inaccurate :o).
Andrei
I thought the meaning was predictable. :P
Out of curiosity, what's stopping you from helping fix bugs right
now? I agree that being paid for it adds motivation, but if it's
something you want to do, do it.
Great question! :)
Right now? The fact that I'm in school and have other things to do. :(
During the summer? The fact that I
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
On Monday, March 07, 2011 12:10:27 %u wrote:
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
and add /path/to/unzipped/dmd2/linux/bin to your path.
how can i add path ?
Put it in the appropriate bashrc file
The general naming convention as far as variable names go is camelcased with
the name starting with a lower case letter - this includes constants. Most of
Phobos follows this, and the parts that
haven't been have been moving towards it. There are likely to be a few
exceptions, but on the
this is part of the code:
void WritePushPop(cmd command, string segment, int index)
{
string temp = TextFile.Asm;
AsmFile = new File(temp, FileMode.OutNew );
string x = toString(index);
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
and add /path/to/unzipped/dmd2/linux/bin to your path.
how can i add path ?
I didn't see this example being mentioned in this thread (although I
might have missed this), but would someone explain why (1) the code
below doesn't compile, and (2) why it's considered context-free?
struct MyStruct { ref MyStruct opMul(MyStruct x) { return this; } }
...
OpOverloadAbuse a, b;
a
That's essentially the example that's been under discussion - though in this
case it's a ref instead of
a temporary for the lvalue. Regardless, it's context free because a * b is by
definition a variable
declaration, not a call to the multiplication operator. If you want it to use
the
i can't install dmd or gdc in arch linux from AUR
i don't way?
in dmd:
this the error massage
object.d: Error: module object is in file 'object.d' which cannot be read
import path[0] = /usr/include/d
import path[1] = /usr/include/d/druntime/import
in gdc:
i can't install it and i use this command
yaourt -R gdc
== Quote from %u (asm...@hotmail.com)'s article
i can't install it and i use this command
yaourt -R gdc
i mean yaourt -S gdc
Thanks for this idea. I plan to submit an organization application. As of now
I'm
unclear whether Digital Mars would be the best organization to apply, as
opposed to
an unincorporated d-programming-language.org entity. I'll discuss this with
Walter. All, please chime in if you have related
Andrei Alexandrescu Wrote:
On 3/2/11 3:20 PM, Walter Bright wrote:
dsimcha wrote:
== Quote from Walter Bright (newshou...@digitalmars.com)'s article
bearophile wrote:
Bekenn:
The use of ref introduces a level of indirection.
This is correct. But a minimally decent compiler must be
Well, it wouldn't be universal then. For a function to be treated
as a property, it would require an annotation, but universal
function call syntax isn't supposed to require an annotation any
more than calling a function on an array as if it were a member
function requires an annotation. It's
();
scope(exit) Runtime.terminate(); // ERROR here
return main(0, null);
}
int main(string[] args)
{
writefln(%u, args.length);
return 0;
}
-
If I comment out the line with the error, it runs fine *inside* the Visual
1 - 100 of 307 matches
Mail list logo