On Wed, 10 Aug 2011 10:35:46 +0200, Dainius (GreatEmerald)
past...@gmail.com wrote:
I seem to have run into a problem with the function pointer method
here. I have this code:
arco.d:
struct FrontendFunctions {
void function(SoundTypes) Sound_Play;
void function()
On Sat, 06 Aug 2011 22:53:31 +0200, Jonathan M Davis jmdavisp...@gmx.com
wrote:
Feel free to create a feature request on it. It may even get the language
changed. However, having more than one invariant complicates things a
bit,
since right now, it's easy for the runtime to just call the
On Fri, 05 Aug 2011 18:43:27 +0200, Kai Meyer k...@unixlords.com wrote:
On 08/05/2011 03:02 AM, Pelle wrote:
Don't declare variables until you need them, just leave bytes_read and
bytes_max here.
Is there a performance consideration? Or is it purely a style or
D-Factor suggestion?
Just
On Fri, 05 Aug 2011 00:25:38 +0200, Kai Meyer k...@unixlords.com wrote:
I have a need for detecting incorrect byte sequences in multiple files
(2) at a time (as a part of our porting effort to new platforms.)
Ideally the files should be identical for all but a handful of byte
sequences (in
On Thu, 04 Aug 2011 21:56:16 +0200, Nick Sabalausky a@a.a wrote:
OT: Who the hell uses MSN?
Almost everyone below 60 in Sweden, at least a few years ago.
On Thu, 04 Aug 2011 11:32:03 +0200, simendsjo simend...@gmail.com wrote:
I would like to use a template mixin to add some fields to a struct, but
I'd also like the template to add additional invariant checks without
having to remember to add this for all struct/classes that mixes in this
On Thu, 04 Aug 2011 12:40:48 +0200, simendsjo simend...@gmail.com wrote:
On 04.08.2011 12:30, Pelle wrote:
What happens if you replace assert(_c) with assert(_c !is null)?
The problem is that you cannot include more than one invariant() in a
struct or class.
IIRC assert(obj) gets
On Wed, 03 Aug 2011 08:29:09 +0200, Jacob Carlborg d...@me.com wrote:
Yes, convert the first code point to a wchar and then throw if there's
more the one character in the string.
Not tested, and I might be wrong, but 'to!' should work between dchar and
wchar, no?
wchar to_wchar(string
On Mon, 01 Aug 2011 21:43:13 +0200, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
Actually I don't really need *uniform* distribution, it's just that
when porting C code to D I didn't find any obvious random()/rnd()
functions, and uniform seemed to be the closest thing without having
to
On Fri, 29 Jul 2011 15:37:36 +0200, bearophile bearophileh...@lycos.com
wrote:
On an oldish Windows PC an empty C program generated by GCC takes about
0.03 seconds to run. An empty D2 program runs in about 0.11 seconds. Is
this expected/good/acceptable/fixable?
Bye,
bearophile
That's a
On Wed, 27 Jul 2011 19:41:37 +0200, Dainius (GreatEmerald)
past...@gmail.com wrote:
I have one program design problem and I wonder if anyone here could
give any suggestions about it. The situation is like this: I am
splitting a game into a frontend (a library) and a backend (an
executable).
On Tue, 26 Jul 2011 13:06:56 +0200, Dainius (GreatEmerald)
past...@gmail.com wrote:
I updated the DMD and tried RDMD, but still no luck. Linker errors
galore. You can see all of them here: http://pastebin.com/C6cRVGKt
You need to link the library as well, try adding -L-llua (I think) to the
On 01/08/2011 04:45 PM, tsukikage wrote:
eg. to return a fibonacci delegate:
return (ulong m) {
if(m 2) return m ;
return _self_ref(m-1)+_self_ref(m-2) ;
} ;
Is it possible? Thank you!
http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator
I don't think there's a built in way to
On 01/06/2011 07:31 AM, %u wrote:
If you have allocated a large uint[], most likely =C3=ACt will be flagged
NO_SCAN, meaning it has no pointers in it, and the GC will ignore it.
Ah, but the trouble is, no one said that this array has to be in the GC heap! I
could easily have a void[] and a
On 01/04/2011 02:55 PM, spir wrote:
Hello,
I'm bluffed by the 2 terms l-value r-value used in C-line language common
terminologies. I think I guess what they mean, but I don't understand the need for such absconse
idioms. Why not:
l-value- variable
r-value- value (or
On 12/21/2010 07:38 PM, Andrej Mitrovic wrote:
I found this by accident:
import std.stdio;
import std.conv;
void main()
{
writeln(to!string(2, 2)); // writes 10
writeln(to!string(1, 0)); // std.conv.ConvException: Radix error
}
I'm not sure why std.conv.to would even take multiple
On 12/16/2010 02:16 PM, d coder wrote:
Greetings
I need a way to know (using traits or other compile time constructs)
all the types derived from a given type.
Is it possible in D?
Is it possible to get a list of all the user-defined classes? I could
use that to filter out the classes that I
On 12/13/2010 09:45 PM, Heywood Floyd wrote:
Good Evening from Berlin!
Have been reading the chapter about concurrency by Andrei. Nice.
I have some questions, of varying quality, I'm sure.
Let's say that we have some sort of structure of rather complex data. To give
us something concrete
On 12/09/2010 10:53 PM, Trass3r wrote:
It was quite hard to track that one down.
In the following example the import statement was mixed into the class
among other code so it wasn't as obvious as here.
import std.traits;
class Foo
{
import std.string;
static assert(isNumeric!int);
}
foo.d(6):
On 12/02/2010 09:05 AM, vincent picaud wrote:
Matthias Pleh Wrote:
Thank you for your reply and yes that works :)
Now i m facing with the following problem, what is the trick for input stream ?
( something like
std::istream operator(std::istream in,A a)
{
// A.someData in;
On 12/02/2010 01:07 PM, spir wrote:
Hello,
Is there an equivalent of 'in' for (non-associative) arrays? Cannot find any
'contains' function.
(Wouldn't it be nice to have in work for all arrays? What is the reason why it
only works with AAs?)
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
On 11/22/2010 04:12 PM, Simen kjaeraas wrote:
spir denis.s...@gmail.com wrote:
On Sun, 21 Nov 2010 20:21:14 -0500
bearophile bearophileh...@lycos.com wrote:
If in a D2 program I have an array of mutable items I may want to
iterate on them but not modify them, so I'd like the iteration
On 11/22/2010 08:18 PM, spir wrote:
Hello,
Let us say I have a parsing library. Now, I want to define parsers in
stand-alone modules -- for code structuration and reusability. Then, import
them from apps that need them.
Is there another way than defining the parser (== list of patterns) at
On 11/12/2010 02:03 PM, Steven Schveighoffer wrote:
Pelle, I spent all this time helping him, and you swoop in with the
answer :)
I was in a rush when answering, causing the swoopiness of my post. :-)
I only knew the answer because I had almost exactly the same bug a week
ago, or so
On 09/30/2010 08:25 PM, Sebastian Schuberth wrote:
On 30.09.2010 20:20, wrzosk wrote:
void main()
{
Vec3f v(1,1,1);
}
I still get
Building Release\ConsoleApp1.exe...
main.d(14): found 'v' when expecting ';' following statement
Building Release\ConsoleApp1.exe failed!
Change
Vec3f v(1,1,1);
On 09/21/2010 09:29 AM, Bob Cowdery wrote:
Hi
I'm stuggling with immutable.
I have a fixed size buffer which is used as a circular buffer of floats
and is effectively double buffering data I wish to transfer to another
thread. At an appropriate point I take the top half or bottom half of
the
On 09/10/2010 04:40 AM, Andrej Mitrovic wrote:
I'm trying to use algorithm.copy, but I get back nothing in the copy buffer.
How do I to copy an array of ubyte's?
iimport std.algorithm,
std.concurrency,
std.stdio;
void main()
{
enum bufferSize = 4;
auto tid =
On 09/10/2010 10:17 AM, Jonathan M Davis wrote:
On Friday 10 September 2010 00:50:32 bearophile wrote:
Jonathan M Davis:
Aren't they _always_ on the heap?
void main() {
int[10] a;
int[] b = a[];
}
Bye,
bearophile
Ah, good point. When you have a slice of a static array as opposed
On 09/10/2010 03:20 PM, Jacob Carlborg wrote:
On 2010-09-07 22:32, Don wrote:
Jacob Carlborg wrote:
On 2010-09-07 17:29, Don wrote:
Jacob Carlborg wrote:
I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof
where it says:
typeof(this) will generate the type of what this
On 09/08/2010 02:24 PM, Steven Schveighoffer wrote:
On Tue, 07 Sep 2010 14:06:58 -0400, Steven Schveighoffer
schvei...@yahoo.com wrote:
On Tue, 07 Sep 2010 11:37:20 -0400, Pelle pelle.mans...@gmail.com
wrote:
On 09/07/2010 04:33 PM, Steven Schveighoffer wrote:
Yes, a valid return. Your
On 09/07/2010 03:15 PM, Steven Schveighoffer wrote:
On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote:
On 2010-09-07 14:49, Steven Schveighoffer wrote:
On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote:
On 05/09/2010 02:16, Jonathan M Davis wrote:
void
On 09/07/2010 04:33 PM, Steven Schveighoffer wrote:
Yes, a valid return. Your function should be:
void foo(void delegate(const(C) f) const
It helps to understand that inout/const/immutable has NOTHING to do with
code generation, it only has to do with limiting what compiles. For this
reason,
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Peter Alexander peter.alexander...@gmail.com wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
andrej.mitrov...@test.com wrote:
What does char[1 + Range.empty] do? It
On 09/06/2010 08:53 PM, Philippe Sigaud wrote:
On Mon, Sep 6, 2010 at 18:47, Pelle pelle.mans...@gmail.com
mailto:pelle.mans...@gmail.com wrote:
On 09/04/2010 02:11 PM, Simen kjaeraas wrote:
Is there a way you could write an isStatic(expr) template? Using
template
On 09/02/2010 10:24 PM, bearophile wrote:
simendsjo:
Suggestions for D-ifying the code is welcome.
Your unit tests are not good enough, they miss some important corner cases.
This my first version in D2:
import std.string: indexOf;
/// return True if s1 is a rotated version of s2
bool
On 09/03/2010 01:35 PM, bearophile wrote:
Pelle:
bool isRotated(T)(T[] a, T[] b) {
return a.length == b.length (a.length == 0 ||
canFind(chain(a,a), b));
}
Nice clean solution. I suggest to add pure and two const in the signature.
canFind isn't really the best possible name
On 08/28/2010 10:25 PM, bearophile wrote:
torhu:
string a = abc;
auto hash = typeid(a).getHash(a);
If higher performance is necessary, you may pre-compute part of that:
void main() {
string a = abc;
auto hash1 = typeid(a).getHash(a);
auto stringHash =(typeid(a).getHash);
On 08/13/2010 01:17 AM, dcoder wrote:
Hello. How do you declare and initialize a map that looks like the following:
Name = [ Personal Info]
Where personal info is type string[string].
I can't get this to compile. I'm wondering what I am doing wrong:
import std.stdio;
void main() {
On 08/09/2010 12:50 AM, bearophile wrote:
This D2 code:
import std.regex: splitter, regex;
import std.array: array;
void main() {
array(splitter(, abc, de, regex(, *)));
}
Gives the errors:
test.d(4): Error: template std.array.array(Range) if (isForwardRange!(Range))
does not match any
On 08/02/2010 10:23 AM, Dmitry Olshansky wrote:
On 02.08.2010 5:23, bearophile wrote:
Can you tell me why std.file.read() returns a void[] instead of
something like a ubyte[]?
Well, it magically converts to whatever array type you have. So this works:
ubyte[] data = read(trash.txt);
This
On 08/02/2010 11:27 PM, bearophile wrote:
Ryan W Sims:
The problem isn't how to check it on a case-by-case basis, there are
plenty of ways to check that a given pointer is non-null. The problem is
debugging _unexpected_ null dereferences, for which a NPE or its
equivalent is very helpful, a
On 08/03/2010 12:02 AM, bearophile wrote:
Pelle:
What I really wish for is non-nullable types, though. Maybe in D3... :P
I think there is no enhancement request in Bugzilla about this, I will add one.
I think there has been, at least this has been discussed on the newsgroup.
To implement
On 08/03/2010 12:32 AM, bearophile wrote:
Pelle:
I think a good thing would be NonNull!T, but I haven't managed to create
one. If this structure exists and becomes good practice to use, maybe we
can get the good syntax in D3. In 20 years or so :P
Maybe we are talking about two different
On 08/03/2010 01:08 AM, bearophile wrote:
Pelle:
struct NotNull(T) if(is(typeof(T.init !is null))) {
Is this enough?
struct NotNull(T) if (is(T.init is null)) {
this(T t) {
enforce(t !is null, Cannot create NotNull from null);
enforce() is bad, use Design by Contract
On 07/28/2010 12:57 AM, Nick Sabalausky wrote:
Trying to convert some D1 code to D2:
On 2.047, I'm trying to do this:
import std.string;
void foo(string str)
{
str =
std.algorithm.map!(
(char a) { return inPattern(a, [digits, letters])? a : '_'; }
)(str);
}
And I'm getting:
On 06/23/2010 09:41 AM, Ali Çehreli wrote:
Ali Çehreli wrote:
dcoder wrote:
So, I moved the initialization to inside the main function, and now
it works.
Great. I think we need to put this question in the FAQ.
For future reference, if it really needs to be global:
uint[string] mywords;
On 05/11/2010 01:38 AM, Trass3r wrote:
Yeah it still works for compatibility reasons but is deprecated.
Not yet, it's not. To compile something that's deprecated, you will need
the -d switch.
Right now, both are allowed, but the old one is scheduled for
deprecation and presumably later
On 05/06/2010 01:10 PM, bearophile wrote:
Lars T. Kyllingstad:
In particular, note Kasumi Hanazuki's post and Andrei's response to it.
Thank you, it seems Andrei agrees with me. But I think here thinks have to be
kept tidy, otherwise it's easy to make a mess.
The syntax offers various
On 05/03/2010 04:28 PM, Dan wrote:
Hi,
it certainly helps. However I can't help myself, I still thinking that this is
the most complicated, hard read and to understand way to
overload operators. Maybe there is something I'm missing but I can't really see
the reason of all that. Other
On 03/18/2010 05:43 PM, Paul D. Anderson wrote:
If I'm implementing a struct and want to provide for duplication, is there a
standard way to implement this?
Here's an example:
//---
struct S {
// members of the struct -- three integer values
int a;
On 03/11/2010 10:20 PM, bearophile wrote:
While looking for possible attribute problems to add to Bugzilla, I have seen
the following D2 program compiles and runs with no errors or warnings:
static foo1() {}
static does not apply to free functions, I would guess this means the
same as
On 03/11/2010 10:44 PM, bearophile wrote:
As far as I know, it's enum that has that purpose.
Oh, but they are not the same. enum declares a constant, whereas static
declares a variable. A static global is still mutable.
Thank you for your answers,
bearophile
Why thank you!
On 03/05/2010 07:50 PM, bearophile wrote:
div0:
putting it in Foo simply puts it in a namespace.
So my (wrong) idea of immutable applied to a struct was that every thing in
such namespace becomes immutable (I think this is a bit more intuitive).
What do you think of modifying D2 so in a
On 02/28/2010 09:16 PM, Ellery Newcomer wrote:
Hello
The impetus:
I agree, except I more and more think that scope classes were a
mistake. Structs with destructors are a much better solution, and
wrapping a class inside a struct would give it RAII semantics.
The problem:
In designing a
On 02/16/2010 08:09 PM, Funog wrote:
Is it possible to run an external .exe and have access to its standard
input/output? Apparently std.process does not allow this.
You'll want to choose either the input or the output stream, otherwise
you might get eaten by a deadlock.
On 02/08/2010 01:48 PM, Trass3r wrote:
Why isn't == used to compare the struct members in the code above? I
mean, if I compare the structs with == it could also use == to compare
the members. If I use is to compare the structs it could use is to
compare them members.
Structs are compared
On 01/28/2010 02:32 AM, strtr wrote:
Personally, I use (D1)std2.conv a lot to get values from strings and thus would
love the following default behaviour for all types:
int i = 0; // i = 0
i = cast( int ) 0; // i = 48 ( If I read the utf8 table correctly )
What keeps this from being the case?
On 01/26/2010 01:02 AM, Nick Sabalausky wrote:
strtrst...@spam.com wrote in message
news:hjd6t1$be...@digitalmars.com...
This may be is a very basic question, but is there a way to let me omit a
repeating variable when doing multiple boolean operations?
if ( var == a || var == b || var == c
On 01/23/2010 12:29 AM, strtr wrote:
Simen kjaeraas Wrote:
Not tested, but they should work:
if ( anySame( var, a, b, c, d ) ) {
}
if ( allSame( var, a, b, c, d ) ) {
}
A lot prettier.
I thought there would be a generic (basic) solution to this which I just didn't
know about but maybe I
I'm in need for a timer library that measures the acutal time. I have
tried std.c.time's clock(), but it only measures time spent inside the
program, not actual time elapsed.
I need at least millisecond resolution, so std.c.time.time() is not an
option.
I wonder, is there a good library for
On 01/25/2010 04:02 PM, strtr wrote:
Stanislav Blinov Wrote:
Pelle M�nsson wrote:
I'm in need for a timer library that measures the acutal time. I have
tried std.c.time's clock(), but it only measures time spent inside the
program, not actual time elapsed.
I need at least millisecond
61 matches
Mail list logo