On Tuesday, 28 January 2025 at 15:00:13 UTC, Jonathan M Davis
wrote:
[...]
-betterC was originally intended to be a tool for making it
easier to port C code to D code (after which, the idea was that
-betterC would no longer be used, and you would just have a
normal D program).
[...]
- Jo
Is there a definitive list somewhere of standard library
functions that work with -betterC?
For example, the following code fragment (taken from the library
docs) does not work with -betterC.
```
extern(C) void main() {
import std.container.array;
auto arr = Array!int(0, 2, 3);
}
```
On Monday, 20 January 2025 at 19:54:19 UTC, Jonathan M Davis
wrote:
[...]
Also, there's really no reason to be doing anything with char[]
instead of string unless you're specifically planning on
mutating the elements in your string, and casting from a string
literal to a char[] is almost never
On Sunday, 26 January 2025 at 16:43:23 UTC, Bradley Chatha wrote:
On Sunday, 26 January 2025 at 15:42:44 UTC, DLearner wrote:
But how to get that value into Count?
It's hard to say what would exactly fit your use case since
this is just a minimal example, so it's hard to gauge what
other res
Suppose we have
```
enum Count = 0;
static if ()
...
enum Count = Count + 1; // is disallowed
else
static if ()
...
enum Count = Count + 1; // is disallowed
else
```
and the objective is to determine (at compile time) the number of
times cond-1 or cond-2 is triggered (perhaps for
DMD 2.109.1 -betterC under Windows 10
The code below executes correctly:
```
extern (C) void main() {
import core.stdc.stdio : printf;
size_t wkIdx;
size_t wkPos;
enum Count = 1;
struct OpVar {
void* Addr;
intType;
}
OpVar[Count] OpVars;
int IntVar
On Tuesday, 21 January 2025 at 05:54:48 UTC, evilrat wrote:
On Monday, 20 January 2025 at 22:32:02 UTC, DLearner wrote:
It was because my understanding was that in certain situations
the string construct did not just produce a character array -
it also produced the (to me horrible) concept of a
On Monday, 20 January 2025 at 19:54:19 UTC, Jonathan M Davis
wrote:
On Monday, January 20, 2025 12:03:09 PM MST DLearner via
Digitalmars-d-learn wrote:
// In the code below, what fn needs to go in the commented-out
line,
// to make the program print 7, 11 rather than 7, 7?
```
void main
// In the code below, what fn needs to go in the commented-out
line,
// to make the program print 7, 11 rather than 7, 7?
```
void main() {
import std.stdio;
int IntVar1 = 5;
int IntVar2 = 7;
int IntVar3 = 11;
int* wkVarAddr;
char[] wkVarName;
wkVarAddr = &IntVar2;
On Wednesday, 18 December 2024 at 07:43:01 UTC, Jonathan M Davis
wrote:
[...]
- Jonathan M Davis
Thinking about this a little more:
Suggestion:
Leave the current behaviour as default, but introduce an option
(-r ?) so that
```
unittest -r {
}
```
forces a complete rebuild
(for clarity, i
On Tuesday, 17 December 2024 at 19:56:32 UTC, H. S. Teoh wrote:
[...]
That means the compiler will have to rerun your program once
per unittest. That means your OS has to create a new process
per unittest. If you have a lot of unittests, that adds a huge
amount of overhead.
Agreed, but onl
On Sunday, 15 December 2024 at 20:30:21 UTC, monkyyy wrote:
On Sunday, 15 December 2024 at 08:45:22 UTC, DLearner wrote:
I appreciate this behaviour matches the docs (so not a bug),
but is it desirable?
yes, the alternative would be that unittests attempt to undo
themselves, and that would
On Sunday, 3 November 2024 at 19:47:31 UTC, monkyyy wrote:
[...]
Id expect this to fail, but nothing I see in yours
```d
string foo="foo";
foo~="bar";
```
[]'s are both slices and dynamic arrays depending on use,
theres a debate about that decision(im of the opinion a `[?]`
should be a dynam
The two fragments below compiled and ran as expected using dmd
-betterC under Windows.
```
string Scrn = "OPO NAM='DspVar1' POS='1,1'
VAR=('IntVar1','I');E";
printf("\nWR_Createtest entered.\n");
OpStructFstPtr = WR_CreateFormatFile(Scrn);
```
```
OpStruct* WR_CreateFormatFile(s
On Wednesday, 30 October 2024 at 09:21:55 UTC, ryuukk_ wrote:
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:
On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer
wrote:
On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:
Just trying ImportC under Windows 10:
```c
#in
On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:
On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:
Just trying ImportC under Windows 10:
```c
#include
int main()
{
printf("Hello world.\n");
return 0;
}
```
Produces
```
dmd hello.c
failed launching cl.exe /P /Zc
On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote:
On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote:
On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier
wrote:
On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:
However, there is still a problem:
```
dmd
On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier
wrote:
On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:
However, there is still a problem:
```
dmd hello.c
C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error
C1034: sal.h: no include path set
Er
On Tuesday, 29 October 2024 at 00:10:17 UTC, Richard (Rikki)
Andrew Cattermole wrote:
https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332
cl.exe comes from Visual Studio (MSVC).
If you haven't got it installed, that'll be why.
Otherwise its
Just trying ImportC under Windows 10:
```
#include
int main()
{
printf("Hello world.\n");
return 0;
}
```
Produces
```
dmd hello.c
failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c
/FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h
/Fihello.i
Error: C preproces
On Friday, 29 December 2023 at 21:25:44 UTC, user1234 wrote:
[...]
Thanks, and the ideas are useful,
but please see below, suppose:
```
void main() {
size_t var1 = 1;
size_t var2 = 3;
size_t var3 = 5;
// ... Many other variables defined.
char[4] VarName;
// ...
// And some compl
Compile-time:
Is there a 'foo1' that yields 1 from the snippet below?
```
void main() {
import std.stdio;
size_t var1 = 1;
char[4] Txt = cast(char[4])("var1");
writeln(foo1(Txt));
}
```
Similarly, execution-time, is there a foo2 that wields 2 from the
snippet below:
```
void mai
On Thursday, 21 December 2023 at 10:38:16 UTC, DLearner wrote:
[...]
And now, returning to the problem after several hours Christmas
shopping, everything seems to work perfectly!
This applies to dmd version v2.106.0-dirty under Windows.
Module containing several functions with unittests, no 'main'
function.
Was testing ok some time ago, producing '1/1 modules PASSED
unittests' message.
Today,
```
dmd -main -unittest -run
```
produced nothing, just a return to the com
The code below fails to compile with
Error: function `test1.foo` no `return exp;` or `assert(0);` at
end of function
unless the commented-out assert(0) is included.
Please, what rule of D is being broken?
foo does not unconditionally loop, and the only places where foo
returns, it returns wit
On Sunday, 26 November 2023 at 15:35:39 UTC, Adam D Ruppe wrote:
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
string mxnTest(string strVar1, string strVar2) {
return `(int Var1, int Var2) {
if (Var1 > Var2) {
return true;
} else {
return false;
The two little demo scripts:
```
string mxnAdd()(string strName) {
return `(typeof(` ~ strName ~ `) Pld) {
import core.stdc.stdlib : malloc;
struct Mst {
typeof(` ~ strName ~ `) Pld;
int I1;
}
Mst*MstPtr;
MstPtr = cast(Mst*)(malloc(Mst.s
On Tuesday, 5 December 2023 at 00:31:35 UTC, H. S. Teoh wrote:
On Mon, Dec 04, 2023 at 11:46:45PM +, DLearner via
Digitalmars-d-learn wrote: [...]
Basically, B corresponds to the whole record (and only a whole
record
can be read).
But the task only requires Var1 and Var2, the last two
On Monday, 4 December 2023 at 23:16:27 UTC, thinkunix wrote:
DLearner via Digitalmars-d-learn wrote:
On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote:
[...]
Is something like this what you had in mind?
```
void main() {
import std.stdio;
mixin template A() {
int I1
On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote:
[...]
Is something like this what you had in mind?
```
void main() {
import std.stdio;
mixin template A() {
int I1;
int I2;
char X;
}
struct B {
mixin A;
int Var1;
int Var2;
}
Suppose we need a construct like:
```
void main() {
struct A {
int I1;
int I2;
char X;
}
struct B {
A Dummy;
int Var1;
int Var2;
}
}
```
But do not want to give an explicit name (like 'Dummy' above) to
the A struct held within the B struct.
Just
The code:
```
void main() {
struct SB {
char SBChrFld1;
char SBChrFld2;
int SBIntFld1;
int SBIntFld2;
}
SB SBVar;
SB* wkSBPtr;
void* StartPtr1 = null;
mixin(mxnDelMbr("StartPtr1", "wkSBPtr"));
return;
}
string mxnDelMbr()(string strStartPt
On Tuesday, 28 November 2023 at 18:43:37 UTC, Adam D Ruppe wrote:
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote:
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A,
from A_Ptr of type A*.
I think what you really want is
typeof(*A_Pt
Trying to manipulate 'typeof' return strings, preferably at
compile-time.
e.g. to produce struct B below (intended to have an A
sub-struct), from A_Ptr alone.
```
struct A {
int AFld1;
}
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from
A_
On Thursday, 23 November 2023 at 17:02:58 UTC, Paul Backus wrote:
[...]
This is a known limitation:
https://issues.dlang.org/show_bug.cgi?id=23637
[...]
Sorry to come back to this, but the reference above suggests
_not_ a bug in the compiler.
If not a bug in the compiler, please, what is g
On Thursday, 23 November 2023 at 18:54:09 UTC, Julian Fondren
wrote:
[...]
The `enum` answer?
[...]
No, the 'template' answer.
To me, if the 'template' suggestion worked (as it did), then my
simple mixin (as in my original post) should also work.
On Thursday, 23 November 2023 at 17:03:29 UTC, Julian Fondren
wrote:
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
Why is this so, bearing in mind the concatenations are
executed at
compile, not run, time?
If you compile without -betterC, it'll work, but if you examine
the r
Code below is intended to test simple mixin with lambda function
under -betterC.
Works with full-D, but fails with 'needs GC' errors under
-betterC.
Why is this so, bearing in mind the concatenations are executed at
compile, not run, time?
```
// Test harness
extern(C) void main() {
i
On Wednesday, 22 November 2023 at 16:51:54 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 23/11/2023 5:34 AM, DLearner wrote:
Is the encapsulation issue resolved if the struct itself is
held in another module, and imported from that module into
both the 'main' and 'Ex_mod' files?
Each modul
On Wednesday, 22 November 2023 at 16:11:03 UTC, Richard (Rikki)
Andrew Cattermole wrote:
You have two ``SA`` structs, each in different encapsulations.
Each of them are different, even if they have similar members.
In D types that look the same do not combine, they are distinct.
You can see th
Please,
Why does:
```
// Test module Ex_mod
struct SA {
int SAIntFld1;
int SAIntFld2;
}
bool AddEle(ref void* StartPtr, SA PayLoad1) {
import core.stdc.stdlib : malloc;
struct Ele {
SA PayLoad;
Ele* EleNxtPtr;
Ele* ElePrvPtr;
}
Ele*ElePtr;
Ele*
On Friday, 23 June 2023 at 16:51:16 UTC, Ali Çehreli wrote:
On 6/23/23 07:22, DLearner wrote:
>`} else static if (__traits(isPOD, typeof(` ~ VarName
~ `))) {` ~
Regardless, you can also use the 'is' expression with the
'struct' keyword. If T is a struct,
is (T == struct)
that will
On Friday, 23 June 2023 at 15:48:44 UTC, H. S. Teoh wrote:
On Friday, 23 June 2023 at 15:22:36 UTC, DLearner wrote:
On Friday, 23 June 2023 at 14:31:45 UTC, FeepingCreature wrote:
On Friday, 23 June 2023 at 14:22:24 UTC, DLearner wrote:
[...]
```
static assert(__traits(isPOD, int)); // ok.
s
On Friday, 23 June 2023 at 14:31:45 UTC, FeepingCreature wrote:
On Friday, 23 June 2023 at 14:22:24 UTC, DLearner wrote:
[...]
```
static assert(__traits(isPOD, int)); // ok.
static assert(__traits(isPOD, byte)); // ok.
```
It's a bug in either the spec or the compiler.
I am using
```
DMD64
Hi
Was looking for compile-time detection of a struct variable.
However, the following test code gave the two 'FAILS' shown below.
Comments?
```
void main() {
import std.stdio : writeln;
import std.traits;
string mxnTst(string VarName) {
return
`static if (is(typeof(` ~ Var
On Sunday, 11 June 2023 at 21:32:11 UTC, Andy wrote:
[...]
void main() {
import std.stdio;
struct foo {}
foo* fooptr;
static if (is(typeof(fooptr) == T*, T))
writeln("fooptr is a pointer to a ", T.stringof);
else
writeln(
Only a small thing, but is it intended that:
```
void main() {
// static assert (false, "Static Assert triggered");
assert(false, "Assert triggered");
}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert triggered
```
but removing the // produces
```
staticassertex01.d(
Please consider:
```
void main() {
import std.stdio;
struct foo {
int foo1;
char foo2;
}
foo* fooptr;
void* genptr;
static if (is(typeof(fooptr) == void*))
writeln("fooptr is void*");
else
writeln("fooptr is not void*");
On Monday, 5 June 2023 at 18:22:45 UTC, Ernesto Castellotti wrote:
[...]
It's not so easy to deal automatically in case of multiple
modules
_multiple modules_
The following code, in a batch (.bat) file, works for me:
```
@echo off
:loop
if [%1]==[] goto loopexit
type .\%1.d > .\__temp_%1.d
ech
On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote:
[...]
The docs say it should work:
https://dlang.org/spec/betterc.html#unittests
[...]
Thank you for the link, can confirm that:
```
int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(fo
On Monday, 5 June 2023 at 03:42:20 UTC, ryuukk_ wrote:
[...]
I don't know how all this works, ...
For what it is worth, running _both_ the above code fragments
with:
```
dmd -main -unittest -i -run foo
```
(ie removing the -betterC flag)
produces:
```
foo.d(8): [unittest] != Assert triggere
Neither:
```
extern(C) int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(foo() == 4, "== Assert triggered.");
}
```
Nor:
```
int foo() {
return 4;
}
unittest {
assert(foo() != 4, "!= Assert triggered.");
assert(foo() == 4, "== Assert tr
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
void main() {
import std.stdio : writeln;
S1 Var1 = S1(1, 2);
writeln("Total Var1 = ", Var1.foo());
S2 Var2 = S2(1,
On Wednesday, 19 April 2023 at 14:42:44 UTC, bachmeier wrote:
[...]
My understanding (from my occasional use of Windows) is that
DMD installs the Community Edition of Visual Studio. That
should solve your original issue, and you shouldn't need to
mess with sppn.exe.
Well it took a little whil
On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 20/04/2023 12:07 AM, DLearner wrote:
Error: C preprocess command sppn.exe failed for file ex01.c,
exit status 1
Did you verify that sppn is accessible in that shell?
As in run it, can it be found?
If not
On Wednesday, 19 April 2023 at 11:50:28 UTC, bachmeier wrote:
[...]
Did you use the switch `-m32omf`?
https://dlang.org/spec/importc.html#auto-cpp
No so following the references I tried every preprocessor option
I could find:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -m32omf
f
C source ex01.c:
```
#include
int main()
{
printf("hello world\n");
return 0;
}
```
'dmc ex01.c' produces message:
```
link ex01,,,user32+kernel32/noi;
```
but does generate .obj, .map and .exe files,
and the exe executes properly.
However, trying to use ImportC via 'dmd ex01.c' produces
On Tuesday, 18 April 2023 at 21:31:21 UTC, thinkunix wrote:
[...]
If not calling C code, why use extern(C) for D code?
Wanted to test out options of calling D routine (possibly
-betterC) from both C and (full) D.
On Tuesday, 18 April 2023 at 20:00:18 UTC, ag0aep6g wrote:
On Tuesday, 18 April 2023 at 19:49:04 UTC, DLearner wrote:
```
void main() {
import std.stdio;
extern(C) void ExtCallee();
```
Move that declaration out of main.
Thanks - worked!
Is the declaration inside main not visible to t
Wanted to try out linking two source files independantly compiled.
ExtCallee.d source file:
```
extern(C) void ExtCallee() {
import std.stdio;
writeln("Entered: ", __FUNCTION__);
writeln("Exiting: ", __FUNCTION__);
}
```
ExtMain.d source file:
```
void main() {
import std.stdio;
e
Requirement is to write some D code (which avoids the GC), that
will be called from C.
So simple approach seemed to be to write D code under -betterC
restrictions.
However, also need variable length arrays - but D Dynamic Arrays
not allowed under -betterC.
So tried trivial example using std.c
Is it correct that this _single_ keyword is used to indicate
_two_ quite different things:
1. As a shorthand to make the type of the variable being declared
the same as the type on the right hand side of an initial
assignment.
Example: ```auto A = 5;``` makes A an int.
2. To indicate storag
Hi
Please consider (1):
```
void main() {
import std.stdio;
int wk_Idx;
int[2] IntArr;
IntArr[0] = 1;
IntArr[1] = 2;
for (wk_Idx = 0; wk_Idx <= 1; wk_Idx = wk_Idx + 1) {
writeln("wk_Idx = ", wk_Idx, " IntArr = ", IntArr[wk_Idx]);
}
}
```
Now consider (2), which is
On Wednesday, 18 January 2023 at 14:18:58 UTC, Salih Dincer wrote:
On Wednesday, 18 January 2023 at 13:45:04 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC
feature. cl.exe seems to be the compiler
On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC feature.
cl.exe seems to be the compiler. I think it is the compiler.
Can you run that program from the command line?
Fails with:
```
C:\Users\SoftDev>c1.exe
'c1.exe'
On Tuesday, 17 January 2023 at 19:17:31 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:
On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
[...]
Downloaded latest dmd for windows from web
On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:
On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 11:21:08 UTC, Denni
On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:
On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:
On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:
On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd e
On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:
On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not
supported
ex01.c(1): Error: no type for declarator befor
This relates to the first example under 41.1 Quick Examples.
Stored as ex01.c, run as shown.
```
#include
int main()
{
printf("hello world\n");
return 0;
}
```
Produced:
```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is no
If unittest run without a main() being present, crashes on link
error:
```
lld-link: error: subsystem must be defined
Error: linker exited with status 1
```
Is this intended?
It's not a problem to add temporary
```
void main() {
}
```
to the bottom of the module, but seems wrong as not then te
On Sunday, 8 January 2023 at 23:59:21 UTC, ryuukk_ wrote:
[...]
Example_03:
```
void main() {
import core.stdc.stdio : printf;
int[] A;
printf("Hello betterC\n");
}
```
```
dmd -betterC -run Example_03
```
Expected result: Failure at compilation stage, owing to
presence of dynamic arr
I thought dynamic arrays were unavailable under -betterC.
Example_02:
```
extern(C) void main() {
import core.stdc.stdio : printf;
int[] A;
printf("Hello betterC\n");
}
```
```
dmd -betterC -run Example_02
```
Expected result: Failure at compilation stage, owing to presence
of dynamic
On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote:
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via
Digitalmars-d-learn wrote:
Suppose there is a D main program (not marked anywhere with
@nogc),
that _both_
A: Calls one or more C functions that themselves call
malloc/free
Suppose there is a D main program (not marked anywhere with
@nogc), that _both_
A: Calls one or more C functions that themselves call
malloc/free; and also
B: Calls one or more D functions that themselves call malloc/free
via `import core.stdc.stdlib;`
Assuming the malloc/free's are used cor
On Wednesday, 30 November 2022 at 02:29:03 UTC, Paul Backus wrote:
[...]
If you want a dynamic array with value semantics, you should
use a library-defined container type (e.g., `struct
DynamicArray`).
I agree should not change existing meaning of
```
int[] A;
```
But why not allow a const
On Tuesday, 29 November 2022 at 19:06:20 UTC, rikki cattermole
wrote:
[...]
Please see the following example:
```
void main() {
import std.stdio;
int[] VarArr1, VarArr2;
VarArr1.length = 6;
VarArr1[5] = 10;
VarArr1[4] = 9;
VarArr1[3] = 8;
VarArr1[2] = 7;
VarArr1[1] = 6
To me, it appears that there are really two (_entirely separate_)
concepts:
A. Supporting the useful concept of variable length (but
otherwise entirely conventional) arrays;
B. Supporting a language feature that acts as a window to an
array, through which that array can be manipulated.
And c
On Sunday, 13 November 2022 at 16:11:17 UTC, matheus. wrote:
[...]
You should add the code below after "auto B = A.dup;":
B[0].Txt = A[0].Txt.dup;
The "Txt" property inside B is still referencing A without the
above.
Matheus.
Thank you - your suggestion worked.
The slight generalisati
On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka
wrote:
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote:
Creating a step 1.5:
```
int[] B = A;
```
```D
auto B = A.dup;
```
This will create a copy of A rather than referencing to the
same buffer in memory.
Tested:
Hi
Program has two steps:
1. Creates an array (int[] A), whose size and element values are
only known at run-time.
Then:
2. The elements (but not the array size) are further processed in
a way that may or may not alter their value.
Requirement: to identify the indices (if any) of the elemen
On Friday, 28 October 2022 at 21:32:46 UTC, rikki cattermole
wrote:
On 29/10/2022 4:15 AM, DLearner wrote:
However, going forward, I don't want copies of OM anywhere
other than UD.
If you want your own private library on your system (that will
get used a lot), you can create a package and use
On Friday, 28 October 2022 at 11:35:44 UTC, Adam D Ruppe wrote:
On Wednesday, 26 October 2022 at 16:20:01 UTC, DLearner wrote:
Wanted to use a function stored in a module outside the main
source.
easiest thing to do with dub is to add it as a sourcePath or a
sourceFile. Well, actually, easies
On Thursday, 27 October 2022 at 00:35:26 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 22:51:53 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
[...]
The linker failed to resolve because
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh
wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
[...]
Maybe try
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
Hi
Never used DUB before.
Wanted to use a function stored in a module outside the main
source.
Main source has `import ;`
Put a line into the
On Saturday, 16 October 2021 at 19:29:59 UTC, Dennis wrote:
On Saturday, 16 October 2021 at 19:28:04 UTC, DLearner wrote:
How does one obtain from strVar:
1. The type of fooVar;
`typeof(mixin(strVar))`
2. The value of fooVar?
`mixin(strVar)`
```
void main() {
import std.stdio;
int
Hi
Suppose string variable strVar has value "fooVar".
fooVar is a valid variable name used elsewhere in the program.
How does one obtain from strVar:
1. The type of fooVar;
2. The value of fooVar?
Best regards
Thanks for the responses.
Please confirm that if the addition of two uint variables
produces a result larger than can be held in a uint:
1. This is a D-legal operation (however inadvisable!), with the
D-defined result of wraparound;
2. Emphasing 1. above: the result is not undefined, or an error
(by the rules of D), or
On Thursday, 2 September 2021 at 23:12:28 UTC, Steven
Schveighoffer wrote:
[...]
immutable means "I can never change and *everything I point at*
can never change".
[...]
If that is how the language defines the keyword 'immutable' when
used in the definition of a pointer variable, then so be
On Thursday, 2 September 2021 at 16:46:46 UTC, Steven
Schveighoffer wrote:
On 9/2/21 12:01 PM, DLearner wrote:
Suppose there is a variable that is set once per run, and is
(supposed) never to be altered again. However, the value to
which it is set is not known at compile time.
Example below,
Suppose there is a variable that is set once per run, and is
(supposed) never to be altered again. However, the value to
which it is set is not known at compile time.
Example below, variable is 'ArrPtr';
```
ubyte[10] Arr;
// immutable void* ArrPtr;
void* ArrPtr;
void main() {
ArrPtr = ca
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote:
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
Please confirm that mixins of format:
You really shouldn't use string mixins like this at all. If you
want to work with a variable, pass the variable itself as an
arg
On Thursday, 26 August 2021 at 16:28:22 UTC, Adam D Ruppe wrote:
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
Please confirm that mixins of format:
You really shouldn't use string mixins like this at all. If you
want to work with a variable, pass the variable itself as an
arg
Please confirm that mixins of format:
```
string mxn1(string VarName) {
...
}
```
Invoked like:
```
mixin(mxn1("Var1"));
```
Have a wider scope than mixins like:
```
string mxn2(string VarName)() {
...
}
```
Invoked like:
```
mixin(mxn2!"Var2");
```
I tried direct replacement of former by
On Wednesday, 25 August 2021 at 22:57:23 UTC, jfondren wrote:
Contrast:
[...]
```d
void main() {
import std.stdio;
uint TestVar = 5;
string mxnWrite_Size_t(string VarName)() {
static if (typeof(mixin(VarName)).stringof == "uint") {
return `write("` ~ VarName ~ `");
On Wednesday, 25 August 2021 at 22:33:00 UTC, H. S. Teoh wrote:
[...}
I think what you meant to write is:
static if (typeof(mixin(VarName)).stringof == "uint") {
You want the type of the variable named by VarName, not the
type of VarName.
T
I understand your reasoning, but:
```
v
Please see below:
```
void main() {
import std.stdio;
uint TestVar = 5;
string mxnWrite_Size_t(string VarName) {
static if (typeof(VarName).stringof == "uint") {
return `write("` ~ VarName ~ `");`;
} else {
return `writeln("Apparently TestVar not a uint"
Hi
The code below compiles and runs producing 'Not null'.
```
void main()
{
import std.stdio;
int Var1;
int* ptrVar;
ptrVar = &Var1;
if (ptrVar == null) {
writeln("Null");
} else {
writeln("Not null");
}
}
```
However, should it not fail to compile, as '=
1 - 100 of 157 matches
Mail list logo