Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?



Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant 
wrote:

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?


UPX?
https://en.wikipedia.org/wiki/UPX
https://linux.die.net/man/1/upx


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 11:50:58 UTC, a11e99z wrote:
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant 
wrote:

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?


UPX?
https://en.wikipedia.org/wiki/UPX
https://linux.die.net/man/1/upx


Thanks for the reply, alle99z. Sorry for my badly-phrased 
question, I think I need to clarify...


What I'm looking for is a system for bundling dlang apps and 
their dependencies for distribution to end users. Hopefully, this 
bundler will:


- install the app in an appropriate place (like C:\Program 
Files\,
- install libraries/dependencies (such as GtkD) also in an 
appropriate place,
- make any modifications to the system PATH that may be necessary 
for the app to run, and
- handle any other roadblocks that will keep the user from using 
the app.


Whether this is an actual pre-existing application bundler or 
just a list of instructions I can follow so I can end up with a 
distributable one-click-does-it-all (on Windows, at least) 
package.


Similarly, on Linux or other UNIX-alikes, a breakdown of how to 
use apt or something similar to do the same so the user can (for 
instance) just do:


apt-get  

to install.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 12:04:16 UTC, Ron Tarrant 
wrote:

On Wednesday, 25 September 2019 at 11:50:58 UTC, a11e99z wrote:
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant 
wrote:

Hi y'all,

What I'm looking for is a system for bundling dlang apps and 
their dependencies for distribution to end users. Hopefully, 
this bundler will:


- install the app in an appropriate place (like C:\Program 
Files\,
- install libraries/dependencies (such as GtkD) also in an 
appropriate place,
- make any modifications to the system PATH that may be 
necessary for the app to run, and
- handle any other roadblocks that will keep the user from 
using the app.


Similarly, on Linux or other UNIX-alikes, a breakdown of how to 
use apt or something similar to do the same so the user can 
(for instance) just do:

apt-get  
to install.


so u need installers/installation program
https://en.wikipedia.org/wiki/List_of_installation_software

well, a long-long time ago I used InstallShield & Wix Toolset for 
Windows only.

I know no one that works with Linux package systems.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 12:32:58 UTC, a11e99z wrote:


so u need installers/installation program
https://en.wikipedia.org/wiki/List_of_installation_software

well, a long-long time ago I used InstallShield & Wix Toolset 
for Windows only.


I'll check those out. Thanks.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread bioinfornatics via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant 
wrote:

Hi y'all,

I've been Googling how to do this, but coming up with nothing 
definitive. Are there any articles for how to do this for:


Windows?
Linux?
other UNIX-alike OSs?


I think I misunderstood your need but are lo looking for dub tool 
with its repository https://code.dlang.org/


Re: Inspecting __traits(isDeprecated) and deprecation warnings

2019-09-25 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 05:57:19 UTC, Tobias Pankrath 
wrote:
Does your code work or does it not? I don't seem to unterstand 
neither what the question here is nor what the desired result 
is. Is the problem that the static reflections triggers the 
deprecation warning?


I added some deprecations in my project and am going through my 
templates trying to silence the warnings that suddenly popped up. 
This template works, but it triggers deprecation warnings when I 
am actively trying to avoid them.


getMember in _traits(isDeprecated, __traits(getMember, T, name)) 
causes a warning on deprecated symbols, which I wanted to avoid 
with isDeprecated, but I couldn't without first calling getMember 
to get the symbol to evaluate it. There's no way to combine 
isDeprecated with getMember without getting a warning.


I worked around the issue by using .tupleof instead of getMember, 
which breaks it for classes (.tupleof needs a `this` and 
SomeClass.init can't be it) but silences warnings for structs.


https://run.dlang.io/is/TVR8Cb

import std;

void main()
{
static assert(longestMemberName!Foo == "bbb".length);
}

struct Foo
{
string s;
int ii;
bool bbb;

deprecated("Use `s`")
string ;
}

template longestMemberName(T)
if (is(T == struct))
{
enum longestMemberName = ()
{
size_t maxLength;
T thing;  // need a `this`

foreach (immutable i, member; thing.tupleof)
{
static if (!__traits(isDeprecated, thing.tupleof[i]) 
&&

   !isType!(thing.tupleof[i]))
{
enum name = __traits(identifier, 
thing.tupleof[i]);

maxLength = max(maxLength, name.length);
}
}

return maxLength;
}();
}


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 13:52:48 UTC, bioinfornatics 
wrote:


I think I misunderstood your need but are lo looking for dub 
tool with its repository https://code.dlang.org/


I don't think so, but I could be wrong. I tried reading up on 
dub, but got lost in the docs, so I really don't understand what 
all it can do.




Re: Looking for a Simple Doubly Linked List Implementation

2019-09-25 Thread Ron Tarrant via Digitalmars-d-learn

On Monday, 23 September 2019 at 22:40:41 UTC, Ali Çehreli wrote:

So, what was it then? Append to an array, sort it, and be 
happy? :)


Ali


Hi, Ali,

It turns out that the GTK Notebook has its own built-in mechanism 
for tracking tabs. Two things got me going down the wrong road on 
this:


1) the fact that Notebook.appendPage() returns an ever-increasing 
index each time a page is added, and

2) trying to quit caffeine.

