On Wednesday, 13 January 2021 at 17:21:23 UTC, Paul Backus wrote:
On Wednesday, 13 January 2021 at 17:14:04 UTC, Jack wrote:
but if I wrap this within a class:
class Foo
{
static int f(HWND hwnd, int n)
{
return n*10;
}
static void baa()
{
HWND foo;
On Thursday, 14 January 2021 at 00:29:23 UTC, Paul Backus wrote:
Easiest way is to use a lambda:
doSomething(() => foo(q))
This worked perfectly, thank you for your timely response~
On Wednesday, 13 January 2021 at 23:38:54 UTC, oddp wrote:
Just two langs I use from time to time:
1) nim via forced ctfe; way faster than d by running through a
vm:
const foo = fib(42)
static:
echo "foobar"
2) crystal via macros:
{{ puts "foobar" }}
Another one would be zig via comptime
On Thursday, 14 January 2021 at 00:15:12 UTC, Ola Fosheim Grøstad
wrote:
On Wednesday, 13 January 2021 at 21:56:58 UTC, mw wrote:
I think this flexibility to mix GC & manual memory management
is very unique in D. Actually I'm not sure if it can be done
in other languages at all.
It sure can.
On Thursday, 14 January 2021 at 00:19:24 UTC, Tim wrote:
I would like to be able to create a delegate but also supply
the function parameters to be used for the function call. How
can I go about doing this? Example:
void foo(int i){
}
void bar(string m){
}
doSomething(&foo(q));
doSomething(&
On Wednesday, 13 January 2021 at 21:56:58 UTC, mw wrote:
I think this flexibility to mix GC & manual memory management
is very unique in D. Actually I'm not sure if it can be done in
other languages at all.
It sure can. Most AOT languages that provide GC also provide
C-interfaces and manual m
I would like to be able to create a delegate but also supply the
function parameters to be used for the function call. How can I
go about doing this? Example:
void foo(int i){
}
void bar(string m){
}
doSomething(&foo(q));
doSomething(&bar("test");
On 13.01.21 21:47, tsbockman via Digitalmars-d-learn wrote:
Is CTFE I/O a standard feature in other languages? How many other languages even have a CTFE
feature comparable to D's?
Just two langs I use from time to time:
1) nim via forced ctfe; way faster than d by running through a vm:
const
On Wednesday, 13 January 2021 at 21:56:58 UTC, mw wrote:
I think this flexibility to mix GC & manual memory management
is very unique in D. Actually I'm not sure if it can be done in
other languages at all.
Yes, this is one of the great things about D.
There are miscellaneous problems with th
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote:
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about
GC?
I want to stress: in D you can *MIX* GC with manual memory
management, which gives you the best of bo
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote:
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about
GC?
tsbockman gave a good answer.
In short:
- You need to design the language for GC for it to be a
sat
On Wednesday, 13 January 2021 at 20:23:22 UTC, H. S. Teoh wrote:
Adam may be written a script for this, I'm not 100% sure.
Yeah, my code does it all, though the auto-generation is more
about accessing Java from D than vice versa, since implementing
the D parts are simple.
See the example
On Wednesday, 13 January 2021 at 11:50:26 UTC, Andrey wrote:
Today is 2021. Dlang still doesn't have ctfe write functions?
You make it sound like D is behind the times. Is CTFE I/O a
standard feature in other languages? How many other languages
even have a CTFE feature comparable to D's?
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote:
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about
GC?
SHORT VERSION: While garbage collection is great for many
applications, GC also has some significant
On Wed, Jan 13, 2021 at 07:51:08PM +, aberba via Digitalmars-d-learn wrote:
[...]
> So Adam's tool setup is pretty clear (talked to him). What remains is
> calling Java classes and interacting with the Android's API. I know a
> little bit of Java but not enough Android. Just the calling
> conve
On Wednesday, 13 January 2021 at 19:38:55 UTC, Paul Backus wrote:
That's what Variant is--a struct that models the universal
supertype (sometimes called "Top" or "Any").
Ahh right. Good point, so it already fits.
On Wed, Jan 13, 2021 at 06:58:56PM +, Marcone via Digitalmars-d-learn wrote:
> I've always heard programmers complain about Garbage Collector GC. But
> I never understood why they complain. What's bad about GC?
It's not merely a technical issue, but also a historical and
sociological one. The
On Wednesday, 13 January 2021 at 02:02:16 UTC, H. S. Teoh wrote:
On Sun, Jan 10, 2021 at 06:58:13PM +, aberba via
Digitalmars-d-learn wrote:
[...]
First, you need a way to build an APK, and then transfer that
to your Android device for testing. Building an APK *can* be
done manually (we
On Wednesday, 13 January 2021 at 18:09:08 UTC, sighoya wrote:
A more natural conclusion would be to infer c to the most
common supertype as other inferences would unnecessarily
exclude future assignments to c. But the most common supertype
doesn't seem to exist, and I'm unsure if this type can
On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote:
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about
GC?
I would guess because of performance issues.
I've always heard programmers complain about Garbage Collector
GC. But I never understood why they complain. What's bad about GC?
core.exception.InvalidMemoryOperationError@src\core\exception.d(647): Invalid
memory operation
reference D runtime unittest executor codes
try
{
fp();
++results.passed;
}
catch ( Throwable e )
{
import core.stdc.stdio;
On Wednesday, 13 January 2021 at 16:17:02 UTC, Marcone wrote:
import std;
void a(int b){
}
void main()
{
Variant c = 10;
a(c); // Error
}
Need more sugar.
Two problems:
1.) Variant is library defined, compared to the language level
there isn't a default strategy to choose int32 here, i
On 1/13/21 8:17 AM, Marcone wrote:
> import std;
>
> void a(int b){
> }
>
> void main()
> {
>Variant c = 10;
>a(c); // Error
> }
>
> Need more sugar.
That can't work in a strongly statically typed language. The call a(c)
is decided at compile time but Variant is not an int at compile ti
On Wednesday, 13 January 2021 at 17:14:04 UTC, Jack wrote:
but if I wrap this within a class:
class Foo
{
static int f(HWND hwnd, int n)
{
return n*10;
}
static void baa()
{
HWND foo;
writeln(foo.f(10));
}
}
I get the error:
Error: no property
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:
which seems perfectly adequate.
What about sets?
You can also search https://code.dlang.org
I use:
https://code.dlang.org/packages/emsi_containers
Which has hashset:
https://github.com/dlang-community/containers/blob/fc1625a5a
works fine (this is defined at global scope, g and baa are same
as static)
int f(HWND hwnd, int n)
{
return n*10;
}
void baa()
{
HWND foo;
writeln(foo.f(10));
}
but if I wrap this within a class:
class Foo
{
static int f(HWND hwnd, int n)
import std;
void a(int b){
}
void main()
{
Variant c = 10;
a(c); // Error
}
Need more sugar.
On Wednesday, 13 January 2021 at 15:11:40 UTC, Dennis wrote:
On Wednesday, 13 January 2021 at 14:04:52 UTC, dog2002 wrote:
[...]
I don't think this is part of the standard library.
Here's a piece of code I wrote a while ago if that's useful:
[...]
Thank you so much!
On Wed, Jan 13, 2021 at 4:10 PM Roguish via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> On Wednesday, 13 January 2021 at 14:17:51 UTC, Rikki Cattermole
> wrote:
> >
> > Same thing.
>
> Clear, thanks.
>
> I'm just discovering today that DMD and LDC are two different
> compiler
On Wednesday, 13 January 2021 at 14:27:48 UTC, user1234 wrote:
You really mostly only requires -g. Then you have to learn gdb.
A few basis to get started
I've used GDB before, but I've forgotten nearly all of it. Your
recap of the basics is appreciated. :-)
On Wednesday, 13 January 2021 at 14:04:52 UTC, dog2002 wrote:
I could use extern(c) and Process Walking (Process32First,
Process32Next), but maybe there is a way to get the list by
means of D?
I don't think this is part of the standard library.
Here's a piece of code I wrote a while ago if tha
On Wednesday, 13 January 2021 at 14:17:51 UTC, Rikki Cattermole
wrote:
Same thing.
Clear, thanks.
I'm just discovering today that DMD and LDC are two different
compilers. I got a different impression from the following
webpage, which claims that ldmd2 is a wrapper invoking ldc2.
https://s
On Wednesday, 13 January 2021 at 14:13:17 UTC, evilrat wrote:
if you are looking for back trace someone recently posted a
hint for linux where there is no back trace by default is to
import core.sys.linux.backtrace or something that has back
trace info and using it in exception handler for runt
On Wednesday, 13 January 2021 at 14:13:11 UTC, Adam D. Ruppe
wrote:
-debug enables the `debug` keyword inside the D code itself.
This lets you bypass other rules temporarily. For example
...
It does NOT do anything related to running D in debuggers like
gdb, it just enables code guarded by
On Wednesday, 13 January 2021 at 11:50:26 UTC, Andrey wrote:
Function "ctfeWriteln" doens't exist.
pragma(msg, ...) is used only for CT values.
Today is 2021. Dlang still doesn't have ctfe write functions?
Yes.(afaik)
It has shot me on the foot once, to the point i abandoned the
idea of eve
On Wednesday, 13 January 2021 at 14:13:07 UTC, drug wrote:
Short answer - sometimes the compiler does not emit a
stackframe (due to optimization for example).
OK, so -gs prevents a certain optimization that would make
debugging harder in certain situations. Thanks for clearing that
up.
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote:
On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote:
Anything else I need to know when debugging on Linux, without
an IDE?
One specific question I have is: what's the difference between
-g and -debug and -d-debug?
Also,
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote:
On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote:
Anything else I need to know when debugging on Linux, without
an IDE?
One specific question I have is: what's the difference between
-g and -debug and -d-debug?
From L
if you are looking for back trace someone recently posted a hint
for linux where there is no back trace by default is to import
core.sys.linux.backtrace or something that has back trace info
and using it in exception handler for runtime to print the stack
trace.
https://dlang.org/phobos/core_r
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote:
One specific question I have is: what's the difference between
-g and -debug and -d-debug?
-debug enables the `debug` keyword inside the D code itself. This
lets you bypass other rules temporarily. For example
void foo() pure {
On 1/13/21 4:47 PM, Roguish wrote:
Also, what does it mean to "always emit a stackframe" (compiler option
-gs) ?
Short answer - sometimes the compiler does not emit a stackframe (due to
optimization for example). In general if you are able to debug your
binary by gdb then you don't need to
On 1/13/21 4:47 PM, Roguish wrote:
On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote:
Anything else I need to know when debugging on Linux, without an IDE?
One specific question I have is: what's the difference between -g and
-debug and -d-debug?
Also, what does it mean to "alway
I need to get a list of processes in Windows (and their pid). I
could use extern(c) and Process Walking (Process32First,
Process32Next), but maybe there is a way to get the list by means
of D?
On Wednesday, 13 January 2021 at 13:30:48 UTC, Roguish wrote:
Anything else I need to know when debugging on Linux, without
an IDE?
One specific question I have is: what's the difference between -g
and -debug and -d-debug?
Also, what does it mean to "always emit a stackframe" (compiler
opti
On Wednesday, 13 January 2021 at 13:22:01 UTC, Roguish wrote:
How to debug D? be possible to get at least a stack trace?
I've discovered that GDB works with the binary generated by the D
compiler, so that's great.
Anything else I need to know when debugging on Linux, without an
IDE?
On Wednesday, 13 January 2021 at 12:39:50 UTC, evilrat wrote:
There is no specific set container, they just implemented as
generic algorithms over the ranges.
I see. Thanks for pointing that out.
How to debug D? My little trial app gives a segmentation fault.
Probably a null pointer somewhere, which I could find simply by
reading my code. But I'm puzzled that the program outputs very
little helpful info when it crashes, even though I've compiled
with all the debug options I could find i
On Wednesday, 13 January 2021 at 12:48:47 UTC, Ferhat Kurtulmuş
wrote:
I read many posts that rbtree can be a replacement for sets in
dlang.
see its behaviour is identical.
Thanks, will read up.
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:
On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
I can't find anything about collections in D. All I have found
are arrays and maps ("associative arrays"). What about lists
and sets? What if I just want a linked list?
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:
What about sets?
There is no specific set container, they just implemented as
generic algorithms over the ranges.
There is a section for set operations (std.algorithm.setops
module).
https://dlang.org/phobos/std_algorithm.html
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote:
I was looking for a way to avoid null checks everywhere. I was
checking the Null object pattern, or use something like enforce
pattern, or even if I could make a new operator and implement
something like C#'s .? operator, that Java was go
On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
I can't find anything about collections in D. All I have found
are arrays and maps ("associative arrays"). What about lists
and sets? What if I just want a linked list?
It seems collections are called "containers" in D's standard
l
On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
I can't find anything about collections in D. All I have found
are arrays and maps ("associative arrays"). What about lists
and sets? What if I just want a linked list?
You can refer to the docs for them:
https://dlang.org/phobos/s
I can't find anything about collections in D. All I have found
are arrays and maps ("associative arrays"). What about lists and
sets? What if I just want a linked list?
On Wednesday, 13 January 2021 at 11:31:16 UTC, Bastiaan Veelo
wrote:
On Wednesday, 13 January 2021 at 09:11:53 UTC, Guillaume Piolat
wrote:
On Wednesday, 13 January 2021 at 08:35:09 UTC, Andrey wrote:
Hello all,
Tell me please how can I "writeln" and "write" in function
that is used in CTFE?
On Wednesday, 13 January 2021 at 09:11:53 UTC, Guillaume Piolat
wrote:
On Wednesday, 13 January 2021 at 08:35:09 UTC, Andrey wrote:
Hello all,
Tell me please how can I "writeln" and "write" in function
that is used in CTFE?
At the moment I get this:
import\std\stdio.d(4952,5): Error: variable
On Wednesday, 13 January 2021 at 09:02:37 UTC, ddcovery wrote:
Find more details here:
https://run.dlang.io/gist/392c06e745d1a35df71084ce4d29fed7
Ups... it seems that the link is not working (it is the first
time I try to generate a dalng/gist link... I'm not sure if this
can really be done)
On Wednesday, 13 January 2021 at 08:35:09 UTC, Andrey wrote:
Hello all,
Tell me please how can I "writeln" and "write" in function that
is used in CTFE?
At the moment I get this:
import\std\stdio.d(4952,5): Error: variable impl cannot be
modified at compile time
Or may be exist some other wa
On Tuesday, 12 January 2021 at 21:37:11 UTC, Jack wrote:
I was looking for a way to avoid null checks everywhere. I was
checking the Null object pattern, or use something like enforce
pattern, or even if I could make a new operator and implement
something like C#'s .? operator, that Java was go
Hello all,
Tell me please how can I "writeln" and "write" in function that
is used in CTFE?
At the moment I get this:
import\std\stdio.d(4952,5): Error: variable impl cannot be
modified at compile time
Or may be exist some other ways to do it?
On 13/1/21 3:15, Tim wrote:
Fantastic response, thank you! I did some more digging and properly
narrowed down where the issue is and created a test script that
demonstrates the problem. Let me know what you think and if it could
still be a similar problem to what you have stated above. I'll s
62 matches
Mail list logo