Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread John Chapman via Digitalmars-d-learn

On Sunday, 2 June 2024 at 21:46:41 UTC, solidstate1991 wrote:
Well, it turns out I used the windres found in mingw instead of 
`rc.exe` since the latter cannot be found anywhere on my PC, 
even after reinstalling stuff. I need to hunt it down somehow.


rc.exe comes with the Windows SDK - it gets installed in one of 
the subfolders of "C:\Program Files (x86)\Windows Kits\10\bin" 
(on my machine it's in "10.0.22000.0\x64").


Re: How does one attach a manifest file to a D executable on Windows?

2024-05-25 Thread John Chapman via Digitalmars-d-learn

On Saturday, 25 May 2024 at 13:13:08 UTC, solidstate1991 wrote:

No, I meant something like this:

https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview


Not tested but from memory I do this:

1) Copy that first XML snippet from the page you linked, save to 
a file called example.exe.manifest
2) Create a resource script file called resources.rc, with this 
at the top:

   1 24 "example.exe.manifest"
3) Compile it with rc.exe
4) Include the resulting resources.res on your DMD command line

You might also need to call InitCommonControls or 
InitCommonControlsEx before creating any windows.


Re: How can I tell D that function args are @nogc etc.

2024-04-12 Thread John Dougan via Digitalmars-d-learn
On Friday, 12 April 2024 at 15:08:50 UTC, Steven Schveighoffer 
wrote:

On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote:

What is the procedure for bug reporting? I'm looking at the 
issues tracker and have no clue how to drive the search to see 
if this is already there.




https://issues.dlang.org

While entering the bug title, it does a fuzzy search for 
existing open and closed issues.


The typical problem with issue/bug database searches is you have 
to know the important discriminating keywords that projects 
evolve over time. When you are new to a system, as I am with D, 
you end up looking manually through a lot of possibles. Another 
barrier to noobs that project long timers may not notice.


Any rate,  it appears 
https://issues.dlang.org/show_bug.cgi?id=22046 is the same issue.


And I'm not sure how to interpret it, as a noob I don't have 
enough context. It appears to be deliberate and also afflicts var 
declarations. Since 2014.


From my point of view, either it's still a bug and needs to be 
written up in a best practices list with all the other long term 
stuff you need to work around until it can be fixed (eg. "in 
alias and var function declarations, put attributes as a suffix 
because...", https://dlang.org/dstyle.html *might* be a place), 
or it has aged in to become the effective intended behavior and 
should be documented other places and have a compiler error or 
warning ("@safe in prefix position in alias, is ignored"). Or of 
course, it could get fixed but my experiences have shown me that 
after 10 years that is low probability with most projects.


I'm not trying to be a dick here. I've managed projects and know 
what unintentional dumb stuff can happen. But, at the moment, I'm 
evaluating D for a project (porting 30,000 lines of very old C 
with strict timing requirements) and I've got some time to build 
impressions of system language candidates. There appears to be a 
lot of talk from time to time over in General about luring new 
people in to work with D, and this kind of issue is relevant.



-Steve


  --john



Re: How can I tell D that function args are @nogc etc.

2024-04-11 Thread John Dougan via Digitalmars-d-learn
On Thursday, 11 April 2024 at 15:00:49 UTC, Steven Schveighoffer 
wrote:


So D can provide a nice mechanism to show what is happening -- 
`pragma(msg, ...)`


If I do that with the two types above I see something *very* 
interesting:


```d
pragma(msg, FnPrefixT);
pragma(msg, FnSuffixT);
```

```
bool function(int) nothrow @nogc
bool function(int) nothrow @nogc @safe
```

That surprises me. `nothrow` and `@nogc` go onto the type, but 
not `@safe` if put before the declaration? I have no idea why. 
All I can think of is that it is a bug.




`pragma(msg,...)` is very useful. Thanks.

My general impressions were correct then. It shouldn't matter on 
which side the attrs get put, except in some ambiguous cases. 
It's just broken. Not every day you get to blame a compiler bug.


Feeding:
```d
alias FnPrefixT = @safe nothrow @nogc bool function(int);
alias FnSuffixT = bool function(int) @safe nothrow @nogc ;

pragma(msg, FnPrefixT);
pragma(msg, FnSuffixT);

void main() { return; }
```

into run.dlang and having it compile with all the 
compilers...gets the same result all the way back to 2.060. It 
has this issue with gdc 2.076, which is what I'm using normally.


What is the procedure for bug reporting? I'm looking at the 
issues tracker and have no clue how to drive the search to see if 
this is already there.




-Steve


-- john



Re: How can I tell D that function args are @nogc etc.

2024-04-10 Thread John Dougan via Digitalmars-d-learn

Interesting. Thank you to both of you.

On Wednesday, 10 April 2024 at 17:38:21 UTC, Steven Schveighoffer 
wrote:
On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
Place your attributes on the right hand side of the function, 
not the left side.


Use the left side for attributes/type qualifiers that go on 
the return type.


Just a word of warning, this explanation suggests putting 
qualifiers on the left side would affect the return type, this 
is not the case.


So in my example, what did I actually tell the compiler with the 
placement of the attributes? And how was it different between the 
function type alias declaration, and the actual function 
declaration?


More specifically, what are the semantic differences below?
```d
alias FnPrefixT = @nogc nothrow @safe bool function(int);
// Versus
alias FnSuffixT = bool function(int) @nogc nothrow @safe;
```
and
```d
@nogc nothrow @safe bool fnPrefix(int) { stuff }
// Versus
bool fnSuffix(int) @nogc nothrow @safe  { stuff }
```
Is there a reasonably clear overview of how this works anywhere? 
What I have seen so far led me to the vague impression that it 
wasn't significant just like attribute ordering.


-- john





How can I tell D that function args are @nogc etc.

2024-04-09 Thread John Dougan via Digitalmars-d-learn

Below is a example program that illustrates my issue.

When compiled at run.dlang I get:
```
onlineapp.d(18): Error: `@safe` function 
`onlineapp.processSafely!(1, 4).processSafely` cannot call 
`@system` function pointer `shouldDo`
onlineapp.d(28): Error: template instance 
`onlineapp.processSafely!(1, 4)` error instantiating

```

Why isn't this working? How can I get the effect I want?

Cheers,
-- john

```
bool[7] stagesToProcess = false;

@nogc nothrow @safe bool shouldDoInStages(int index)
{
return stagesToProcess[index];
}

@nogc nothrow @safe bool shouldDoNever(int index)
{
return false;
}

template processSafely(int low, int high)
{
alias ShouldDoFnT = @nogc nothrow @safe bool function(int);

@nogc nothrow @safe uint processSafely(ShouldDoFnT shouldDo)
{
assert(low < high);
uint stepsProcessed;
for (int ii = low; ii <= high; ii++)
{
if (shouldDo(ii))
{
stepsProcessed++;
}
}
return stepsProcessed;
}
}

void main()
{
stagesToProcess = [false, false, true, true, false, true, 
false];

uint count = processSafely!(1, 4)();
assert(count == 2);
}
```



Re: Disable wrilten buf in docker

2024-03-12 Thread john rath via Digitalmars-d-learn
I'm glad you find it helpful! If you have any more questions, 
whether it's about fashion or anything else, feel free to ask. 
I'm here to assist you with any information or insights you might 
need.https://vjackets.com/







Re: Preparing for the New DIP Process

2024-01-28 Thread John Thomas via Digitalmars-d-announce

On Sunday, 28 January 2024 at 04:47:30 UTC, FairEnough wrote:


module test;
@safe:

import std;

class C
{
private(this) int x; // intent: other code in this 
module cannnot mutate this.
private(this) int y; // intent: other code in this 
module cannnot mutate this.


invariant () { assert (x == y); }

void modifyX() {...}
void modifyY() {...}
}


void foo(C c)
{
c.x = 10; // compiler will not compile this code.
c.modifyX();
}


Thank you for posting a very informative example, i think not 
just myself but everyone else on this forum had completely forgot 
how class private is supposed to work. In spite of the 1000 or so 
posts you've made about it.


Keep up the good work!


Re: Preparing for the New DIP Process

2024-01-27 Thread John Thomas via Digitalmars-d-announce

On Saturday, 27 January 2024 at 19:58:55 UTC, Jordan Wilson wrote:

On Saturday, 27 January 2024 at 10:42:26 UTC, FairEnough wrote:

On Saturday, 27 January 2024 at 08:00:32 UTC, Jordan Wilson

I believe we are now in the "there is nothing more to be said" 
territory (just for the record, I think we both agree the 
feature is good, I just don't think the feature is necessary at 
all...nice-to-have at best. I suspect we'll agree to disagree).


Its probably more useful if you manage a team of barely competent 
idiot programmers.




Re: Preparing for the New DIP Process

2024-01-27 Thread John Thomas via Digitalmars-d-announce

On Friday, 26 January 2024 at 23:41:51 UTC, FairEnough wrote:
On Thursday, 25 January 2024 at 00:19:54 UTC, Jordan Wilson 
wrote:


...
That wasn't what was said. What was said was "causing US 
problems". I.e. on the whole, the lack of class-level privacy 
does not appear to be causing widespread problems, which 
implies that it's simply lower on the list of feature requests 
for most people.




Allowing mutable state to escape - the confines of the type in 
which it has been declared - into the whole of the module, will 
inevitably lead to a problem.


My first use of the D language demonstrated that this statement 
is factual.


The more 'widespread' D is used, will 'likely' also demonstrate 
the same.


What we need to do is find a way to make the computer explode 
when somebody does that. Weed out the stupid programmers. ;-)


Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn

On Tuesday, 19 December 2023 at 14:01:31 UTC, John Kiro wrote:
Thanks Adam. I agree, the behavior associated with the 
initialization here is confusing (compared for example to a 
similarly-looking code in Java). Also I don't get why an array 
of characters would be considered as an immutable array of 
characters (that is a **string**). I agree this could be a 
compiler bug, specially that it's not caught by the compiler.


I mean: specially that **attempting to update it** is not caught 
by the compiler.


Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
Thanks Adam. I agree, the behavior associated with the 
initialization here is confusing (compared for example to a 
similarly-looking code in Java). Also I don't get why an array of 
characters would be considered as an immutable array of 
characters (that is a **string**). I agree this could be a 
compiler bug, specially that it's not caught by the compiler.


SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn

Hello there,

First time to experiment with DLang, after a long time.

I'm getting a weird behavior with an **array of chars**, where I 
get a segmentation fault upon writing to it (see code and output 
below). What makes this problem weird it two things:


1) Why there is no problem with the **int** array (unlike the 
**char** array)?
2) Why reading the array element (**charArray[index]**) works, 
unlike writing to it?