I chased my tail for a full week (seriously: a full week!) trying 
to come up with a way to track tabs. Then I got tired of doing 
face-plants on my desk, took up coffee again, and solved it in 
three hours.


The moral of the story is: don't quit coffee until you have 
nothing left to contribute to this world. :)


How to get the address of an instance of a class

2019-09-25 Thread dokutoku via Digitalmars-d-learn
I wrote the following code to get the address of a class 
instance, but it doesn't work.

Please let me know if there is a way to write it to work properly.

private import std;

```
class C
{
C* this_pointer()
{
return this;
}
}

void main()
{
C Z = new C();
writeln(&Z == Z.this_pointer());
}
```



Re: How to get the address of an instance of a class

2019-09-25 Thread Tobias Pankrath via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 17:32:25 UTC, dokutoku wrote:
I wrote the following code to get the address of a class 
instance, but it doesn't work.
Please let me know if there is a way to write it to work 
properly.


private import std;

```
class C
{
C* this_pointer()
{
return this;
}
}

void main()
{
C Z = new C();
writeln(&Z == Z.this_pointer());
}
```


Classes are always references. I think you can just cast 'Z' to 
void* to get the address.


Conversely &Z should be an address on the stack.



Difference between slice[] and slice

2019-09-25 Thread WhatMeWorry via Digitalmars-d-learn



Just got through debugging a line of code which uses dynamic 
array.  It boiled to to my use of [].  How should I "D think" 
about slice[]?  The run time error seems to say the the length of 
[] is zero.   I was assuming that [] meant "the entirety" of the 
array.


In short, is there anytime that one would want to use "slice[] = 
something" syntax?I


//waste[] = waste[0..$-1]; // object.Error@(0): Array lengths 
don't match for copy: 0 != 1


waste = waste[0..$-1]; // works





Re: Difference between slice[] and slice

2019-09-25 Thread Ali Çehreli via Digitalmars-d-learn

On 09/25/2019 12:06 PM, WhatMeWorry wrote:

> I was
> assuming that [] meant "the entirety" of the array.

Assuming we're talking about D slices, Yes. (It could be a user-defined 
type with surprisingly different semantics.)


> In short, is there anytime that one would want to use "slice[] =
> something" syntax?I

That changes element values.

> //waste[] = waste[0..$-1]; // object.Error@(0): Array lengths don't
> match for copy: 0 != 1
>
>  waste = waste[0..$-1]; // works

That makes slice refer to a different set of elements. In that example, 
the slice does not include the last element anymore.


Ali



Re: Inspecting __traits(isDeprecated) and deprecation warnings

2019-09-25 Thread Boris Carvajal via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 14:20:00 UTC, Anonymouse wrote:
I added some deprecations in my project and am going through my 
templates trying to silence the warnings that suddenly popped 
up. This template works, but it triggers deprecation warnings 
when I am actively trying to avoid them.


This code seems to work for classes too and even with DMD "-de" 
compiler switch.


