On Sunday, 29 September 2019 at 11:36:00 UTC, aberba wrote:
I have no idea how to do that from D. Any help/resources on
that?
You should be able to use the techniques at
https://dlang.org/spec/interfaceToC.html to declare the C
functions that you wish to use in your *.d source files, and
th
On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi
programming...stuff like turning on and off an LED light. I
believe it requires being able to call the Raspberry OS core
APIs from D as available in Python.
Anyone here t
On Thursday, 25 July 2019 at 18:37:49 UTC, Jonathan M Davis wrote:
There's probably at least one bug report on it, but as I
understand it, it's not a bug in the sense that the
implementation is currently expected to handle such a case.
It's an area where betterC should be improved upon, but it
On Thursday, 25 July 2019 at 12:01:40 UTC, Oleg B wrote:
Hello everyone!
I try build this code with betterC
import core.stdc.stdio;
import std.format : format;
extern(C) int main()
{
mixin(format!`enum str = "%s\0";`("hello"));
fprintf(stderr, "%s\n", str.ptr);
return 0;
}
but com
On Thursday, 16 May 2019 at 12:16:26 UTC, Marco de Wild wrote:
Or are there any tips to roll my own implementation?
I took a stab at it:
---
@nogc:
nothrow:
pure:
struct NoGcArray(size_t maxSize, T)
{
private T[maxSize] _buffer;
private T[] _slice;
private size_t _frontIndex;
On Sunday, 14 April 2019 at 01:54:39 UTC, Jamie wrote:
Do @property attributes not allow postincrement operators?
import std.stdio;
struct Foo {
@property bar() { return 10; }
@property bar(int x) { writeln(x); }
}
void main()
{
Foo foo;
writeln(foo.bar); // actually calls foo.
On Thursday, 21 March 2019 at 22:51:21 UTC, James Blachly wrote:
Thanks -- I also tried to figure out how to install GDC just
yesterday and gave up. All wiki links and google top results
seemed dead ends.
I'm also a little puzzled by how GDC is structured, but I have
learned a few things wit
On Wednesday, 13 February 2019 at 22:29:18 UTC, solidstate1991
wrote:
When I tried to apply to a position at Symmetry, I've got a
criticism from Atila Neves that some of my code relied too much
on memcpy, thus making it unsafe. After digging into std.array,
I found some function that could poss
On Wednesday, 15 August 2018 at 08:14:53 UTC, Petar Kirov
[ZombineDev] wrote:
It's not a bug, it's all about how the type system is set up.
The type of an array literal expression like `[1, 2, 3]` is
`int[]` (a slice of an array of ints), so no matter if you do:
auto readonly(T)(const(T)[] x
On Tuesday, 14 August 2018 at 17:22:42 UTC, Seb wrote:
FYI: staticArray will be part of 2.082, it already works with
dmd-nightly:
That just seems wrong. Isn't the fact that `staticArray` is
needed a bug in the compiler? I think the compiler could have
lowered to something like that automat
On Tuesday, 14 August 2018 at 13:42:04 UTC, Andrey wrote:
Hello,
I have a enum:
enum Type : string
{
One = "Q1",
Two = "W2",
Three = "R3"
}
I want to concat it in compile-time:
enum result = doConcat!Type();
And get this result:
writeln(result); // output: "Q1 W2 R3"
Delimiter h
On Monday, 30 July 2018 at 22:40:21 UTC, Hakan Aras wrote:
I'm trying to use extern(C++) classes with -betterC and I would
like to initialize their members properly.
I would also like to be able to use `extern(C++)` classes without
the runtime, but I haven't been able to allocate any time to
On Tuesday, 31 July 2018 at 00:29:45 UTC, Mike Franklin wrote:
I'm not sure if this is right, but check
https://github.com/dlang/dmd/blob/792fe5379af310cbd9348eca910cd5f8889d57ac/src/dmd/toobj.d#L368
Actually, this looks more like what you're looking for:
https://github.com/dlang/dmd/blob/79
On Monday, 30 July 2018 at 22:40:21 UTC, Hakan Aras wrote:
Sorry if this is the wrong category.
Where in the druntime is m_init of TypeInfo_Class set? I'm
trying to use extern(C++) classes with -betterC and I would
like to initialize their members properly.
I don't think it is set in druntim
On Tuesday, 24 July 2018 at 08:09:33 UTC, ANtlord wrote:
So... how prevent appearing of console on the startup of the
application?
Here's my test
---
module HelloMsg;
import core.runtime;
import std.utf;
import core.sys.windows.windows;
auto toUTF16z(S)(S s)
{
return toUTFz!(const(wchar)
On Saturday, 14 July 2018 at 19:04:01 UTC, Andre Pany wrote:
Somehow also the DMD executable needs to know which
Phobos/DRuntime it should use.
How does DMD is working here? Maybe I can do the same...
DMD determines default import and library paths from the dmd.conf
file typically at /etc/dm
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote:
---
// main.d
void main() {
scope(success) {}
}
dmd -betterC main.d
Error: Cannot use try-catch statements with -betterC
---
You can see what the compiler is doing at
https://run.dlang.io/is/5BZOQV and clicking on the "AST
On Wednesday, 13 June 2018 at 07:19:24 UTC, Gokhhy wrote:
Nevermind, it doesn't affect functions inside classes and
structs.
Yeah, that's kindof unfortunate isn't it. Just do the same thing
within the class/struct scope.
class C {
@nogc:
void nogcMethod1() {}
void nogcMehtod2() {
On Wednesday, 13 June 2018 at 06:45:27 UTC, Gokhhy wrote:
Is there a way to define an entire module as @nogc or otherwise
make it so I don't have to qualify every single function as
@nogc?
You can put attributes at the top of a module followed by a ":"
to have them apply to everything below t
On Thursday, 7 June 2018 at 19:19:55 UTC, realhet wrote:
Hi,
The following narrow test program works fine when compiled with
DMD to 32bit target:
import std.stdio, core.sys.windows.windows, core.runtime;
extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE
hPrevInstance, LPSTR lpCmdLin
On Thursday, 24 May 2018 at 18:51:31 UTC, Mike Franklin wrote:
I'm trying to find a way to declare a block of code `nothrow:`
when compiling with -betterC, but not `nothrow` when not
compiling with -betterC.
The solution is needed for this PR:
https://github.com/dlang/druntime/pull/2184/file
On Sunday, 27 May 2018 at 23:21:05 UTC, IntegratedDimensions
wrote:
I came across a few posts mentioning this after the fact. It's
been this way since at least 2012 so... It's now may so not
sure how much longer we'll have to wait. That pull seems to
have stalled. So close but so far away ;/
On Sunday, 27 May 2018 at 09:23:09 UTC, IntegratedDimensions
wrote:
C[] c;
@property C[] get() { return c; }
get ~= something;
errors out, yet
auto q = get;
q ~= something;
is fine.
Why is D thinking that ~= is being applied to get, the
function, rather than what it returns?
Also
When I
I'm trying to find a way to declare a block of code `nothrow:`
when compiling with -betterC, but not `nothrow` when not
compiling with -betterC.
The solution is needed for this PR:
https://github.com/dlang/druntime/pull/2184/files#r188627707
Attempt #1
--
void test() { }
version(D_
On Thursday, 10 May 2018 at 21:16:12 UTC, Jonathan M Davis wrote:
IIRC, there's a DIP for trying to make += work with just
getters and setters, but I don't know if we're ever going to
see anything like it in the language.
Yes, the DIP is here: https://github.com/dlang/DIPs/pull/97
It's curr
On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote:
Structs don't have that.
Should they?
Consider the following code:
---
struct S
{
// intentionally not `static`
struct SS
{
int y() { return x; } // Error: need `this` for `x` of
type `int`
}
int x;
SS ss;
}
void main()
{
S s;
s.ss.y();
}
---
If I change `return x;` to `return this.x;` th
On Wednesday, 25 April 2018 at 01:20:13 UTC, Mike Franklin wrote:
It appears a bug has already been filed
(https://issues.dlang.org/show_bug.cgi?id=11970). I'll see if
I can fix it.
https://github.com/dlang/dmd/pull/8208
We'll see what happens.
On Wednesday, 25 April 2018 at 01:08:46 UTC, Arun Chandrasekaran
wrote:
So I was telling my colleague that D would warn on self
assignment, but found that I was wrong.
https://run.dlang.io/is/HLhtek
```
module a;
import std.stdio;
void main() {
string a;
a = a; // Can the co
On Wednesday, 25 April 2018 at 01:08:46 UTC, Arun Chandrasekaran
wrote:
So I was telling my colleague that D would warn on self
assignment, but found that I was wrong.
https://run.dlang.io/is/HLhtek
```
module a;
import std.stdio;
void main() {
string a;
a = a; // Can the co
On Sunday, 22 April 2018 at 00:41:34 UTC, Nicholas Wilson wrote:
You're not using the C library version of it, the compiler does
the stack space reservation inline for you. There is no way
around this.
I'm not convinced. I did some no-runtime testing and eventually
found the implementation
On Saturday, 21 April 2018 at 19:06:52 UTC, Steven Schveighoffer
wrote:
alloca is an intrinsic, and part of the language technically --
it has to be.
From what I can tell `alloca` is only available in the platform's
C standard library (actually for Linux it appears be part of
libgcc as `__b
On Saturday, 21 April 2018 at 07:37:50 UTC, Mike Franklin wrote:
Does D have some way to dynamically allocate on the stack? I'm
looking for something roughly equivalent to the following C
code.
int doSomething(size_t len)
{
char stackBuffer[len + 1];
doSomethingElse(stackBuffer);
}
Does D have some way to dynamically allocate on the stack? I'm
looking for something roughly equivalent to the following C code.
int doSomething(size_t len)
{
char stackBuffer[len + 1];
doSomethingElse(stackBuffer);
}
Thanks,
Mike
This works:
```
class S {
int n, m;
int sum() { return n + m; }
Inner!(sum) a;
class Inner(alias f){
auto get() {
return f();
}
}
}
```
This doesn't:
```
struct S {
int n, m;
int sum() { return n + m; }
Inner!(sum) a;
struct Inne
On Saturday, 10 March 2018 at 02:25:38 UTC, Richard wrote:
Hi,
I've been trying to see if I can get an mbed project to work
with Dlang
basically compiling D code for use on a Cortex-M Proccessor
You might be interested in the following, if you're not already
aware:
* https://github.com/Jin
On Friday, 9 March 2018 at 14:46:04 UTC, Simen Kjærås wrote:
This is the best I've come up with in the current language:
struct S {
int n;
mixin property!("field", "get => this.n", "set => this.n =
set");
}
Not bad. Not good, but not bad either.
Sadly, there are issues:
1) Wrong
On Friday, 9 March 2018 at 01:22:15 UTC, Mike Franklin wrote:
I would like to know if this can be improved to support the
following:
* binary assignment operators (e.g. +=)
* unary assignment operators (e.g. ++)
* @safe, @nogc, and -betterC compatible
* at least as good code generation as that
On Tuesday, 20 February 2018 at 14:34:53 UTC, bauss wrote:
Would there be a reason why this wouldn't be a good
implementation?
If so what and how could it be improved?
Are there flaws in an implementation like this?
[... snip ...]
I am very interested in this as a potential alternative to th
On Wednesday, 7 March 2018 at 21:39:09 UTC, Apocalypto wrote:
Are there any tutorials about D in vscode?
No that I know of.
Which are the minimal plugins to install to have code
completion, syntax highlighting and code formatting?
I've been getting by with
https://marketplace.visualstudio.
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote:
Hi, I'm new to language and games.
Many people say that GC is bad and can slow down your project
in some moments.
What can happen if I create a game using D without worrying
with memory management?
(using full GC)
Don't let the GC
On Thursday, 22 February 2018 at 04:16:44 UTC, Nick Sabalausky
(Abscissa) wrote:
Are there any tutorials or articles out there for "getting
started with converting a C++ codebase to D one module at a
time?" Or at the very least: tips, tricks, lessions learned,
from those who have come before.
On Sunday, 21 January 2018 at 10:04:36 UTC, Mike Franklin wrote:
What is/was `transition=safe`? I can't find any documentation
on it.
Well, I found
http://forum.dlang.org/post/gquxgusfhyigirfpe...@forum.dlang.org
But, didn't really clear much up for me.
I found the following statement in the DIP1000 document
(https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md)
NB: this DIP is out of sync with -transition=safe
implementation available in dmd and pending a rewrite. Most key
points still apply though.
What is/was `transition=safe`? I c
On Wednesday, 17 January 2018 at 23:15:33 UTC, Jiyan wrote:
I want to convert from ints implicit to a struct type, so for
example:
I'm not sure what your actual use case is, but based on the
example, you can just template `useV`.
import std.stdio;
struct use
{
int x;
i
On Saturday, 6 January 2018 at 05:44:28 UTC, Venkat wrote:
Why does gcc say "unknown demangling style `dlang'" ? Do I need
GDC for demangling to work ?
Check your version of binutils with `ld --version`. It looks
like it was added in v2.25:
http://forum.dlang.org/post/rvoqllpimfskvlabp...@f
On Friday, 29 December 2017 at 12:11:46 UTC, rikki cattermole
wrote:
Structs are structs, classes are classes.
I'm talking about interfaces, which are neither structs nor
classes.
C++ had the mixed model similar to what you suggested, we got
it right and kept it nice and separate. This was
On Friday, 29 December 2017 at 12:06:12 UTC, tipdbmp wrote:
It seems to me that some of the language reference/spec pages
that are somewhat long,
could provide a Toc (Table of contents) which should help users
see an overview of what's
there and improve the searchability and the navigation of th
In C#, structs can inherit from and implement interfaces.
using System;
interface IPrint
{
void Print();
}
struct MyStruct : IPrint
{
public void Print()
{
Console.WriteLine(ToString());
}
}
public class Program
{
public static void Main()
{
MyStruc
On Monday, 25 December 2017 at 10:42:55 UTC, Sobaya wrote:
```
import std.stdio;
int[] x;
void func(scope int[] a) {
x = a;
}
void main() {
func([0,1,2]);
writeln(x);
}
```
This code was successfully compiled and printed '[0, 1, 2]'.
But according to https://dlang.org/spec/funct
On Monday, 25 December 2017 at 11:09:25 UTC, Jonathan M Davis
wrote:
```
import std.stdio;
int[] x;
void func(scope int[] a) {
x = a;
}
void main() {
func([0,1,2]);
writeln(x);
}
```
This code was successfully compiled and printed '[0, 1, 2]'.
But according to https://dlang.
On Saturday, 23 December 2017 at 15:04:30 UTC, kerdemdemir wrote:
Is there any better way for me to search C/C++ equivalent
features? As a humble suggestion would it make sense to make a
table with feature names and corresponding name of the same
feature in other languages ?
Try this:
http
On Thursday, 21 December 2017 at 19:43:16 UTC, Steven
Schveighoffer wrote:
The gist is, you cannot expect that destructors will be run in
a timely manner, or at all.
They may be called, and most of the time they are. But the
language nor the current implementation makes a guarantee that
the
On Thursday, 21 December 2017 at 10:49:46 UTC, Dan Partelly wrote:
I started to look into D very recently. I would like to know
the following, if you guys are so nice to help me:
1. What is the performance of D's GC, what trade-offs where
done in design , and if a in-deep primer on efficient
"Don't expect class destructors to be called at all by the GC"
I was a bit shocked to read that here:
https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors
The document tries to clarify with:
"The garbage collector is not guaranteed to run the destructors
for all unreferenced o
On Tuesday, 19 December 2017 at 10:37:05 UTC, Michael wrote:
On Tuesday, 19 December 2017 at 02:12:29 UTC, Mike Franklin
wrote:
On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom
wrote:
writeln(S.j);
// Error: Instance symbols cannot be used through types.
I don't understand why yo
On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom wrote:
writeln(S.j);
// Error: Instance symbols cannot be used through types.
I don't understand why you would say that is a bug.
I meant that the example is wrong, and a bug report should be
filed to fix the example.
Mike
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote:
I have been looking at the following example found right at the
end of the section here:
https://dlang.org/spec/declaration.html#alias
struct S { static int i; }
S s;
alias a = s.i; // illegal, s.i is an expression
alias b = S.i; //
On Tuesday, 5 December 2017 at 13:43:38 UTC, Nordlöw wrote:
If I get the following stack trace ___without line numbers___
(instead ??:?) what's missing?
and using DMD 2.077.1
https://issues.dlang.org/show_bug.cgi?id=18068
On Tuesday, 17 October 2017 at 19:00:38 UTC, Steven Schveighoffer
wrote:
In this case, an extra destructor call is made without a
corresponding postblit or constructor.
-Steve
https://issues.dlang.org/show_bug.cgi?id=18050
In other words, is 'shared __gshared' redundant?
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
62 matches
Mail list logo