The problem is gone if I uncomment the constructor code.

Code:

 import std.stdio;

 void main()
 {
   (new Test).runit();
 }

 class Test {
   static enum MAX = 10;
   uint index = 0;
   auto intArray = new int[MAX];
   auto charArray = new char[MAX];

   this() {
 /*
 charArray = new char[MAX];
 */
   }

   void runit() {
 debug writefln("IntArray initially: %s", intArray);
 intArray[index] = 40; //OK
 debug writefln("IntArray becomes: %s", intArray);

 debug writefln("Adding char in place of (%c) at index 
(%d)..",

charArray[index], index);
 charArray[index] = 'a'; //ERROR: segmentation fault 
(code -11)!
 debug writefln("CharArray becomes %s (PROGRAM ABORTS 
BEFORE IT ACTUALLY!)",

   charArray);
   }
 }


Output:

 $ dub run
 Starting Performing "debug" build using 
/home/john/dlang/dmd-2.106.0/linux/bin64/dmd for x86_64.
 Building hello-dlang ~master: building configuration 
[application]

  Linking hello-dlang
  Running hello-dlang
 IntArray initially: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 IntArray becomes: [40, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 Adding char in place of (�) at index (0)..
 Error Program exited with code -11



Re: From the D Blog: Crafting Self-Evident Code in D

2023-10-26 Thread John Colvin via Digitalmars-d-announce

On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:
It's been a long, long while since I published anything on the 
blog. I do intend to get pick it up again down the road, but 
Walter recently surprised me with plans of his own. He's taken 
the topic of his DConf '23 talk and derived a blog post from it:


https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/

I guess he got impatient with the pace at which I'm getting the 
talk videos uploaded :-)


And for anyone who'd like to engage in any Reddit discussion 
that comes up:


https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/


Good talk.

Many very clever people would achieve more if they tried to 
understand why a v. experienced developer would care to spend so 
much time talking about what might appear to be such basic points.


The key challenge: If this stuff was so obvious & everyone did it 
or it didn't matter so much that they didn't, why would Walter 
care about it so much?


Re: What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn

On Monday, 5 June 2023 at 10:43:27 UTC, Ferhat Kurtulmuş wrote:

On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote:
The parseDOM returns a DOMEntity(R) type, how do I write a 
xmlRoot as global variable?

I need its detailed type (auto / Variant doesn't work).


import dxml.dom;
?? xmlRoot;
int main() {
string xml = readText("a.xml");
auto dom = parseDOM(xml);
xmlRoot = dom.children[0];
}

```d
import dxml.dom;
import std.stdio;

DOMEntity!string xmlRoot;
int main()
{
string xml = "";
auto dom = parseDOM(xml);
writeln(typeof(dom.children[0]).stringof); // yields 
"DOMEntity!string"

xmlRoot = dom.children[0];
return 0;
}
```


Thanks, that's very helpful. D sometimes drives me crazy, screws 
up my brain, :-)


What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
The parseDOM returns a DOMEntity(R) type, how do I write a 
xmlRoot as global variable?