template isMemberDeprecated(T, string name)
{
enum isMemberDeprecated = mixin(q{__traits(isDeprecated, }, 
T, ".", name, q{)});

}

https://run.dlang.io/is/iQbxOC




Re: Difference between slice[] and slice

2019-09-25 Thread WhatMeWorry via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 19:25:06 UTC, Ali Çehreli 
wrote:

On 09/25/2019 12:06 PM, WhatMeWorry wrote:

> I was
> assuming that [] meant "the entirety" of the array.

Assuming we're talking about D slices, Yes. (It could be a 
user-defined type with surprisingly different semantics.)


> In short, is there anytime that one would want to use
"slice[] =
> something" syntax?I

That changes element values.


Ok.  But which element(s)?  In my specific case, I was using []. 
Is


waste[] = waste[0..$-1];

even semantically meaningful?  Because the LDC compiler had no 
problem compiling it.





> //waste[] = waste[0..$-1]; // object.Error@(0): Array lengths
don't
> match for copy: 0 != 1
>
>  waste = waste[0..$-1]; // works

That makes slice refer to a different set of elements. In that 
example, the slice does not include the last element anymore.


Ali





Re: Difference between slice[] and slice

2019-09-25 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 20:36:47 UTC, WhatMeWorry 
wrote:
Ok.  But which element(s)?  In my specific case, I was using 
[]. Is


waste[] = waste[0..$-1];

even semantically meaningful?  Because the LDC compiler had no 
problem compiling it.


`waste[]` is just shorthand for `waste[0..$]`. Assigning to a 
slice means copying the contents of another array into the array 
that slice refers to. If the lengths of the source and 
destination don't match, you get an error. Since `waste[0..$]` 
and `waste[0..$-1]` can never have the same length, you will 
always get an error if you try to assign one to the other.


Source: https://dlang.org/spec/arrays.html#array-copying


Re: Difference between slice[] and slice

2019-09-25 Thread ag0aep6g via Digitalmars-d-learn

On 25.09.19 22:36, WhatMeWorry wrote:

On Wednesday, 25 September 2019 at 19:25:06 UTC, Ali Çehreli wrote:

On 09/25/2019 12:06 PM, WhatMeWorry wrote:

[...]

> In short, is there anytime that one would want to use
"slice[] =
> something" syntax?I

That changes element values.


Ok.  But which element(s)?


All of them. For example, `slice[] = 42;` sets all elements to 42. And 
`slice[] = another_slice[];` replaces all elements of `slice` with 
copies of `another_slice`'s elements.



  In my specific case, I was using []. Is

waste[] = waste[0..$-1];

even semantically meaningful?  Because the LDC compiler had no problem 
compiling it.


It's equivalent to this:


waste[0] = waste[0..$-1][0];
waste[1] = waste[0..$-1][1];
...
waste[waste.length - 2] = waste[0..$-1][waste.length - 2];
waste[waste.length - 1] = waste[0..$-1][waste.length - 1];


So it basically does nothing. It just copies `waste`'s elements over 
themselves.


Except that the last line makes an out-of-bounds access. That's an error 
that may be detected during compilation or at run time. Or if you're 
telling the compiler to optimize too aggressively, it might go unnoticed.


Using D for Raspberry Pi expirements

2019-09-25 Thread aberba via Digitalmars-d-learn
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core APIs 
from D as available in Python.


Anyone here tried something like that using D?


Re: Using D for Raspberry Pi expirements

2019-09-25 Thread Mike Franklin via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core 
APIs from D as available in Python.


Anyone here tried something like that using D?


I haven't tried with D yet, but I use C# and mono calling into 
the pigpio C library (http://abyz.me.uk/rpi/pigpio/pdif2.html) 
and it workes great.  You should be able to do the same with D.


Mike


Re: Using D for Raspberry Pi expirements

2019-09-25 Thread aberba via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core 
APIs from D as available in Python.


Just found this package dating back from May 2016...let's see 
what it can do 
(https://github.com/fgheorghe/D-Lang-Raspbian-GPIO-Module)




Anyone here tried something like that using D?