John wrote:
> It's nothing to do with the @property attribute. So you need to
> define a constructor. Also, use "new" when creating instances.
Thanks Simon and John. First actual usage of D classes and mistaken
assumption that C++ syntax is valid. :-)
--
Shriramana Sharma, Penguin #395953
On Thursday, 23 August 2012 at 13:56:05 UTC, Philippe Sigaud
wrote:
On Tue, Aug 21, 2012 at 6:43 AM, Bobby Bingham
wrote:
[...]
[...]
A possibility is to use a function template, passing the double
as a template argument:
string test(double d)() // d is a template
Here is my code:
// File dllmain.d
module dllmain;
import core.runtime;
import std.c.stdlib;
import std.string;
import std.c.windows.windows;
import honmod;
private HINSTANCE g_hInst;
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG
ulReason, LPVOID pvReserved)
{
g_hInst
On Friday, 1 January 2016 at 22:45:20 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 22:02:46 UTC, alkololl wrote:
I've found that std.c.windows.windows doesn't include a
std.c.windows is basically useless. The new version should have
it in core.sys.windows.windows though I'm not
Ok, So Deit allows D code inside html... looks great.
But how do external variables work? If I create a variable in the
server(such as a class), can an html file access it easily? (not
having to jump through hoops)
doctype html
html
head
title D string interpolations
Hello. With this code:
import std.stdio, std.regex;
void main()
{
immutable numbers = regex(r"\d+");
foreach (match; "a1b2c3d4e5".matchAll(numbers))
writeln(match[0]);
}
compiling gives the error:
(4): Error: cannot implicitly convert expression (regex("\\d+", "")) of
type
Shriramana Sharma wrote:
> Why is it impossible for a Regex object to be
> `immutable`?
I find that I can't declare it as `const` either... This is most curious!
--
Shriramana Sharma, Penguin #395953
If I have:
struct TimeSpan { double start, end; }
Then both the following automatically work:
auto s = TimeSpan();
auto t = TimeSpan(1, 2);
But if I make it a class (I need to) then I have to explicitly define a
field-wise constructor else only a constructor with no args is automatically
On Saturday, 2 January 2016 at 02:03:13 UTC, Shriramana Sharma
wrote:
Shriramana Sharma wrote:
Why is it impossible for a Regex object to be
`immutable`?
I find that I can't declare it as `const` either... This is
most curious!
I think it's because regex() only compiles the regex at
cym13 wrote:
> Is it that you
> can't make an immutable regex()? In that case it is a
> runtime-related issue and those variables just have to be
> mutable. Or is it that you want to be able to use an immutable or
> const regex (be it from regex() or ctRegex!()) with matchAll()?
> In the latter
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
You fell for the C# syntax like me...
According to Ahli. You have to use the old C way of doing it with
readf.
On Friday, 1 January 2016 at 22:00:04 UTC, TheDGuy wrote:
On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B.
wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
is there any way to get the pixel color
On Saturday, 2 January 2016 at 02:39:36 UTC, Shriramana Sharma
wrote:
Aw come on. The immutability of the variable is *after* it has
been created at runtime.
Sure, but still...
> you'll find that using
ctRegex() instead will allow you to declare it immutable for
example. I didn't look at
On Friday, 1 January 2016 at 22:02:46 UTC, alkololl wrote:
I've found that std.c.windows.windows doesn't include a
std.c.windows is basically useless. The new version should have
it in core.sys.windows.windows though I'm not sure if it has
actually been released yet.
If it isn't in there
On Saturday, 2 January 2016 at 02:56:35 UTC, cym13 wrote:
On Saturday, 2 January 2016 at 02:39:36 UTC, Shriramana Sharma
wrote:
Aw come on. The immutability of the variable is *after* it has
been created at runtime.
Sure, but still...
> you'll find that using
ctRegex() instead will allow
On Saturday, 2 January 2016 at 00:32:20 UTC, alkololl wrote:
Why is that?
I'm not sure, but in the switch you posted, you didn't handle the
DLL_THREAD_ATTACH and DLL_THREAD_DETACH cases, the runtime might
be incrementing the refcount there.
Check this out:
On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
is there any way to get the pixel color of a single pixel by
x and y coordinates of a context?
Hey there and a happy new year,
I wrote a C++ Dll which gets injecrted into another process. Now
I want to port that Dll to D. In my C++ Dll I used a while loop
which captures all keystrokes via GetAsyncKeyState and waited for
F7 to be pressed and lastly unloads the dll via
cym13 wrote:
> I think it's because regex() only compiles the regex at runtime
> so it needs to be modified later ;
Aw come on. The immutability of the variable is *after* it has been created
at runtime.
> > you'll find that using
> ctRegex() instead will allow you to declare it immutable for
Rikki Cattermole wrote:
> How exactly is a D version more bulky then C?
> After all everything C can do, D can do with a very similar syntax.
Source-code wise D is much leaner than C, obviously, but object-code wise it
is *huge* even with dynamically linking Phobos:
The binary size of
On 01/01/16 11:15 PM, Shriramana Sharma wrote:
Rikki Cattermole wrote:
Either port it to D and extern(C) it so it is accesible from other
languages or not have CTFE support.
I already wrote it in D, then I ported to C with much effort. The option to
extern(C)-ing it didn't occur to me. :-(
Rikki Cattermole wrote:
> Either port it to D and extern(C) it so it is accesible from other
> languages or not have CTFE support.
I already wrote it in D, then I ported to C with much effort. The option to
extern(C)-ing it didn't occur to me. :-( Also, the D version is really much
too bulky.
On Friday, 1 January 2016 at 10:14:58 UTC, Shriramana Sharma
wrote:
Hello. I'm trying the following code:
import std.stdio;
class TimeSpan
{
immutable double start, end;
@property double length() { return end - start; }
}
void main()
{
auto p = TimeSpan(1, 2);
writeln(p.length);
Hello. I'm trying the following code:
import std.stdio;
class TimeSpan
{
immutable double start, end;
@property double length() { return end - start; }
}
void main()
{
auto p = TimeSpan(1, 2);
writeln(p.length);
}
...and I'm getting the error:
Error: no property 'opCall' for
On Friday, 1 January 2016 at 10:14:58 UTC, Shriramana Sharma
wrote:
auto p = TimeSpan(1, 2);
Error: no property 'opCall' for type '.TimeSpan'
The error should be in 'auto p = ...', not in the line using the
property.
Instantiate with 'new TimeSpan(1, 2)' instead of 'TimeSpan(1,
2)'.
The following works:
---
struct Foo { float x; }
auto val(Foo foo) { return foo.x; }
auto val(ref Foo foo, float val) { return foo.x = val; }
unittest {
auto f = Foo();
f.val = 5;
assert(f.val == 5);
}
---
But the following fails to compile with 'val(b) is not an lvalue'.
---
struct
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
The solution is that readln() returns a string that also contains
the newline
this can be solved by easily stripping the
https://github.com/Hackerpilot/dfmt
After run build.bat nothing do not happens. How can I build it?
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping the newline off
import std.string;
int i = to!int(input.strip);
Sorry my bad english.. i wrote solution but meant
On Friday, 1 January 2016 at 14:47:20 UTC, TheDGuy wrote:
On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping
On Friday, 1 January 2016 at 11:59:39 UTC, rcorre wrote:
auto val(T)(ref Bar!T bar, float val) { return bar.x = val; }
Uh, never mind. That `float` should have been `T`. Seems to work
now.
I'd like to implement a Skyline Rectangle packing algorithm.
A DList should store the actual Skyline. (So the order is
important, it will mostly have to access the right or left node
element)
And a Binary Heap which should hold a pointer to every DList
element.
(Mostly for fast accessing the
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
On 31.12.2015 23:37, rcorre wrote:
struct Vector(T, int N) { }
alias Vector2(T) = Vector!(T, 2);
void fun1(T)(Vector!(T, 2) vec) { }
void fun2(T)(Vector2!T vec) { }
unittest {
fun1(Vector!(float, 2).init);
fun2(Vector!(float, 2).init);
}
Why can fun1 deduce `T`, but fun2 can't?
On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping the newline off
import std.string;
int i =
On 01/01/2016 01:37 PM, TheDGuy wrote:
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
is there any way to get the pixel color of a single pixel by x and y
coordinates of a context?
render to a png back
On 30.12.2015 12:06, Ivan Kazmenko wrote:
import std.regex, std.stdio;
void main ()
{
writeln (bmatch ("abab", r"(..).*\1")); // [["abab", "ab"]]
writeln (match("abab", r"(..).*\1")); // [["abab", "ab"]]
writeln (matchAll ("abab", r"(..).*\1")); // [["abab", "ab"]]
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
is there any way to get the pixel color of a single pixel by x
and y coordinates of a context?
render to a png back buffer.
see
On Friday, 1 January 2016 at 14:20:05 UTC, Suliman wrote:
https://github.com/Hackerpilot/dfmt
After run build.bat nothing do not happens. How can I build it?
The easiest way to do it is to download and install dub - the
package manager from https://code.dlang.org/ and then run
dub fetch
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently asked questions by new users..
I added a tip to my new docs:
On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote:
On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote:
Hello,
is there any way to get the pixel color of a single pixel by x
and y coordinates of a context?
render to a png back buffer.
see
On Friday, 1 January 2016 at 15:22:18 UTC, Mike Wey wrote:
On 01/01/2016 01:37 PM, TheDGuy wrote:
[...]
you would either cr.getTarget(); or
cairo.ImageSurface.ImageSurface.create.
I'm not sure how those would get you access to the pixel data.
Okay, thanks for your answer.
So which
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently
On Friday, 1 January 2016 at 17:00:23 UTC, TheDGuy wrote:
If i had known that blog existed. I think your example at the
end of the page explains the problem really well.
Thanks!
I just wrote that example in response to this thread :P (the
overall thing there is something i started last week
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently
45 matches
Mail list logo