I need its detailed type (auto / Variant doesn't work).


import dxml.dom;
?? xmlRoot;
int main() {
string xml = readText("a.xml");
auto dom = parseDOM(xml);
xmlRoot = dom.children[0];
}


Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn

A correction:

 string getTMember(T t, string columnName) {
 foreach(member; __traits(allMembers, T)){
 if (member == columnName) {
 return __traits(getMember, t, member).to!string;
 }
 }
 return "";
 }




Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn
On Thursday, 1 June 2023 at 15:38:08 UTC, Steven Schveighoffer 
wrote:

On 5/31/23 12:08 AM, John Xu wrote:



When render vibe.d diet template,

     string[] allMembers = __traits(allMembers, t);


enum allMembers = __traits(allMembers, t);


     res.render!("index.dt", t, allMembers)

if I don't want write memberName one by one in diet template:

     table
     - foreach(memberName; allMembers)
     tr
     td #{memberName}
     td #{getTMember!memberName(t)}

Problem: memberName is not known at compile time.


The problem is that you stored the member name list as a 
runtime variable, and that is not known at compile time. Try 
the enum.


Or really, just `foreach(memberName; __traits(allMembers, t))` 
right in the diet template.


-Steve


Ok, thanks for all you gentlemen's help. I tried following 
function,

now it works like C/C++/Python way:

string getTMember(T t, string columnName) {
foreach(member; __traits(allMembers, T)){
if (member == columnName) {
return __traits(getMember, mcu, member).to!string;
}
}
return "";
}



Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 15:43:12 UTC, Steven Schveighoffer 
wrote:

On 5/30/23 4:46 AM, John Xu wrote:
How to put above enum as a function parameter? Following code 
wouldn't work:


     string getTMember(T t, enum string memberName) {
     return __traits(getMember, t, memberName);
     }


compile time parameters come before runtime parameters:

```d
string getTMember(string memberName)(T t) {
   return __traits(getMember, t, memberName);
}

// used like
auto v = getTMember!"name"(t);
```

-Steve


When render vibe.d diet template,

string[] allMembers = __traits(allMembers, t);
res.render!("index.dt", t, allMembers)

if I don't want write memberName one by one in diet template:

table
- foreach(memberName; allMembers)
tr
td #{memberName}
td #{getTMember!memberName(t)}

Problem: memberName is not known at compile time.


Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn

On Tuesday, 30 May 2023 at 01:33:54 UTC, H. S. Teoh wrote:
On Tue, May 30, 2023 at 01:24:46AM +, John Xu via 
Digitalmars-d-learn wrote:

On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote:
> On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote:
> > Error: variable `column` cannot be read at compile time
> 
> you should generally getMember on a variable
> 
> T t;

> __traits(getMember, t, "name")
> 
> like that, that's as if you wrote t.name


It seems I can't use variable as member name:

struct T {int a; string name;}
T t;
string s = "name";
writeln(__traits(getMember, t, s));

Above code fails to compile. Any help?


Short answer:

`s` must be known at compile-time.  Or more precisely, known at 
the time of template expansion. In this case, use `enum`:


enum s = "name";


Long answer:
https://wiki.dlang.org/Compile-time_vs._compile-time


T



How to put above enum as a function parameter? Following code 
wouldn't work:


string getTMember(T t, enum string memberName) {
return __traits(getMember, t, memberName);
}

My database table is very wide, with many columns. Above ddbc 
allows a struct
to map db returned data. Then if I want a member's value to show 
in vibe.d template,

how do I use a function to get it?


Re: How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn

On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote:

On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote:

Error: variable `column` cannot be read at compile time


you should generally getMember on a variable

T t;
__traits(getMember, t, "name")

like that, that's as if you wrote t.name


It seems I can't use variable as member name:

struct T {int a; string name;}
T t;
string s = "name";
writeln(__traits(getMember, t, s));

Above code fails to compile. Any help?


How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn
I saw ddbc 
(https://github.com/buggins/ddbc/blob/master/source/ddbc/pods.d) 
uses


static if (__traits(compiles, (typeof(__traits(getMember, T, 
m) {

__traits(getMember, T, m)
}

But for my experience, above code sometimes/somewhere works, 
sometimes/somewhere just doesn't:


Error: variable `column` cannot be read at compile time

Is there any friend can explain some more details?


How hide console in dub.sdl under windows 11?

2023-05-25 Thread John Xu via Digitalmars-d-learn

For dmd, I can use a no_console.def file, which has:

EXETYPE NT
SUBSYSTEM WINDOWS


Then `dmd my.d no_console.def` to hide console.

But how do I realize it with dub.sdl ? Adding no_console.def to
"sourceFiles", doesn't help.


Best way to convert between GBK/GB18030 to utf8 ?

2023-05-22 Thread John Xu via Digitalmars-d-learn

What is the best way to convert a GBK/GB18030 file contents,
i.e. read via: std.stdio.read(gbkFile).to!string ,
to utf8 encoding ?


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-22 Thread John Xu via Digitalmars-d-learn
On Friday, 19 May 2023 at 21:19:07 UTC, Richard (Rikki) Andrew 
Cattermole wrote:


On 19/05/2023 9:39 PM, John Xu wrote:
On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) 
Andrew Cattermole wrote:


On 19/05/2023 2:19 AM, John Xu wrote:
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) 
Andrew Cattermole wrote:

That is only for OMF target.

You need rc that comes with Visual Studio C++ build tools.

Alternatively windres from mingw may work (I haven't 
tested).


How can I add this step to dub.sdl ?


You would use one of the build commands and then put the 
result file name into source files.


However you may not want to require it in normal builds 
(since the file it outputs won't change you can just commit 
that) just to ensure your build is reproducible.


sourceFiles ?
or
libFiles ?

sourceFiles.

libFiles is for shared libraries.


When I put resource.rc in sourceFiles, dub said, "Error: 
unrecognized file extension rc";
When I put resource.res in sourceFiles, dub said,"resource.res : 
fatal error LNK1136: Invalid or damaged file.  Error: linker 
exited with status 1136"


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-19 Thread John Xu via Digitalmars-d-learn
On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew 
Cattermole wrote:


On 19/05/2023 2:19 AM, John Xu wrote:
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
Cattermole wrote:

That is only for OMF target.

You need rc that comes with Visual Studio C++ build tools.

Alternatively windres from mingw may work (I haven't tested).


How can I add this step to dub.sdl ?


You would use one of the build commands and then put the result 
file name into source files.


However you may not want to require it in normal builds (since 
the file it outputs won't change you can just commit that) just 
to ensure your build is reproducible.


sourceFiles ?
or
libFiles ?


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-18 Thread John Xu via Digitalmars-d-learn
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
Cattermole wrote:

That is only for OMF target.

You need rc that comes with Visual Studio C++ build tools.

Alternatively windres from mingw may work (I haven't tested).


How can I add this step to dub.sdl ?


Re: Where can I find D jobs?

2023-05-16 Thread John Xu via Digitalmars-d-learn

On Saturday, 29 April 2023 at 00:31:21 UTC, Neto wrote:

On Saturday, 29 April 2023 at 00:29:28 UTC, Neto wrote:
I'm thinking in moving from freelancer to some company, but 
I'd like to use D. Are there any companies hiring where D is 
used? note: hire without a degree.


and remote.


I received emails from turing.com before, about remote jobs.
But I never tried their real service.0


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn

On Monday, 15 May 2023 at 02:45:17 UTC, John Xu wrote:

Found a related link:
https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org

Where Adam D Ruppe informed rcc.exe from 
http://ftp.digitalmars.com/bup.zip

...
Any help? My isp.ico was converted from a png with gimp, used 
in C# programs before,
shouldn't have any problem. Searched bing.com about "Windows 
3.0 icon", bing didn't give

much info.


I figured out that the rcc on ftp.digitalmars.com only supports
8-bit non-compressed icon format. We'll need a newer rcc.exe
which can support 24-bit/32-bit/compressed-contents icon format.


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn

Found a related link:
https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org

Where Adam D Ruppe informed rcc.exe from 
http://ftp.digitalmars.com/bup.zip


But, I got problem:

rcc -r .\resource.rc
IDI_ICON1   ICON  DISCARDABLE  "isp.ico"
^
.\resource.rc(1) : Error: 'isp.ico' doesn't contain a valid 
Windows 3.0 icon resourc


Any help? My isp.ico was converted from a png with gimp, used in 
C# programs before,
shouldn't have any problem. Searched bing.com about "Windows 3.0 
icon", bing didn't give

much info.


Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn

On Friday, 12 May 2023 at 02:09:17 UTC, ryuukk_ wrote:

create a ``ressource.rc`` file

and paste:

```
IDI_ICON1 ICON DISCARDABLE "myicon.ico"
```

then put your ``mycon.ico`` file next to it

```
my_project\
app.d
ressource.rc
myicon.ico
```

```
dmd app.d ressource.rc


Thanks for your quick reply. I'll give a try.


Can dmd compile a favicon.ico to exe file ?

2023-05-11 Thread John Xu via Digitalmars-d-learn
I saw c# program's exe, often have an favicon.ico image bound 
together, which can be dragged to desktop.


Can dmd compile an icon image to an exe also?


Re: Any working REPL program on windows? DREPL doesn't compile

2023-05-11 Thread John Xu via Digitalmars-d-learn

On Thursday, 23 March 2023 at 13:27:00 UTC, jmh530 wrote:

I've composed a simple gui, partially solved my problem:
to compile/test simple codes quickly:
https://github.com/xucs007/dln



Re: Getting a total from a user defined variable

2023-04-20 Thread John Chapman via Digitalmars-d-learn

On Thursday, 20 April 2023 at 19:41:21 UTC, Joel wrote:

// how do I get the total of ages added together?


p.map!(x => x.age).sum();


Re: How can a function pointer required to be extern(C)?

2023-04-12 Thread John Chapman via Digitalmars-d-learn

On Wednesday, 12 April 2023 at 20:36:59 UTC, H. S. Teoh wrote:

---snip---
extern(C) void* abc(void*) {return null;}

alias FuncPtr = typeof();


You can also express it like this:

```d
extern(C) alias FuncPtr = void* function(void*);
```


Re: mutable pointers as associative array keys

2023-04-11 Thread John Colvin via Digitalmars-d-learn
On Monday, 10 April 2023 at 20:31:43 UTC, Steven Schveighoffer 
wrote:

On 4/10/23 4:25 PM, Steven Schveighoffer wrote:
It's also completely useless. Having const keys does nothing 
to guarantee unchanging keys. Another half-assed attempt to be 
encode correct semantics but fails completely in its goal.


In case you wonder how old this is:

https://issues.dlang.org/show_bug.cgi?id=11477
https://issues.dlang.org/show_bug.cgi?id=12491#c2

-Steve


Oh dear.


mutable pointers as associative array keys

2023-04-10 Thread John Colvin via Digitalmars-d-learn

It seems that it isn't possible, am I missing something?

alias Q = int[int*];
pragma(msg, Q); // int[const(int)*]

Also, is this documented somewhere?


Any working REPL program on windows? DREPL doesn't compile

2023-03-23 Thread John Xu via Digitalmars-d-learn
Anybody know any working REPL program? I failed to find a working 
one.


https://github.com/dlang-community/drepl
can't compile on my Windows 10, dub reports:

src\drepl\engines\dmd.d(258,16): Error: undefined identifier 
`dlsym`


How to expand wildchar under dos ?

2023-03-09 Thread John Xu via Digitalmars-d-learn

Under dos, how to get wildchar matched file names?

PS E:> dmd a.d
PS E:> .\a.exe a.*
args=["a.exe", "a.*"]

d-glob doesn't function well under windows dos either.


Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-09 Thread John Xu via Digitalmars-d-learn
I found this: 
https://github.com/meatatt/exCode/blob/master/source/excode/package.d


There is mention of unicode/GBK conversion, maybe it could be 
helpful


Thanks for quick answers. Now I found I can read both UTF8 and 
UTF-16LE

chinese file:
string txt = std.file.read(chineseFile).to!string;

and write to UTF8 file:
std.file.write(utf8ChineseFile, txt);

But still need figure out how to read/write GBK directly.



Best way to read/write Chinese (GBK/GB18030) files?

2023-03-06 Thread John Xu via Digitalmars-d-learn
I'm new to dlang. I didn't find much tutorials on internet about 
how to read/write Chinese easily. std.encoding doesn't seem to 
support GBK or GB18030:


"Encodings currently supported are UTF-8, UTF-16, UTF-32, ASCII, 
ISO-8859-1 (also known as LATIN-1), ISO-8859-2 (LATIN-2), 
WINDOWS-1250, WINDOWS-1251 and WINDOWS-1252."


Then what is best way to read GBK/GB18030 contents ? Even 
GBK/GB18030 file names ?





Re: staticMap but with two arguments

2023-02-09 Thread John Chapman via Digitalmars-d-learn

On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote:
I could not figure out eliminating the hard-coded 4. Can we 
introspect the parameter list of a template like 'fun' in the 
example? If we could, then we could get 4 that way.


Thank you for this. I don't mind hard-coding the N argument. 
TemplateArgsOf needs an instantiated template but maybe ```enum N 
= count(fun.stringof, ',') + 1``` is good enough.


Re: staticMap but with two arguments

2023-02-08 Thread John Chapman via Digitalmars-d-learn

On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote:

I adapted staticMap's implementation to two sets of arguments:


So I've got this implementation, but wonder if I can generalise 
the arg splitting portion rather than write it manually for each 
N?


```d
template staticMapN(size_t N, alias fun, args...) if (args.length 
% N == 0) {

  alias staticMapN = AliasSeq!();
  static foreach (i; 0 .. args.length / N)
static if (N == 1)
  staticMapN = AliasSeq!(staticMapN, fun!(args));
else static if (N == 2)
  staticMapN = AliasSeq!(staticMapN, fun!(args[0 .. $ / 
N][i], args[$ / N .. ($ / N) * 2][i]));

else static if (N == 3)
  staticMapN = AliasSeq!(staticMapN, fun!(args[0 .. $ / 
N][i], args[$ / N .. ($ / N) * 2][i], args[($ / N) * 2 .. ($ / N) 
* 3][i]));

// etc
}
```


Re: staticMap but with two arguments

2023-02-06 Thread John Chapman via Digitalmars-d-learn

On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote:

I adapted staticMap's implementation to two sets of arguments:


Thanks Ali, that's perfect. I thought of splitting the args in 
half a few hours later but hadn't got around to trying it.


staticMap but with two arguments

2023-02-05 Thread John Chapman via Digitalmars-d-learn
I have two AliasSeqs: one containing a function's parameters 
(SourceSeq), the other containing the types I want to convert 
said parameters to (TargetSeq). I'd use something like staticMap 
to call the conversion function with both a parameter from 
SourceSeq and a type from TargetSeq, and return an AliasSeq of 
converted values which will be forwarded to another function. 
staticMap's "fun" can only be instantiated with a single 
argument, while I need it to work with two.


E.g.:
```
template toTarget(alias source, Target) {
  static if (is(typeof(source) == int) && is(Target == string)) 
// for example, convert int to string

}

alias TargetSeq = Parameters!targetFunc;

auto wrapperFunc(A...)(A) {
  alias SourceSeq = __traits(parameters);
  return targetFunc(staticMap!(toTarget, SourceSeq)); // How 
would I call staticMap (or something similar) with SourceSeq 
*and* TargetSeq?

}
```

I could build the list of converted values manually but I wanted 
something smart (like staticMap) to do it inline. I thought 
ApplyLeft/Right could help but couldn't get my head around it.


Re: Mixin helper help

2023-01-14 Thread John Chapman via Digitalmars-d-learn

On Friday, 13 January 2023 at 14:32:44 UTC, Salih Dincer wrote:

Why not directly use the mixin template for opDispatch()?


My opDispatch generates code based on the arguments passed, 
interpolating variable names and functions based on the type. I 
wanted to remove the double braces in my static foreach (needed 
as I declared some aliases inside but since it creates a scope 
those new variables can't be referred to outside of it). I saw 
Adam's post here 
http://dpldocs.info/this-week-in-d/Blog.Posted_2022_12_26.html 
showing use of a "helper" template, and I was trying to adapt it.


I've since just dropped the double braces and removed the 
aliases. It's not as clean but works.


Mixin helper help

2023-01-12 Thread John Chapman via Digitalmars-d-learn

I'm obviously doing something wrong, but don't quite understand.

```d
mixin template helper() {
  mixin("writeln(12);");
}

struct Foo {
  void opDispatch(string name)() {
import std.stdio;
mixin helper!();
//mixin("writeln(12);");
  }
}

void main() {
  Foo.init.opDispatch!"bar"();
}
```

The compiler emits these errors about the mixin ("writeln(12);"):
unexpected `(` in declarator
basic type expected, not `12`
found `12` when expecting `)`
no identifier for declarator `writeln(_error_)`
semicolon expected following function declaration
declaration expected, not `)`

Why does the commented code work but the mixin not? Thanks for 
any pointers.


Re: text based file formats

2022-12-21 Thread John Colvin via Digitalmars-d-announce

On Wednesday, 21 December 2022 at 04:19:46 UTC, 9il wrote:

On Tuesday, 20 December 2022 at 19:46:36 UTC, John Colvin wrote:

On Tuesday, 20 December 2022 at 00:40:07 UTC, H. S. Teoh wrote:

[...]


We use this at work with some light tweaks, it’s done a lot 
work 


It has already been replaced with 
[mir.csv](https://github.com/libmir/mir-ion/blob/master/source/mir/csv.d). Mir is faster, SIMD accelerated, and supports numbers and timestamp recognition.


Hah, so it has! Well anyway, it did do a lot of hard work for us 
for a long time, so thanks :)


Re: text based file formats

2022-12-20 Thread John Colvin via Digitalmars-d-announce

On Tuesday, 20 December 2022 at 00:40:07 UTC, H. S. Teoh wrote:
On Mon, Dec 19, 2022 at 04:16:57PM -0800, Walter Bright via 
Digitalmars-d-announce wrote:

On 12/19/2022 4:35 AM, Adam D Ruppe wrote:
> On Monday, 19 December 2022 at 09:55:47 UTC, Walter Bright 
> wrote:

> > Curious why CSV isn't in the list.
> 
> Maybe std.csv is already good enough?


LOL, learn something every day! I've even written my own, but 
it isn't very good.


There's also my little experimental csv parser that was 
designed to be as fast as possible:


https://github.com/quickfur/fastcsv

However it can only handle input that fits in memory (using 
std.mmfile is one possible workaround), has a static limit on 
field sizes, and does not do validation.



T


We use this at work with some light tweaks, it’s done a lot work 


Re: Beerconf October 2022

2022-10-30 Thread John Colvin via Digitalmars-d-announce
On Sunday, 30 October 2022 at 01:50:33 UTC, Steven Schveighoffer 
wrote:

On 10/29/22 2:00 PM, FeepingCreature wrote:
On Saturday, 29 October 2022 at 10:14:31 UTC, rikki cattermole 
wrote:

And now for some good news!

Its almost Halloween, so grab your candy and any spooky brews 
you may have, and join us for a ghostly chat!


https://meet.jit.si/Dlang2022OctoberBeerConf


I wish you'd announce the time a bit in advance. :)


I don't want to announce a time, because I don't know what time 
it can be started. I'm in the US, so I'm usually asleep when 
it's started.


But I do try to announce 2 weeks before and then 2 days before.

-Steve


Quiet here, I’m around for a couple of hours, come say hi! 


Re: How to add struct definition?

2022-09-08 Thread John Chapman via Digitalmars-d-learn

On Friday, 9 September 2022 at 00:16:01 UTC, Injeckt wrote:
I need to add this struct definition in my project. But how to 
do that?

This structure:
https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_info


It's defined in DRuntime, so you can just import the module like 
this:


import core.sys.windows.iptypes;


Re: Symmetry looking for D programmers in Singapore/Hong Kong/Australia/New Zealand

2021-06-17 Thread John Colvin via Digitalmars-d-announce

On Wednesday, 16 June 2021 at 17:13:35 UTC, russhy wrote:

For what kind of project? need more info


It might help to look at https://jobs.symmetryinvestments.dev/ 
and https://github.com/symmetryinvestments/


Re: From the D Blog -- Interfacing D with C: Strings Part One

2021-05-24 Thread John Colvin via Digitalmars-d-announce
On Monday, 24 May 2021 at 16:16:53 UTC, Steven Schveighoffer 
wrote:

On 5/24/21 10:02 AM, Mike Parker wrote:
The latest post in the D and C series dives into the weeds of 
D and C strings: how they're implemented, when you need to 
NUL-terminate your D strings and when you don't, and how the 
storage of literals in memory allows you to avoid NUL 
termination in one case you might not have considered and 
another case that you shouldn't rely on but can in practice 
with the current compilers.


There are at least two more posts worth of information to go 
into on this topic, but everything in this post is enough to 
cover many use cases of D to C string interop.


The blog:
https://dlang.org/blog/2021/05/24/interfacing-d-with-c-strings-part-one/

Reddit:
https://www.reddit.com/r/programming/comments/njyf76/interfacing_d_with_c_strings_part_one/



Nice article!

Note that there is a huge pitfall awaiting you if you use 
`toStringz`: garbage collection. You may want to amend the 
article to identify this pitfall.


And I'm not talking about requiring `@nogc`, I'm talking about 
the GC collecting the data while C is still using it.


In your example:

```d
puts(s1.toStringz());
```

This leaves a GC-collectible allocation in C land. For `puts`, 
it's fine, as the data is not used past the call, but in 
something else that might keep it somewhere not accessible to 
the GC, you'll want to assign that to a variable that lasts as 
long as the resource is used.


-Steve


It’s worse than that, no? If the only reference to GC data isn’t 
on the stack of a tracked thread, in GC allocated memory or in a 
tracked root then it can be freed. Even in D:


void foo(int* a) {
int** b = cast(int**) malloc((int*).sizeof);
*b = a;
a = null;
GC.collect();
**b = 4; // whoops!!
}

foo(new int);

Right? Obviously that collection could be from calling another 
function (e.g. a callback from C to D code) or from another 
thread. Or am I missing something?


Re: Are there any containers that go with allocators?

2021-02-09 Thread John Burton via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 12:23:52 UTC, rikki cattermole 
wrote:

https://github.com/dlang-community/containers

It uses the older design for allocators (dependency).


Looks good, thank you


Are there any containers that go with allocators?

2021-02-09 Thread John Burton via Digitalmars-d-learn
Normally I'm happy with the GC containers in D, they work well 
and suit my use.


I have a few uses that would benefit from allocation in memory 
arenas or local stack based allocation. Looks like 
std.experimental has allocators for those use cases.


But I can't find any containers to make use of those allocators. 
The built in ones use GC managed memory, there are std.container 
but they appear to use malloc/free which again is useful but not 
what I'm looking for.


I'd like resizeable arrays, hashmaps and strings that I can 
allocate using an allocator?
Am I missing something in the standard library, or a way to use 
the existing ones, or is it just that nobody has implemented this 
kind of thing yet?





Re: DIP 1034--Add a Bottom Type (reboot)--Formal Assessment Begins

2021-02-03 Thread John Carter via Digitalmars-d-announce

On Wednesday, 3 February 2021 at 18:24:06 UTC, Imperatorn wrote:


Is there a short explanation of why this was done and what it 
enables?




Personally I'm excited to see this...

Strangely enough there is a long running 'net wide disagreement 
on what an assert is or does.


Some regard it as purely a debugging tool used as a programmer 
aid that is expressly turned on by the programmer, and others 
(such as myself) regard it as a way of stating, and enforcing the 
contract, provided by an API.


And as such, people with the latter mindset wish the compiler 
would warn us if that contract is potentially violated on any 
path, and conversely, wish the optimizer to act on the 
information it provides.


By adding it to the type system, it expresses and clarifies the 
intent of the author of the code, and expresses it in the 
compilers terms, ie. a type.


In my day job, I have found the only resolution to the 
disagreement is to create two different facilities with two 
different names to permit the two groups of humans to get along.


In my day job instead of "assert" we now have "log_If()" that 
are opt-in programmer debugging tools and "error_Check...()" that 
enforce.


Re: Printing shortest decimal form of floating point number with Mir

2021-01-04 Thread John Colvin via Digitalmars-d-announce

On Monday, 4 January 2021 at 17:22:55 UTC, John Colvin wrote:
On Monday, 4 January 2021 at 13:47:17 UTC, Ola Fosheim Grøstad 
wrote:

[...]


I have a longer reply I'm trying to write, but just to make 
sure I'm on the right track:


template Foo(T) {
alias Foo = T;
}

template Q(A : Foo!T, T) {
pragma(msg, A.stringof, " ", T.stringof);
}

alias X = Q!(Foo!int);

in your opinion, this should compile and msg `int int`, yes?

I'm trying to make a really concise example without using IFTI.


and presumably the same for
alias X = Q!(int);
yes?


Re: Printing shortest decimal form of floating point number with Mir

2021-01-04 Thread John Colvin via Digitalmars-d-announce
On Monday, 4 January 2021 at 13:47:17 UTC, Ola Fosheim Grøstad 
wrote:

On Monday, 4 January 2021 at 12:35:12 UTC, John Colvin wrote:
What's the simplest example that doesn't work and is that 
simple example just indirection through an alias or is it 
actually indirection through a template that *when 
instantiated* turns out to be just an alias?


Indirection through a parametric alias. This is the simplest I 
have come up with so far:



  struct Foo(T) {}

  alias Bar(T) = Foo!T;

  void f(T)(Bar!T x) {}

  void main() {
f(Bar!int());
  }


I created a thread for it:

https://forum.dlang.org/post/nxrfrizqdmhzhivxp...@forum.dlang.org


I have a suspicion that what you're asking for here is the 
type-inference to have x-ray vision in to uninstantiated 
templates that works for a few simple cases. Am I wrong?


No, just substitute: "Bar!int" with "Foo!int".


To be clear, a really useful special case can be really useful 
and worthwhile, but I'm not convinced this is the principled 
"type system bug" you are saying it is.


Why are you not convinced?

An alias is a short hand. If it is possible to discriminate by 
the alias and the actual object then that it a semantic problem.


I have a longer reply I'm trying to write, but just to make sure 
I'm on the right track:


template Foo(T) {
alias Foo = T;
}

template Q(A : Foo!T, T) {
pragma(msg, A.stringof, " ", T.stringof);
}

alias X = Q!(Foo!int);

in your opinion, this should compile and msg `int int`, yes?

I'm trying to make a really concise example without using IFTI.


Re: Printing shortest decimal form of floating point number with Mir

2021-01-04 Thread John Colvin via Digitalmars-d-announce
On Monday, 4 January 2021 at 09:21:02 UTC, Ola Fosheim Grøstad 
wrote:
On Monday, 4 January 2021 at 09:18:50 UTC, Ola Fosheim Grøstad 
wrote:
On Monday, 4 January 2021 at 05:55:37 UTC, Ola Fosheim Grostad 
wrote:

On Monday, 4 January 2021 at 04:37:22 UTC, 9il wrote:
I suppose the answer would be that D doesn't pretend to 
support all C++ template features and the bug is not a bug 
because we live with this somehow for years.


But it is a bug even if there was no C++... An alias should 
work by simple substitution, if it does not, then it is no 
alias...


Here is an even simpler example that does not work:

struct Foo(T){}
void foo(T)(T!int x) {}

alias FooInt = Foo!int;

void main() {
foo(FooInt());
}


Oh, now wait, it does:

struct Foo(T){}
void foo(alias T)(T!int x) {}
alias FooInt = Foo!int;

void main() {
foo(FooInt());
}

My mistake.


What's the simplest example that doesn't work and is that simple 
example just indirection through an alias or is it actually 
indirection through a template that *when instantiated* turns out 
to be just an alias?


I have a suspicion that what you're asking for here is the 
type-inference to have x-ray vision in to uninstantiated 
templates that works for a few simple cases. Am I wrong?


To be clear, a really useful special case can be really useful 
and worthwhile, but I'm not convinced this is the principled 
"type system bug" you are saying it is.


Re: Printing shortest decimal form of floating point number with Mir

2020-12-24 Thread John Colvin via Digitalmars-d-announce

On Thursday, 24 December 2020 at 14:14:33 UTC, 9il wrote:

On Thursday, 24 December 2020 at 14:08:32 UTC, welkam wrote:

On Wednesday, 23 December 2020 at 18:05:40 UTC, 9il wrote:

It was a mockery executed by Atila

Read the all comments and didnt saw any mockery


Yes, it wasn't explicit. He didn't write bad words, he did a 
bad decision. Bad for D.


Big difference between bad decision and mockery. It's very 
possible he was wrong, but I don't think he wasn't taking it 
seriously.


Re: MIR vs. Numpy

2020-11-18 Thread John Colvin via Digitalmars-d-announce
On Wednesday, 18 November 2020 at 13:01:42 UTC, Bastiaan Veelo 
wrote:
On Wednesday, 18 November 2020 at 10:05:06 UTC, Tobias Schmidt 
wrote:

Dear all,

to compare MIR and Numpy in the HPC context, we implemented a 
multigrid solver in Python using Numpy and in D using Mir and 
perforemd some benchmarks with them.


You can find our code and results here:
https://github.com/typohnebild/numpy-vs-mir


Nice numbers. I’m not a Python guy but I was under the 
impression that Numpy actually is written in C, so that when 
you benchmark Numpy you’re mostly benchmarking C, not Python. 
Therefore I had expected the Numpy performance to be much 
closer to D’s. An important factor I think, which I’m not sure 
you have discussed (didn’t look too closely), is the compiler 
backend that was used to compile D and Numpy. Then again, as a 
user one is mostly interested in the out-of-the-box 
performance, which this seems to be a good measure of.


— Bastiaan.


A lot of numpy is in C, C++, fortran, asm etc

But when you chain a bunch of things together, you are going via 
python. The language boundary (and python being slow) means that 
internal iteration in native code is a requirement for 
performance, which leads to eager allocation for composability 
via python, which then hurts performance. Numpy makes a very good 
effort, but is always constrained by this. Clever schemes with 
laziness where operations in python are actually just composing 
operations for execution later/on-demand can work as an 
alternative, but a) that's hard and b) even if you can completely 
avoid calling back in to python during iteration you would still 
need JIT to really unlock the performance.


Julia fixes this by having all/most in one language which is JIT'd

D can do the same with templates AOT, like C++/Eigen does but 
more flexible and less terrifying code. That's (one part of) what 
mir provides.


Highlight general point about software dev and design in general.

2020-10-22 Thread John Colvin via Digitalmars-d-announce

On Tuesday, 20 October 2020 at 21:58:16 UTC, Johan Engelen wrote:

On Tuesday, 20 October 2020 at 20:21:56 UTC, aberba wrote:

On Tuesday, 20 October 2020 at 17:36:11 UTC, kinke wrote:

On Tuesday, 20 October 2020 at 16:08:47 UTC, aberba wrote:
It's an option but doesn't fill the need for an installer. 
Not sure why its hasn't been done.


See https://github.com/ldc-developers/ldc/issues/1754.


From the discussions, it seems you still don't see the value 
of an installer...backing it with the idea that LDC is for 
"developers". I'm a developer myself and I use installers all 
the time when on Windows...there are very few people I 
personally know who would go for an archive file to set it up 
themselves.


So not everyone is like you. The reason why I personally go 
for DMD over LDC is convenience (especially when introducing D 
to newbies)...even though LDC is more optimized for 
performance.


Unless what you guys are doing is an artificial barrier to get 
others to not use it.


Guys, all points have been made, there is no wrong and right 
here, let's stop arguing over this.


What is needed is someone who thinks it is useful to have an 
exe installer and wants to do the work. It cannot be done by 
someone who thinks it is not useful, because there are 
decisions to be made (like which folder to install it in, 
whether to overwrite old or not), that can only be made by 
someone who actually cares about it. There is no point in 
trying to convince kinke or me.


I'm sure noone will be against uploading the installer exe onto 
github release page once it's been made and checked.


-Johan


Johan hits an important nail right on the head here.

While it is possible to design for others who are unlike you, 
it's much harder than designing for yourself or those who have 
similar values and priorities w.r.t. the thing in question. A lot 
of talk about "we (and by we I mean you) should do this thing I 
think is important" isn't pushing in the most productive 
direction, because


_*_*_{
even if one becomes convinced that there is value in something, 
that does not mean one has the relevant understanding necessary 
for good design of that thing

}_*_*_

Either the person with the problem works on understanding the 
tools to fix the problem, or the person with the tools works on 
understanding the problem. When values and "user experience" and 
"ease of use" are in play, I think the latter usually gets harder 
than normal, because understanding what will be easy or pleasing 
for others who are unlike us is not something everyone is good 
at.* This shifts the balance towards preferring the former 
approach where the person with the problem works towards doing at 
least a significant part of the design.** There will always be 
other considerations of course, this is just one force out of 
many.


This is not to say that developers shouldn't be thoughtful about 
their users - they definitely should be - but that doing a good 
job of that when the users are unlike the developer is _hard_.


* Perhaps in practice that ability is negatively associated with 
a strong sense of personal taste, e.g. great musicians writing 
the music _they_ want, not trying to specifically please people; 
the magic isn't that they understand other people, it's that 
their particular tastes resonate with others strongly. Maybe 
truly great mass-market businesses come from people who both have 
that magic _and_ a strong ability to experience their work from 
other's perspectives, the combination being rare and the ability 
to integrate the two effectively being even rarer (Steve Jobs 
comes to mind).


** Design and implementation often don't separate very cleanly in 
practice, so this probably means implementing it too, at least to 
proof-of-concept quality.


Re: winapi, dll

2020-10-15 Thread John Chapman via Digitalmars-d-learn

On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote:

On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:

On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
I didn't find how to call the queryperformancecounter 
function. I tried this. Returns errors, doesn't know what 
BOOL and LARGE_INTEGER are.


import core.sys.windows.windows;
import core.sys.windows.w32api;
import core.sys.windows.winbase;
pragma(lib, "kernel32");
extern (Windows)
{
BOOL QueryPerformanceCounter(LARGE_INTEGER 
*lpPerformanceCount);

}
void main()
{}


It's already defined. Just use QueryPerformanceCounter, (no 
extern).


I'm a newby. Can you show me an example? In which module is it?


Just import core.sys.windows.windows and call the function like 
so:


---
import core.sys.windows.windows;

void main() {
  LARGE_INTEGER pc;
  QueryPerformanceCounter();
}
---


Re: I need "windowsx.d" Someone can send It to me?

2020-09-26 Thread John Chapman via Digitalmars-d-learn

On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote:
I need windowsx.d but for I don't know the reason is not in 
dmd. Someone that have it can send to me? I don't know convert 
windowsx.h to windowsx.d


windowsx.h is mostly a bunch of macros that forward to functions 
elsewhere in the SDK. Yes, it's handy, but you can get by without 
it in case you don't manage to get it translated to D. Open 
windowsx.h in your editor, find the macro you want to use, look 
across to the right to see what the macro expands to, and use 
that in your code instead.


A lot of the macros that simply cast between HBITMAP, HPALETTE, 
HFONT, HPEN, HGDIOBJ etc are redundant because in D they're all 
just aliases for void*.


Re: Beta 2.094.0

2020-09-18 Thread John Colvin via Digitalmars-d-announce
On Friday, 18 September 2020 at 13:35:34 UTC, Jacob Carlborg 
wrote:

On 2020-09-17 12:10, John Colvin wrote:

I personally think it's not so bad as long as the commit gets 
written to the dub.selections.json


It doesn't.


I know. But it should be.

But then again a lot of things “should be” with dub.


Re: Beta 2.094.0

2020-09-17 Thread John Colvin via Digitalmars-d-announce
On Wednesday, 16 September 2020 at 18:52:23 UTC, Jacob Carlborg 
wrote:

On 2020-09-16 19:20, mw wrote:


Why it's deprecated? can we revive it?


It was deprecated because it's a bad idea to not lock versions. 
Using `~master` would fetch the latest code from the "master" 
branch when compiling. You never know which version you get. 
You don't get reproducible builds.


I personally think it's not so bad as long as the commit gets 
written to the dub.selections.json


Re: Access violation when using IShellFolder2

2020-09-10 Thread John Chapman via Digitalmars-d-learn

On Thursday, 10 September 2020 at 13:30:15 UTC, FreeSlave wrote:
Thanks. I tried this, but VarDateFromStr does not succeed for 
me.


It turns out the shell embeds some control characters in the 
string, specifically 8206 and 8207. So remove those before 
passing it to VarDateFromStr.


auto temp = strRet.pOleStr[0 .. lstrlenW(strRet.pOleStr)]
  .replace(cast(wchar)8206, "")
  .replace(cast(wchar)8207, "");
DATE date;
VarDateFromStr((temp ~ '\0').ptr, LOCALE_USER_DEFAULT, 0, );



Re: Access violation when using IShellFolder2

2020-09-10 Thread John Chapman via Digitalmars-d-learn

On Wednesday, 9 September 2020 at 22:44:50 UTC, FreeSlave wrote:
Btw do you know how to parse a date returned by GetDetailsOf? 
Couldn't find any examples in C++. I actually can see digits 
representing date and time as a part of the string, but I would 
prefer to use some winapi function to translate it into some 
time type instead of manually parsing the result.


You could look at passing the str.pOleStr field in the 
SHELLDETAILS you got from GetDetailsOf to VarDateFromStr. It will 
give you a DATE value that VariantTimeToSystemTime will convert 
to a SYSTEMTIME from which you can get the years, months, days 
etc.


For example:

SHELLDETAILS details;
GetDetailsOf(pidl, 3, );
DATE date;
VarDateFromStr(details.str.pOleStr, LOCALE_USER_DEFAULT, 0, 
);

SYSTEMTIME st;
VariantTimeToSystemTime(date, );
auto year = st.wYear;
auto month = st.wMonth;

You can convert that into a more D-friendly SysTime object using 
SYSTEMTIMEToSysTime from the std.datetime package.


Re: Access violation when using IShellFolder2

2020-09-09 Thread John Chapman via Digitalmars-d-learn

On Tuesday, 8 September 2020 at 22:24:22 UTC, FreeSlave wrote:
However if I change the type of recycleBin variable to 
IShellFolder (not IShellFolder2), the crash does not happen.


Does IShellFolder2 require some special handling?


The issue is caused by druntime's definition of IShellFolder2. To 
fix it temporarily, just redefine it in your module somewhere:


interface IShellFolder2 : IShellFolder {
  HRESULT GetDefaultSearchGUID(GUID*);
  HRESULT EnumSearches(IEnumExtraSearch*);
  HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*);
  HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*);
  HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, 
VARIANT*);

  HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*);
  HRESULT MapColumnToSCID(UINT, SHCOLUMNID*);
}

IShellFolder2 isn't the only culprit - IShellView2 will need 
fixing too if you intend to use it. There are probably others as 
well.




Re: Contributing to D wiki

2020-07-30 Thread John Burton via Digitalmars-d-learn

On Monday, 27 July 2020 at 16:58:13 UTC, H. S. Teoh wrote:
On Mon, Jul 27, 2020 at 11:39:32AM +, John Burton via 
Digitalmars-d-learn wrote: [...]
I tried looking there for information and examples of getting 
glfw3 statically linked into my program using LDC and didn't 
really find anything.


I wonder if adding a page for static linking tips would be 
useful as it seems to be problematic and compiler and 
environment dependent? Perhaps I should go ahead and see if I 
can make a page and see if anyone objects :P


Yes, please go ahead.  I don't think there's a need to ask. :-)


T


I will try to add something in the coming days


Re: Contributing to D wiki

2020-07-27 Thread John Burton via Digitalmars-d-learn

On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote:
On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via 
Digitalmars-d-learn wrote: [...]
D wiki is badly outdated. This is not a fact but a gut feeling 
after reading through some of its pages. I was wondering who's 
owning it myself but never actually dared to just go and 
update.


Why not?  It's a *wiki*.  Wikis are intended for the user 
community (i.e. you & me) to go and edit.  That's the whole 
point of a wiki.  If that wasn't the intention we wouldn't have 
set up a wiki in the first place.


I tried looking there for information and examples of getting 
glfw3
statically linked into my program using LDC and didn't really 
find anything.


I wonder if adding a page for static linking tips would be useful 
as it seems to be problematic and compiler and environment 
dependent? Perhaps I should go ahead and see if I can make a page 
and see if anyone objects :P




Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn

On Monday, 27 July 2020 at 08:53:25 UTC, Mike Parker wrote:

On Monday, 27 July 2020 at 07:30:42 UTC, John Burton wrote:


For reference I got this to work by doing the following :-

1) Installed visual studio build tools. I could not get this 
to work at all with the linker etc that comes with ldc2.
2) Copied the glfw3.lib vs2019 version file into my build 
directory (obviously could point the linker at it too which 
would be better)

3) Used the following dub.sdl

name "game"
description "Test Project"
authors "Me"
copyright "Copyright ┬® 2020, Me"
license "proprietary"
dependency "bindbc-glfw" version="~>0.10.0"
dflags "-mscrtlib=ucrt"
libs "glfw3"
versions "BindGLFW_Static"

The key seems to be using the dflags line to make it link with 
the "modern" C libraries, and using the microsoft linker.


I appear to have glfw3 statically linked and working :)


Cool. To be clear, you're still compiling with LDC, correct? 
I'm pretty sure DMD is using the universal C runtime out of the 
box when VS is installed.


yes compiling with LDC (Installed via "scoop" (see 
https://scoop.sh) but I don't think that matter where it came 
from).


I got it previously to work with DMD with no issue, my issue was 
with LDC only.
I was using DMD for my project previously but started doing 
something where performance mattered so thought to use LDC 
instead.


Re: Static link of glfw3 library fails for me

2020-07-27 Thread John Burton via Digitalmars-d-learn

On Sunday, 26 July 2020 at 12:24:06 UTC, John Burton wrote:

On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote:

On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote:



And I get the following errors from the link :-

lld-link: error: undefined symbol: __GSHandlerCheck
lld-link: error: undefined symbol: __security_check_cookie
lld-link: error: undefined symbol: __security_cookie


I believe that's because the GLFW library was compiled with 
the Microsoft compiler's /GS option:




For reference I got this to work by doing the following :-

1) Installed visual studio build tools. I could not get this to 
work at all with the linker etc that comes with ldc2.
2) Copied the glfw3.lib vs2019 version file into my build 
directory (obviously could point the linker at it too which would 
be better)

3) Used the following dub.sdl

name "game"
description "Test Project"
authors "Me"
copyright "Copyright ┬® 2020, Me"
license "proprietary"
dependency "bindbc-glfw" version="~>0.10.0"
dflags "-mscrtlib=ucrt"
libs "glfw3"
versions "BindGLFW_Static"

The key seems to be using the dflags line to make it link with 
the "modern" C libraries, and using the microsoft linker.


I appear to have glfw3 statically linked and working :)




Re: Static link of glfw3 library fails for me

2020-07-26 Thread John Burton via Digitalmars-d-learn

On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote:

On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote:



And I get the following errors from the link :-

lld-link: error: undefined symbol: __GSHandlerCheck
lld-link: error: undefined symbol: __security_check_cookie
lld-link: error: undefined symbol: __security_cookie


I believe that's because the GLFW library was compiled with the 
Microsoft compiler's /GS option:


https://docs.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=vs-2019

The __security_* functions are MS extensions to the C standard 
library. A quick search suggests you should try linking with 
bufferoverflowU.lib. Either that or compile GLFW with /GS- to 
turn off the security checks.


This is one reason I gave on on static linking pre-built C 
binaries long ago. I use the static bindings with import 
libraries, but I don't touch static libs unless I compile them 
myself.


Thank you. I'll look into this.
I wanted a single statically linked binary for an application I 
had in mind so thought I'd try this out. It's nice just to be 
able to send a single binary without needing to have an installer 
or copy multiple files for some use cases. This is the main 
reason I quite like go, not so much for the language but that 
things like "gitea" can be just one single binary and nothing 
else.


I can rebuild glfw I guess, that's not a problem (but makes it 
harder for people if I want to share my code of course). Perhaps 
I ought to try this.


I understand, as mentioned in your other reply, that I'll have to 
link with all the other dependencies of glfw too. I 
oversimplified my example a bit too much :)


Static link of glfw3 library fails for me

2020-07-26 Thread John Burton via Digitalmars-d-learn

I'm trying to replicate a program I make in C++ using D.
I am using the ldc2 compiler and want to *static* link in the 
glfw library.
Following the docs I have an dub.sdl file that looks like the one 
below.


The library I'm linking with is the vs2019 one from the GLFW zip 
file from
their website. My program isn't work showing, it just calls 
glfwInit, creates a
windows, and does a basic event loop. (This is a simplified test 
made when

I couldn't get my real program to link)

However I get link errors shown below.

Am I doing this wrong?
Am I using the wrong library to link with? (And if so which 
should I use).

Am I missing any options etc?
Or will this just not work with ldc2?

Thanks for any help!

My dub.sdl file looks like this :-

name "game"
description "Test Project"
authors "Me"
copyright "Copyright © 2020, Me"
license "proprietary"
dependency "bindbc-glfw" version="~>0.10.0"
versions "BindGLFW_Static"
libs "glfw3"
lflags "-L..\\work\\3rdparty\\lib"

And I get the following errors from the link :-

lld-link: error: undefined symbol: __GSHandlerCheck
lld-link: error: undefined symbol: __security_check_cookie
lld-link: error: undefined symbol: __security_cookie




Re: Decimal string to floating point conversion with correct half-to-even rounding

2020-07-07 Thread John Colvin via Digitalmars-d-announce

On Tuesday, 7 July 2020 at 15:08:33 UTC, Adam D. Ruppe wrote:
On Tuesday, 7 July 2020 at 13:00:04 UTC, Steven Schveighoffer 
wrote:
Doing that these days would be silly. You can depend on a 
specific version of a repository without problems.


I always have problems when trying to do that. git submodules 
bring pretty consistent pain in my experience.


But it probably isn't so bad if the submodule rarely changes.

Just for 100% control anyway nothing beats copy/paste. Then 
there's zero difference between you writing it yourself.


I kinda wish the D upstream were more willing to do that. My 
view is it shouldn't be on independent developers to add stuff 
to Phobos, for example, instead the Phobos team should just be 
copying and testing modules they are interested in on their own.


git subtree

it's like submodules but also like copy-paste.


Re: final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn

On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote:

On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote:
Is this a bug or have I made a mistake? This worked a few days 
ago and I haven't changed my setup since then.


https://issues.dlang.org/show_bug.cgi?id=19548

Your code triggers it by using "-debug" option on 
https://run.dlang.io/ using DMD


Hmm, compiling with -release makes it work. Not a huge issue, 
I'll just avoid final switches in debug mode until it's fixed. 
Thanks.


final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
If I use a final switch and import std.uni (or any other module 
that imports it, such as std.string), I'm getting unresolved 
external symbol errors with DMD 2.092.


This code triggers the issue:

---
module test;

import std.uni;

enum Cheese { cheddar, edam }

void test(Cheese cheese) {
  final switch (cheese) {
  case Cheese.cheddar: break;
  case Cheese.edam: break;
  }
}

void main() {
  test(Cheese.cheddar);
}
---

error LNK2019: unresolved external symbol "pure nothrow @nogc 
@safe void 
core.internal.switch_.__switch_error!().__switch_error(immutable(char)[], ulong)" (_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv) referenced in function _Dmain


If I remove "final" and add a default case, it compiles fine. Is 
this a bug or have I made a mistake? This worked a few days ago 
and I haven't changed my setup since then.


Re: Rationale for accepting DIP 1028 as is

2020-05-27 Thread John Colvin via Digitalmars-d-announce

On Wednesday, 27 May 2020 at 05:49:49 UTC, Walter Bright wrote:

On 5/26/2020 9:31 AM, Bruce Carneal wrote:
Currently a machine checked @safe function calling an 
unannotated extern C routine will error out during 
compilation. This is great as the C routine was not machine 
checked, and generally can not be checked.  Post 1028, IIUC, 
the compilation will go through without complaint.  This seems 
quite clear.  What am I missing?


Nothing at all.

But I doubt there is much legacy non-compiling code around.


The point isn't that incorrect legacy code that didn't compile 
now does (although that does matter a bit), it's that newly 
written code will compile when it shouldn't.


Existing code will be full of extern(C) declarations that are 
implicitly and correctly @system now and will become @safe with 
dip1028, which means that when I write new @safe code calling 
those (could be through a deep dependency chain of 
inferred-@safety APIs, multiple dub packages...) I could easily 
find my new code compiling when it shouldn't.



Effectively, by silently @safe-ing things you can't infer, you 
will be changing APIs from @system to @trusted without any checks.



Just in case there's any confusion, here's a timeline:

1. library A is written containing a dangerous but useful 
extern(C) declaration assuming @system by default.
2. application B is written for and compiled with dip1028, @safe: 
at the top of every file.
3. B adds a dependency on A. It continues to compile as @safe, 
calling an unsafe C function.



This seems like one of those things where it's either wrong or a 
showstopper.


Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn

On Tuesday, 26 May 2020 at 13:37:22 UTC, Vinod K Chandran wrote:

On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote:

On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote:

Here is my full code. Please take a look.
https://pastebin.com/av3nrvtT


Change line 124 to:

SetWindowSubclass(this.mHandle, SUBCLASSPROC(), 
UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this);


That is, change `` to `cast(void*)this`.


Hi,
Thanks for the reply. That will work like charm but we need to 
change the code in subclassed button's WndProc  like this--

extern(Windows)
private LRESULT btnWndProc(HWND hWnd, UINT message, WPARAM 
wParam, LPARAM lParam, UINT_PTR scID, DWORD_PTR refData) {

try  {

Button thisBtn = cast(Button)cast(void*)refData;
 {
catch (Exception e) {}



Yes, that should work.


Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn

On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote:

Here is my full code. Please take a look.
https://pastebin.com/av3nrvtT


Change line 124 to:

SetWindowSubclass(this.mHandle, SUBCLASSPROC(), 
UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this);


That is, change `` to `cast(void*)this`.


Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn

On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote:

On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote:


I believe that in D *this* is a reference to the
object and not a pointer like in C++.
So I think that writing  might be what you need?


No. A class reference is a pointer under the hood. Getting its 
address will result in a pointer to the reference variable 
itself, not to the class instance. When passing a reference to 
a C API, casting it directly to the C type is correct.


Ah I see.
In that case I have some code I need to investigate as it's 
probably only working by accident!


Re: How to get the pointer of "this" ?

2020-05-25 Thread John Burton via Digitalmars-d-learn

On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote:

On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote:

[...]


I think your issue might be elsewhere because casting this 
should be fine and it should not complain about that in your 
given code.


At least you should be able to pass this to another function or 
even cast it.


Please show the full code and the full error which gives you 
the stacktrace of where it's called and from where.



I believe that in D *this* is a reference to the
object and not a pointer like in C++.
So I think that writing  might be what you need?


Overload function template for rectangular array

2020-05-25 Thread John Chapman via Digitalmars-d-learn
Is it possible to overload a function template for rectangular 
arrays? Is there any way to tell them apart from normal ones?


void foo(T)(T[] a) {}
void foo(T)(T[][] a) {}

auto ra = new int[][](5, 5);
ra.foo(); // matches both

Thanks for any hints.


Re: Objective C protocols

2020-05-17 Thread John Colvin via Digitalmars-d-learn

On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote:

What's the best way to implement an Objective C protocol in D?

I see mention here 
https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days.


Based on some experimentation, I'm starting to wonder do 
protocols actually have any runtime component in Objective C? 
Because if I pass in an extern(Objective-C) class with the right 
interface to a function expecting a protocol everything just 
works.


Objective C protocols

2020-05-16 Thread John Colvin via Digitalmars-d-learn

What's the best way to implement an Objective C protocol in D?

I see mention here 
https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days.


Re: Easy way to format int in pragma msg ?

2020-05-14 Thread John Chapman via Digitalmars-d-learn

On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote:
Is there an easy way to print an int in hexadecimal, octal or 
binary representation ?


The documentation on pragma(msg, ...) and a quick web search 
didn't provide an answer.


  import std.string;
  pragma(msg, format("%x", 10));

%x = hex
%o = octal
%b = binary


Re: Luneta: terminal fuzzy finder

2020-05-05 Thread John Colvin via Digitalmars-d-announce

On Tuesday, 5 May 2020 at 07:31:18 UTC, Panke wrote:

On Monday, 4 May 2020 at 22:49:49 UTC, Felipe wrote:

Hi,

I develop an interactive terminal fuzzy finder in D with 
ncurses.

Feel free to check it out and contribute.

Any feedback is welcome.

Thanks, Felipe

[1] https://github.com/fbeline/luneta
[2] https://code.dlang.org/packages/luneta
[3] https://code.dlang.org/packages/fuzzyd


What's the difference to fzf?


Seems like this is being discussed here: 
https://github.com/fbeline/luneta/issues/28


Re: dmdcache

2020-04-25 Thread John Colvin via Digitalmars-d-announce

On Saturday, 25 April 2020 at 10:17:50 UTC, Ali Çehreli wrote:
A colleague of mine has written dmdcache which may be very 
useful for some projects:


  https://github.com/seeraven/dmdcache

It drops our build time

  from 8 minutes
  to 45 seconds

on a particular build environment for about half a dozen D 
programs, one of which ends up being a 2G executable! WAT! :) 
And the total cache size is 5.5G. Wow!


This build is with dmd 2.084.1 and that one particular 
application uses tons of template instantiations most of which 
are in generated source code. If I remember correctly, 2.084.1 
does not contain template symbol name improvements and that may 
be the reason for the large size.


Enjoy!

Ali


Perhaps I'm being very dumb, but how does this differ from just 
using make?


Re: Online D Conference

2020-03-16 Thread John Carter via Digitalmars-d-announce

Motivating Questions:

What is the difference between an "Online Conference" and 
watching something on youtube?


If the answer is nothing, don't bother with a conference, just 
create a youtube channel.


If the answer is a conference is nothing like watching stuff on 
youtube... you better consciously and actively organise it to be 
different.


What is the difference between "Online" and "Meat space"?

If the answer is "Nothing", you will have a guy, selected by a 
papers committee, standing in front of an empty hall talking at 
the camera.


Otherwise you can think much much wider...

* screencasts
* massively multiprogrammer online sessions
* remove the paper selection committee and replace it with 
redditlike upvotes
* or write a paper like you write a library, collaboratively, on 
github, with PR's.
* Have game sessions, virtual choirs, ... whatever can turn 
online handles into humans.



Disclaimer: I was involved in arranging linuxconfau 2019 and 
observed first hand that meatspace conferences impose huge and 
tight constraints on what is possible...


Some things are about meatspace are very nice (eat! drink! be 
merry!). Some things cost a huge amount and decrease the value of 
the conference. (Very tight limits on number of tracks / papers, 
attendees, health and safety, transport, accommodation, flights, 
.)


Re: DConf 2020 Canceled

2020-03-09 Thread John Burton via Digitalmars-d-announce

On Saturday, 7 March 2020 at 20:37:32 UTC, Mike Parker wrote:
Personally, I was really looking forward to heading to London 
and seeing everyone again, but I do agree with the decision. We 
hope not many of you will be impacted by the decision and we're 
terribly sorry if you are.


Very disappointing as I'd hoped to go for at least one day for 
the first time.

But very much the right thing to do under the circumstances.




Is it safe in D to cast pointers to structures like this?

2020-01-14 Thread John Burton via Digitalmars-d-learn
After years of C++ I have become paranoid about any casting of 
pointers being undefined behavior due to aliasing so want to see 
if :-


1) This is safe to do in D.
2) If not is there anything I can do to make it safe.
3) If not, what is the best approach?

I have a void* pointing to a block of allocated memory. In that 
memory I have a header struct at the start, and some of the 
members of that struct are offsets into the memory of other 
structs.


Can I do this? It appears to compile and "work" in dmd 64 bit but 
I need to make sure it's valid and reliable code. (This is a 
minimal example without any error checking etc)


import std.stdio;

//
// getMemory is just an example to make this compile...
//
void* getMemory()
{
static byte[100] someData;
// Something fills in the data here
}

struct Header
{
ulong data1;
ulong data2;
}

struct Data1
{
int a;
}

struct Data2
{
int b;
float[10] d;
}

void main()
{
void* memory = getMemory();
auto header = cast(Header*)memory;
auto data1 = cast(Data1*)(memory + header.data1);
auto data2 = cast(Data2*)(memory + header.data2);

writeln(data1.a, " ", data2.b);

}


Re: Win32 Api: How create Open/"Save as" Dialog?

2020-01-11 Thread John Chapman via Digitalmars-d-learn

On Saturday, 11 January 2020 at 10:34:34 UTC, Marcone wrote:

This code works, but I can't get file Path. Someone can help me?

import std;
import core.sys.windows.windows;
pragma(lib, "comdlg32");

void main(){
OPENFILENAME ofn;
wchar* szFileName;


You need to supply a buffer, not a pointer:

  wchar[MAX_PATH] szFileName;


(cast(byte*)& ofn)[0 .. ofn.sizeof] = 0;
ofn.lStructSize = ofn.sizeof;
ofn.hwndOwner = null;


The above lines are unnecessary as D structs are automatically 
initialized and lStructSize is already filled in.


ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files 
(*.*)\0*.*\0";

ofn.lpstrFile = szFileName;


It wants a pointer to your buffer:

  ofn.lpstrFile = szFileName.ptr;


ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | 
OFN_HIDEREADONLY;

ofn.lpstrDefExt = "txt";
if(GetOpenFileNameW()){
  writeln(szFileName); // Print null
  writeln(ofn.lpstrFile); // Print null


You'll need to slice the buffer to the right length:

  import core.stdc.wchar_ : wcslen;
  writeln(ofn.lpstrFile[0 .. wcslen(ofn.lpstrFile.ptr)]);


}
}





Re: DConf 2019 Pictures

2020-01-07 Thread John Colvin via Digitalmars-d-announce

On Tuesday, 7 January 2020 at 13:37:24 UTC, Ethan wrote:

On Tuesday, 7 January 2020 at 09:04:04 UTC, Ali Çehreli wrote:

This one is Laeeth introducing Andrei at Symmetry Investments:

  http://acehreli.org/photo/dconf_2019/DSC04839.html

Ali


And if you start here you get to the important bits: BeerConf!

http://acehreli.org/photo/dconf_2019/DSC04853.html


Damn... I miss beerconf.


Re: code.dlang.org downtime

2019-12-18 Thread John Colvin via Digitalmars-d-announce
On Wednesday, 18 December 2019 at 10:18:03 UTC, Sebastiaan Koppe 
wrote:
On Wednesday, 18 December 2019 at 09:29:50 UTC, John Colvin 
wrote:
This is still down for me, regardless of using the IP or 
address. I don't think it's just me either: 
https://stats.uptimerobot.com/6mQX4Crw2L/783838659


Anytime you see the metadata working you can add 
`--registry=https://dub.bytecraft.nl` to dub.


I am really tempted to cache the metadata as well. Although 
that brings up the question of how to purge it when new 
versions are released. (I could setup a job to import the dump 
every now and then, hmm).


This stuff just begs to be fixed.


can't get metadata, so no good right now.


Re: code.dlang.org downtime

2019-12-18 Thread John Colvin via Digitalmars-d-announce

On Monday, 16 December 2019 at 11:04:38 UTC, Sönke Ludwig wrote:
As you may have already noticed, the main registry server, 
code.dlang.org got unreachable yesterday. This was caused by an 
old VPS of mine getting terminated. The registry had already 
moved to a different server years ago, but, without me 
realizing it, the DNS entry still pointed to the old one, with 
a "temporary" HTTP proxy forwarding to the new server being set 
up.


By now the DNS entry has been corrected, an up-to-date TLS 
certificate is in place, and the registry is running stable. 
There are still reports of people not being able to access 
code.dlang.org, which is apparently caused by intermediate DNS 
servers still reporting the old IP address and should start 
working during the next few hours. A temporary workaround is to 
specify --registry=http://31.15.67.41/ on the dub command line.


Unfortunately both fallback servers have been down for a while 
now, so that this resulted in a total blackout. I plan to move 
the main registry to a powerful dedicated server in January, 
which will fix all memory resource related issues that 
sometimes show up, and could then keep the current VPS as a 
relatively reliable fallback server. Both together should 
guarantee virtually 100% uptime, although more fallback servers 
are of course highly desirable.


In addition to that, I plan to separate the repository polling 
process form the web and REST frontend, as the former appears 
to be the main cause for failures (a GC memory leak of some 
kind and a possibly codegen related crash when being compiled 
with DMD being the two known issues, which both need further 
investigation).


This is still down for me, regardless of using the IP or address. 
I don't think it's just me either: 
https://stats.uptimerobot.com/6mQX4Crw2L/783838659


Re: Release D 2.089.0

2019-11-05 Thread John Chapman via Digitalmars-d-announce

On Wednesday, 6 November 2019 at 01:16:00 UTC, Manu wrote:

On Tue, Nov 5, 2019 at 5:14 PM Manu  wrote:


On Tue, Nov 5, 2019 at 1:20 PM John Chapman via 
Digitalmars-d-announce  
wrote:

>
> On Tuesday, 5 November 2019 at 19:05:10 UTC, Manu wrote:
> > Incidentally, in your sample above there, `a` and `b` are 
> > not shared... why not just write: `cas(, null, b);` ?? 
> > If source data is not shared, you shouldn't cast to shared.

>
> Because casts were needed in 2.088 and earlier and I just 
> updated to 2.089, unaware of the API change. Should I log 
> `null` not working as a bug?


Yes


But I also think you should update your code to not perform the 
casts. Can you confirm that the null works when removing the 
shared casts?


Yes and no - it compiles when removing the casts, but AVs at 
runtime.


Bug filed: https://issues.dlang.org/show_bug.cgi?id=20359


Re: Release D 2.089.0

2019-11-05 Thread John Chapman via Digitalmars-d-announce

On Tuesday, 5 November 2019 at 19:05:10 UTC, Manu wrote:
Incidentally, in your sample above there, `a` and `b` are not 
shared... why not just write: `cas(, null, b);` ?? If source 
data is not shared, you shouldn't cast to shared.


Because casts were needed in 2.088 and earlier and I just updated 
to 2.089, unaware of the API change. Should I log `null` not 
working as a bug?


Re: Release D 2.089.0

2019-11-04 Thread John Chapman via Digitalmars-d-announce

On Tuesday, 5 November 2019 at 07:52:12 UTC, John Chapman wrote:


Sure - this AVs on DMD 2.088 Windows:

import core.atomic;
void main() {
  Object a, b = new Object;
  cas(cast(shared), null, cast(shared)b);
}


Sorry, I meant it AVs 2.089, but works on 2.088.


Re: Release D 2.089.0

2019-11-04 Thread John Chapman via Digitalmars-d-announce

On Tuesday, 5 November 2019 at 06:44:29 UTC, Manu wrote:
On Mon., 4 Nov. 2019, 2:05 am John Chapman via 
Digitalmars-d-announce, < digitalmars-d-announce@puremagic.com> 
wrote:


Something has changed with core.atomic.cas - it used to work 
with `null` as the `ifThis` argument, now it throws an AV. Is 
this intentional?


If I use `cast(shared)null` it doesn't throw but if the change 
was deliberate shouldn't it be mentioned?




Changes were made because there were a lot of problems with 
that module...
but the (reasonably comprehensive) unit tests didn't reveal any 
such
regressions. We also build+test many popular OSS projects via 
buildkite,

and there weren't problems.
Can you show the broken code?


Sure - this AVs on DMD 2.088 Windows:

import core.atomic;
void main() {
  Object a, b = new Object;
  cas(cast(shared), null, cast(shared)b);
}


  1   2   3   4   5   6   7   8   9   10   >