0].filter & EVFILT_READ);
```
The `filter` field of an event is not a flag/bit field. It's just a
plain value, you should use `==` to check if it's a read event.
I'm not sure if fixing these things will solve your issue. But at least
some problems I noticed.
--
/Jacob Carlborg
On 2021-04-06 21:57, Alain De Vos wrote:
Can we say tk ang gtk toolkits are alive.
But wxwidgets , fox an fltk are dead ?
Do you mean these libraries in general or D bindings to these libraries?
--
/Jacob Carlborg
ere in the learn forum or on the DStep specific discussions section
(which I just enabled) on GitHub [2]. I'll do my best to help you.
[1] https://github.com/jacob-carlborg/dstep
[2] https://github.com/jacob-carlborg/dstep/discussions
--
/Jacob Carlborg
On Wednesday, 17 March 2021 at 15:16:36 UTC, Jacob Carlborg wrote:
macOS doesn't support static linking.
The proper way to solve this is to bundle the dynamic libraries
with the application. If it's a GUI application it can be located
in the application bundle. It seems like Dav
On Wednesday, 17 March 2021 at 13:52:48 UTC, Guillaume Piolat
wrote:
On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote:
Anyone else done this? Pointers welcome.
Sorry for delay.
Just add "dflags-osx-ldc": ["-static"],
macOS doesn't support static linking.
--
/Jacob Carlborg
`lockstep`.
--
/Jacob Carlborg
On 2021-02-23 16:34, Decabytes wrote:
ldc2 is the winner thank you! I'd like to get gdc and dmd up and running
to at some point
Unfortunately, DMD doesn't support ARM.
--
/Jacob Carlborg
his, to get
something a bit closer to your original example:
// add this to the Foo struct
static Proxy attributes()
{
return Proxy();
}
struct Proxy
{
string opDispatch(string name)()
{
return __traits(getAttributes, mixin("Foo.", name))[0].value;
}
}
void main()
{
writeln(Foo.attributes.a);
}
--
/Jacob Carlborg
].a == 3);
}
Due to language consistency it should behave the same for all
types.
In the above example, `c` is typed as `const(Foo)[]`. Although, I
wonder why in your example the concatenation is typed as `char[]`
instead of `const(char)[]`. Perhaps that's a bug.
--
/Jacob Carlborg
e for numeric values, strings, characters
and similar values. Why waste extra space on a variable if it's
not needed?
If you don't want a new instance, then don't use `enum`. Use
`immutable` instead.
--
/Jacob Carlborg
g
`typeid(base).initializer.length`.
Base base = new Derived;
assert(__traits(classInstanceSize, Derived) ==
typeid(base).initializer.length);
--
/Jacob Carlborg
nd of like reference types.
They consist of a context pointer and a function pointer. Function
pointer are, as the name suggest, already pointers.
--
/Jacob Carlborg
.
But interestingly, the occurrence of this is much more seldom than
checking the return value after each function.
It's claimed that exceptions are not zero cost, even when an exception
is not thrown. Because the compiler cannot optimize functions that may
throw as well as those that cannot throw.
ne that
throws a static exception (and vice versa); each is translated to the
other automatically by default or you can do it explicitly if you prefer."
But perhaps you're proposing something different for D?
--
/Jacob Carlborg
On 2021-01-05 03:02, kdevel wrote:
expected output: none. The compiler should have rejected the code after
the duplicate definition def #2. dmd 2.093.1 ignores both definitions
instead. Is this a bug or a bug?
DMD 2.095.0 now reports an error for this.
--
/Jacob Carlborg
as well to store different values of
different types. But then everything need to be known at compile
time. That is, the index, in your case.
--
/Jacob Carlborg
On 2020-12-16 16:18, Dave P. wrote:
Is this a bug in the spec or in the implementation?
Yeah, that's a good question. That's always problematic with D. The spec
is incomplete.
How do we get this fixed?
The simplest would be to change the spec.
--
/Jacob Carlborg
r)`.
That function needs to have C calling convention. But to avoid
any conflicts with other `extern(C)` functions I wanted to keep
the D mangling.
https://github.com/dlang/druntime/blob/master/src/core/memory.d#L212-L232
--
/Jacob Carlborg
struct is passed,
on some it doesn't.
--
/Jacob Carlborg
mangling to get the same name
as the C function
void foo(int a, int b); // D calling convention
void main()
{
foo(1, 2);
}
$ clang -o foo.o foo.c -c
$ dmd main.d foo.o
$ ./main
a=2 b=1
LDC behaves the same way as DMD and, IIRC, GDC follows how GCC
passes the arguments.
--
/Jacob Carlborg
eauty!
Or you can call it `rgba`. It seems to be what Wikipedia prefers
[1].
[1] https://en.wikipedia.org/wiki/RGBA_color_model
--
/Jacob Carlborg
lang.org/phobos/core_runtime.html#.rt_term
--
/Jacob Carlborg
or another file) is to mangle the function name
the same way as a D function.
You can either use `extern(C) char*[] hldr` to make only `hldr`
have C linkage. Use `extern(C) {}` to group several symbols which
should have C linkage or rearrange the code so that `static this`
is above `exte
he same code as the compiler is using. Here's an example on how to
use DMD to parse some code [1]. Here's some more advance usages [2].
[1]
https://github.com/dlang/dmd/blob/b35572b07a6994385b6459a430674d32e9a97279/test/dub_package/frontend.d#L10-L24
[2]
https://github.com/jacob-carlbo
value <= 255) // assert that the value is
within bounds
{
hex = (hex & 0x00) | value;
}
string toString()
{
return format!"Color(red: %s, green: %s, blue: %s)"(red,
green, blue);
}
}
void main()
{
Color color;
color.red = 255;
color.green = 143;
color.blue = 89;
writeln(color);
}
--
/Jacob Carlborg
= 255;
assert(color.red == 255);
}
[1] https://en.wikipedia.org/wiki/Property_(programming)
--
/Jacob Carlborg
( )
{
}
// rest of class
}
It gets executed at compile time. All instances of `DebuggerSession`
will share the same single instance of `BreakState`.
--
/Jacob Carlborg
;
}
void printA(Foo foo)
{
writeln(foo.a);
}
foo.printA();
printA(foo);
The two above lines are exactly the same.
[1] https://dlang.org/spec/function.html#pseudo-member
--
/Jacob Carlborg
On 2020-11-08 13:39, Kagamin wrote:
Surrogate pairs are used in rules because java strings are utf-16
encoded, it doesn't make much sense for other encodings.
D supports the UTF-16 encoding as well. The compiler doesn't accept the
surrogate pairs even for UTF-16 strings.
--
/Jacob Carlborg
ing UTF-16, can encode these code points" [1].
"... the standard states that such arrangements should be treated
as encoding errors" [1].
Perhaps they need to be combined with other code points to form a
valid character.
[1] https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
--
/Jacob Carlborg
he memory just as the GC does for
efficiency, even if `free` is called. Otherwise it would be not
much point in using over the syscalls like `mmap` or `sbrk` (and
whatever the corresponding calls are on Windows).
--
/Jacob Carlborg
** passed, it will
produce one executable and one single object file.
--
/Jacob Carlborg
Are you looking for `TemplateArgsOf` [1] ?
[1] https://dlang.org/phobos/std_traits.html#TemplateArgsOf
--
/Jacob Carlborg
he [1]. Here's a Dub
package [2].
[1] http://mustache.github.io/mustache.5.html
[2] https://code.dlang.org/packages/mustache-d
--
/Jacob Carlborg
to wrap
each argument in Variant
The advantage of using the type safe variadic function is that
all the arguments are bundle into one array, make it easier to
work with.
--
/Jacob Carlborg
g.org/spec/function.html#d_style_variadic_functions
[2]
https://dlang.org/spec/function.html#typesafe_variadic_functions
--
/Jacob Carlborg
ocate GC memory I think.
If you pass the delegate as a template parameter/alias parameter,
it's more likely to be inlined:
auto myStuff(alias fn)() {
try return fn();
catch (Exception e) { }
}
myStuff!( { /* some code */ } );
--
/Jacob Carlborg
On Sunday, 25 October 2020 at 16:50:09 UTC, Jack wrote:
Which build tool are you refering to? an existing one or build
one oneself to do this job?
It should work with any build tool that has hooks to execute
arbitrary commands.
--
/Jacob Carlborg
hange the ABI for passing D arrays and this would break. If
fact, the ABI documentation [1] doesn't mention how a D array is passed.
A different compiler could choose to pass it differently.
[1] https://dlang.org/spec/abi.html#arrays
--
/Jacob Carlborg
s and read one of the smaller files with the import expression.
--
/Jacob Carlborg
eld.
[1] https://dlang.org/spec/abi.html#classes
[2] https://dlang.org/spec/class.html#synchronized-classes
[3] https://dlang.org/spec/statement.html#synchronized-statement
--
/Jacob Carlborg
On 2020-09-19 21:50, Per Nordlöw wrote:
On Saturday, 19 September 2020 at 18:48:31 UTC, Jacob Carlborg wrote:
A nested class seems to be able to escape the `this` reference:
Ahh, thanks.
I just realized that it can escape into other parameters without the
`scope` qualifier?
This
class
r
is just another argument passed to the function.
In the struct and class case?
A nested class seems to be able to escape the `this` reference:
class Foo
{
Bar b;
class Bar
{
void bar() pure
{
b = this;
}
}
}
--
/Jacob Carlborg
rm` packages. Then it provides a common
interface that is used by the rest of the project.
* Ocean [3]. This one is quite large as well.
[1] https://github.com/d-widget-toolkit/dwt
[2] https://github.com/weka-io/mecca
[3] https://github.com/sociomantic-tsunami/ocean
--
/Jacob Carlborg
terate all HTML files and output a simple index.html file.
[1]
https://github.com/rejectedsoftware/ddox#generating-offline-documentation
--
/Jacob Carlborg
unit tests
and Ddoc are the best things that have happened since sliced
bread. But if you compare with C or C++ the bar isn't very high.
--
/Jacob Carlborg
ank you in advance for your time!
You should compile both files. I'm guessing LDC might be doing some form
of optimization to figure out that it doesn't need those symbols.
PS: I hope this is the right sub-forum for asking this sort of question!
Yes.
--
/Jacob Carlborg
w return back to the
`main` function.
--
/Jacob Carlborg
generated documentation.
There's no built-in support for that. You might want to look at some
other doc generating tool if those support that.
--
/Jacob Carlborg
t; writeln(index, ":", value));
https://dlang.org/phobos/std_algorithm_iteration.html#.each
--
/Jacob Carlborg
On 2020-09-16 21:04, Vladimirs Nordholm wrote:
Ah, I guess it boils down to this then. Doesn't really make it "neater",
but thank you for the tip!
You only need to declare the enums ones.
--
/Jacob Carlborg
;
else
enum windows = false;
static if (!windows)
{
// ... my code
}
--
/Jacob Carlborg
ethod that allows to take full control of the
(de)serialization of a specific type.
Thirdly, you can do the same thing with pointer arithmetic. Although
this is not allowed if @safe code.
[1] https://github.com/jacob-carlborg/orange
--
/Jacob Carlborg
r serialization and, as you can see in your example, for
debugging as well. `writeln` will print the values of the fields in a
struct, even for private fields.
--
/Jacob Carlborg
ns [1]. Or if you have executables depending on only one
source file, you can use single-file packages [2].
Here are some real-world examples [3][4].
[1] https://dub.pm/package-format-sdl.html#configurations
[2] https://dub.pm/advanced_usage.html
[3] https://github.com/jacob-carlborg/dstep/blob/m
to override the
source directory. To override the output directory you can use
`targetPath` build setting. They are documented here [1][2].
[1] For the SDL format:
https://dub.pm/package-format-sdl.html#build-settings
[2] For the JSON format:
https://dub.pm/package-format-json.html#build-setti
On Friday, 28 August 2020 at 05:38:59 UTC, novice3 wrote:
DMD x86 on Windows have no dependencies, just unpack .zip and
use.
It's a pitty, that DMD x64 depend on VS :(
It does not. If VS is not installed the MinGW provided libraries,
which are bundled, will be used.
--
/Jacob Carlborg
o give the best of both worlds. Little binary bloat
and high performance.
--
/Jacob Carlborg
is also most likely the reason why Java generic types
don't accept primitive types. They need to be boxed, i.e. `int` need to
be wrapped in an object of type `Integer`.
--
/Jacob Carlborg
u can start with that at least.
--
/Jacob Carlborg
don't think the first thing to try is to replace the
Rust main function with a D main function.
--
/Jacob Carlborg
[2] https://dlang.org/phobos/core_runtime.html#.rt_term
--
/Jacob Carlborg
On 2020-07-14 23:58, Cecil Ward wrote:
What’s the best way to publish a D routine ?
As others have already said, on GitHub. Then as a Dub package as well [1].
[1] https://code.dlang.org
--
/Jacob Carlborg
for more information:
https://semver.org
--
/Jacob Carlborg
of Clang, I think zoujiaqing
is using a Mac. On Mac libc++ is used. That above might not apply.
--
/Jacob Carlborg
to select which C
compiler is used. Is there any equivalence for selecting the linker,
"LD" perhaps?
--
/Jacob Carlborg
On Thursday, 9 July 2020 at 06:57:22 UTC, Kagamin wrote:
If you suspect there's a contradiction in requirements, you
need to specify them with better precision.
What are the contradictions in the requirements? I don't see any.
--
/Jacob Carlborg
possible.
Does anyone have a system like this that is already available?
--
/Jacob Carlborg
.
--
/Jacob Carlborg
On Tuesday, 7 July 2020 at 12:41:23 UTC, Per Nordlöw wrote:
What about construction and assignment from a static array of
`Pair`'s? Wouldn't that be easier on the compiler?
I you refer to it wouldn't be using templates, then yes, I guess
so.
--
/Jacob Carlborg
ook pretty:
import std;
struct Pair
{
string key;
int value;
}
void main() @nogc
{
auto a = tuple(Pair("foo", 1), Pair("bar", 2));
}
--
/Jacob Carlborg
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote:
---
import std;
struct AA
{
void opIndexAssign(int v, string k) @nogc
{}
}
void main(string[] args) @nogc
{
AA myCustom;
enum literal = ["one":1, "two":2].stringof[1..$-1];
enum pairs = literal.split(',').array;
$-1];
enum pairs = literal.split(',').array;
---
That split won't work if you have something more complicated,
like struct values:
struct Foo
{
int a;
int b;
}
enum literal = ["one":Foo(1, 2), "two":Foo(3,
4)].stringof[1..$-1];
enum pairs = literal.split(',').array;
static assert(pairs == 4);
--
/Jacob Carlborg
re_runtime.html#.Runtime.traceHandler
--
/Jacob Carlborg
sure there are other differences in the ABIs.
--
/Jacob Carlborg
n (C) void foo_extern_c(int, int);
void main()
{
foo_extern_d(1, 2);
foo_extern_c(1, 2);
}
$ dmd main.d foo.o
$ ./main
a=2 b=1
a=1 b=2
This is on macOS.
--
/Jacob Carlborg
o, of course not. How would you otherwise call your `cfunc` function
from your original example ;)
--
/Jacob Carlborg
gt; bytes function too but I don't remember what
it is.
Regardless, the Windows functions may look familiar if you have done
AJAX - that was based on an IE object which was based on the Windows API.
Thanks, I'll take a look.
--
/Jacob Carlborg
issue assuming libcurl is built
with the platform provided TLS implementation. Just make sure it's
possible to statically link libcurl, without using `dlopen`.
--
/Jacob Carlborg
32/winhttp/about-winhttp
I'll take a look, thanks.
--
/Jacob Carlborg
ing on Windows either.
macOS is my main platform.
Bottom line - problem with SSL/TLS libraries lies in
incompatibility between platforms and even inside the single
library.
Yes. I'm trying to identify the best solution, which ideally
requires the least amount of work.
[1]
https://git
[5]
https://developer.apple.com/documentation/security/secure_transport
[6] https://developer.apple.com/documentation/network
[7]
https://developer.apple.com/documentation/foundation/nsurlsession
[8] https://code.dlang.org/packages/botan
--
/Jacob Carlborg
.)(Args args)
{
return printf(args);
}
}
void main()
{
printf("asd\n".ptr);
}
The `printf` function can be called from anywhere within the
module, but not outside the module.
--
/Jacob Carlborg
ting `extern(C)` functions in the D code, which
forwards to your D functions (or have the functions being
`extern(C)` to begin with). Then you need to have these
declarations available in a C header file, either created by
using the `-HC` flag or by manually writing the declarations.
--
/Jacob Carlborg
On Monday, 22 June 2020 at 19:41:22 UTC, Vlad wrote:
Is it even possible to compile D for iOS and use it the same
way as compiled C++ static library? (We do need a D runtime)
Yes, druntime/Phobos will need to be linked like any other static
library.
--
/Jacob Carlborg
ating null character
--
/Jacob Carlborg
environment variable named "DUB" available to
the build script. It should contain the path to the Dub executable. I
guess that somehow fails. Might be some unexpected character in the path?
--
/Jacob Carlborg
ot;);
override Foo init() @selector("init");
void print(int value) @selector("print:")
{
writeln(value);
}
}
extern (Objective-C) void print(Printer);
void main()
{
auto foo = Foo.alloc.init;
print(cast(Printer) cast(void*) foo); // need to cast through void*
}
--
/Jacob Carlborg
system about your symbols.
I think it's possible to implement the `RTInfo` template in `object.d`.
But that requires a custom druntime.
`RTInfo` is a template that is instantiated once for each type in the
program.
--
/Jacob Carlborg
/sync/future.d#L23
--
/Jacob Carlborg
On 2020-05-07 02:17, data pulverizer wrote:
What is the difference between -O2 and -O3 ldc2 compiler optimizations?
`--help` says -O2 is "Good optimizations" and -O3 "Aggressive
optimizations". Not very specific.
--
/Jacob Carlborg
On 2020-05-11 16:44, Russel Winder wrote:
Crickey, a third option. This wil increase my dithering! ;-)
Forth: Mecca [1] :)
[1] https://github.com/weka-io/mecca
--
/Jacob Carlborg
On 2020-05-06 12:23, data pulverizer wrote:
Yes, I'll do a blog or something on GitHub and link it.
It would be nice if you could get it published on the Dlang blog [1].
One usually get paid for that. Contact Mike Parker.
[1] https://blog.dlang.org
--
/Jacob Carlborg
std.traits : ReturnType;
alias R = ReturnType!(mixin(caller));
static assert(is(R == int));
}
int bar()
{
foo();
return 0;
}
--
/Jacob Carlborg
On 2020-05-06 06:04, Mathias LANG wrote:
In general, if you want to parallelize something, you should aim to have
as many threads as you have cores.
That should be _logical_ cores. If the CPU supports hyper threading it
can run two threads per core.
--
/Jacob Carlborg
On 2020-05-06 08:54, drug wrote:
Do you try `--fast-math` in ldc? Don't know if 05 use this flag
Try the following flags as well:
`-mcpu=native -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto`
--
/Jacob Carlborg
checks physical cores instead of
logical cores. That could be a reason, if you're running macOS.
--
/Jacob Carlborg
how to D as Better C could solve that.
I think it was the second talk in this list:
https://dconf.org/2017/schedule/
Any idea?
I have previously downloaded the DConf videos. I sent them to Mike for
him to upload.
--
/Jacob Carlborg
Standard Deviation: 24.5672
For: Mean time(usecs): 40.02, Standard Deviation: 7.67388
--
/Jacob Carlborg
ed-up C library through D, it will work fine.
So what am I doing wrong here? Thanks!
Classes in D are always passed by reference. Try dropping the pointer in
the `create` method:
static A create();
--
/Jacob Carlborg
1 - 100 of 1682 matches
Mail list logo