Re: static foreach issues

2017-09-05 Thread Psychological Cleanup via Digitalmars-d

On Wednesday, 6 September 2017 at 05:23:47 UTC, Ali Çehreli wrote:

On 09/05/2017 07:05 PM, Psychological Cleanup wrote:
> Nesting static foreach and using enum has latent problem.
>
> static foreach()
>   static foreach()
>   {
>  enum A = ;
>   }
>
> compiler complains because A is defined multiple times by the
outer most
> foreach.

That's understandable as there are multiple As dropped into 
code.


> To fix this
>
> static foreach()
>   static foreach()
>   {
>  {
> enum A = ;
>  }
>   }
>
> But then compiler complains about unexpected { if in a scope
where
> normal {}'s are not expected.

Can you demonstrate with compilable code? Doing what you 
describe works for me:


void main() {
static foreach(i; 0 .. 3)
static foreach(j; 0 .. 3)
{
{
enum A = i * j;
}
}
}

Ali


Yes, but I said you can't do that. Put the static foreaches 
outside main in to a block where one can't simply do {} and it be 
valid.


You see, the point is that

static foreach
   static foreach
   {

   }

works at the module level

static foreach
   static foreach
   {
   enum a = ;
   }

fails because of multiple a's


so

static foreach
   static foreach
   {
  {
 enum a = ;
  }
   }

to solve that(which, in your given example, works inside main) 
but fails at the module scope because the { }'s we used to solve 
the first problem created a new problem. The two methods are 
mutually exclusive but both are required.



Sure, I could wrap stuff around a function, but what if I'm using 
them for code generation inside a class? I have to use the extra 
{ } to prevent the enum error but then I get a new error about 
the { }.



class X
{
   static foreach
 static foreach
 {
   // fails, multiple a
   enum a = ; // part of class generation code like 
generating functions


 }
}


class X
{
   static foreach
 static foreach
 {
   // fails, { } block inside a class.
   {
   enum a = ; // part of class generation code like 
generating functions

   }

 }
}




it works fine if we use it in a function because we can have { } 
in functions without problems.


Do you not see the contradictory nature? { } required but { } 
forbidden.





Re: Going on std.regex & std.uni bug-fixing hunt

2017-09-05 Thread Dmitry Olshansky via Digitalmars-d
On Wednesday, 6 September 2017 at 05:23:51 UTC, Jon Degenhardt 
wrote:
On Tuesday, 5 September 2017 at 10:50:46 UTC, Dmitry Olshansky 
wrote:
Before I'm too deep down this rabbit hole I decided to first 
address the long-standing backlog of issues of std.regex and 
std.uni.


Not intending to add to your workload, but I added an 
enhancement request for something I hit ran into recently: 
Having a version of wcwidth/wcswidth functions available as 
part of unicode support. These functions calculate the width of 
a character in fixed-width fonts, they are useful in 
command-line apps.


Yeah, there is quite a few missing bits from std.uni. I didn't 
expect this one though.


Hopefully we can add them on pay as go principle, so if you don't 
use it you don't pay for it.




--Jon





Re: Going on std.regex & std.uni bug-fixing hunt

2017-09-05 Thread Jon Degenhardt via Digitalmars-d
On Tuesday, 5 September 2017 at 10:50:46 UTC, Dmitry Olshansky 
wrote:
Before I'm too deep down this rabbit hole I decided to first 
address the long-standing backlog of issues of std.regex and 
std.uni.


Not intending to add to your workload, but I added an enhancement 
request for something I hit ran into recently: Having a version 
of wcwidth/wcswidth functions available as part of unicode 
support. These functions calculate the width of a character in 
fixed-width fonts, they are useful in command-line apps. (CJK 
characters typically have a width of two.) Character width is 
part of the unicode standard. Issue: 
https://issues.dlang.org/show_bug.cgi?id=17810


--Jon




Re: static foreach issues

2017-09-05 Thread Ali Çehreli via Digitalmars-d

On 09/05/2017 07:05 PM, Psychological Cleanup wrote:
> Nesting static foreach and using enum has latent problem.
>
> static foreach()
>   static foreach()
>   {
>  enum A = ;
>   }
>
> compiler complains because A is defined multiple times by the outer most
> foreach.

That's understandable as there are multiple As dropped into code.

> To fix this
>
> static foreach()
>   static foreach()
>   {
>  {
> enum A = ;
>  }
>   }
>
> But then compiler complains about unexpected { if in a scope where
> normal {}'s are not expected.

Can you demonstrate with compilable code? Doing what you describe works 
for me:


void main() {
static foreach(i; 0 .. 3)
static foreach(j; 0 .. 3)
{
{
enum A = i * j;
}
}
}

Ali



Re: Deimos X11 bindings license question

2017-09-05 Thread Joakim via Digitalmars-d
On Tuesday, 5 September 2017 at 22:25:57 UTC, Jonathan M Davis 
wrote:
If you go with a BSD or Boost license, you're maximizing who 
can use your software, but you have no guarantees that any 
improvements will be made available, whereas the (L)GPL does 
guarantee that those improvements will be made available 
(assuming that folks behave themselves and follow the license 
anyway), but that means that there are a lot of projects that 
can't use your software, because those restrictions are 
unacceptable to those developing it.


I'll also note that if a developer uses GPL software on the 
server, he doesn't have to give any source to users who access 
apps on the server remotely.  For example, Google uses a linux 
kernel with proprietary modifications on a million servers 
running their search engine, yet my understanding is that they 
have not made most of those modifications available, as they're 
not required to under the GPL.  By contrast, every Android vendor 
has to release the source for their linux kernel.  It's not a 
coincidence that GPL software took off on the sever, until and 
except for Android's kernel.


That's why some devs then came up with the Affero GPL, to close 
the server loophole, though it hasn't been used for linux:


https://en.wikipedia.org/wiki/Affero_General_Public_License


[Issue 17810] New: Add wcwidth/wcswidth equivalents to std.uni

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17810

  Issue ID: 17810
   Summary: Add wcwidth/wcswidth equivalents to std.uni
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: jrdemail2000-dl...@yahoo.com

Enhancement request: Add the equivalents of the POSIX wcwidth/wcswidth
functions to std.uni.

These functions calculate the expected cell width of a wchar_t or wchar string.
This is the normal character width in fixed width fonts. It is useful in
command-line apps and other terminal displays where fixed width fonts are
commonly used. Generally, CJK characters are two cells wide, most other
characters are one cell wide. Cell width properties are part of the unicode
standard.

--


Re: Using closure causes GC allocation

2017-09-05 Thread Vino.B via Digitalmars-d-learn

On Monday, 4 September 2017 at 14:42:45 UTC, Azi Hassan wrote:

On Monday, 4 September 2017 at 05:45:18 UTC, Vino.B wrote:
  In order to resolve the issue "Using closure causes GC 
allocation" it was stated that we need to use delegates


Alternatively you can drop the functional style and use a 
foreach loop that doesn't require delegates, but you'd still 
need the GC to store the result in an array. And even then you 
could still use Array (from std.container).


Hi All,

 Was able to resolve this issue, thank you for your help, below 
is the changes that i did to resolve the issue.



import std.stdio: File,writeln;
import std.datetime.systime: Clock, days, SysTime;
import std.file: SpanMode, dirEntries, exists, isFile, mkdir, 
remove;

import std.typecons: tuple, Tuple;
import std.algorithm:  filter, map, each;
import std.array: array;

Tuple!(string)[] logClean (string[] Lglst, int LogAge) {
if (!Lglst[0].exists) { mkdir(Lglst[0]); }
		auto dFiles = dirEntries(Lglst[0], SpanMode.shallow).filter!(a 
=a.exists && a.isFile && a.timeCreated < dtLogAge).map!(a 
=tuple(a.name)).array;

dFiles.each!(a =a[0].remove);
return dFiles;
}

SysTime dtLogAge () {
int LogAge = mParams[1];
auto ct2 = Clock.currTime();
auto st2 = ct2 + days(-LogAge);
return st2;
}

void main () {
string[] LogDir = 
["C:\\Users\\admin\\Desktop\\Current\\Script\\D\\Logs"];

logClean(LogDir);
}

"mParams" is another function that reads the value from the 
configuration file and returns the value for the LogAge as 
defined in the configuration file.


From,
Vino.B


Re: run unittest inside program

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 06, 2017 02:06:59 Psychological Cleanup via 
Digitalmars-d-learn wrote:
> Is it possible to run a unit test without adding -unittest to the
> command line?
>
> unittest X
> {
> pragma(msg, "Boo!");
> }
>
> X;
>
> void main() { }

No. Without -unittest, the unittest blocks and anything that's
version(unittest) aren't compiled in. If you're worried about running main
after the unit tests (since unfortunately, the way that -unittest works is
that it compiles in your normal main to run after the unit tests), then you
can do something like

version(unittest) void main() {}
else void main()
{
...
}

And you can always put tests in functions rather than unittest blocks if you
want to call them normally.

There are also some unit test frameworks on code.dlang.org which allow you
to mess with how unit tests work in various ways, but fundamentally,
-unittest must be used in order to have unittest blocks and
version(unittest) blocks compiled in.

- Jonathan M Davis



Re: Interface inheritance

2017-09-05 Thread GGB via Digitalmars-d

On Tuesday, 5 September 2017 at 21:45:51 UTC, jmh530 wrote:

On Tuesday, 5 September 2017 at 21:44:07 UTC, jmh530 wrote:


This is related to Issue 2538:
https://issues.dlang.org/show_bug.cgi?id=2538

The spec has more information on interfaces here
https://dlang.org/spec/interface.html


And here is a simpler example:

interface I1
{
void A();
}

interface I2: I1
{
final void A() { }
}

class B: I2
{
   //It is an error to declare this class either with A or 
without it

}


Thanks, I think that explains it, although neither the 
documentation nor the compiler messages make things clear.


Re: Can attributes trigger functionality?

2017-09-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 02:43:20 UTC, Psychological 
Cleanup wrote:


I'm having to create a lot of boiler plate code that creates 
"events" and corresponding properties(getter and setter).


I'm curious if I can simplify this without a string mixin.

If I create my own attribute like

@Event double foo();

and I write any code that will trigger when the event is used 
and add more code(such as the setter property and events that I 
need?


Obviously I could write some master template that scans 
everything, but that seems to be far too much over kill. A 
string mixin is probably my only option but is a bit ulgy for 
me.


Since attributes can be defined by structures it seems natural 
that we could put functionality in them that are triggered when 
used but I'm unsure if D has such capabilities.


Thanks.


User defined attributes (UDAs) are in and of themselves only 
(compile time) introspectable decoration [1] (they only carry 
information). If you want to trigger specific behaviour for 
things that are attributed with a UDA you indeed need to some 
custom written active component that introspects using 
`__traits(getAttributes, symbol) and generates injects generates 
the behaviour (e.g. using a string mixin as you noted).


[1] https://dlang.org/spec/attribute.html#UserDefinedAttribute


Re: Can attributes trigger functionality?

2017-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 02:43:20 UTC, Psychological 
Cleanup wrote:


I'm having to create a lot of boiler plate code that creates 
"events" and corresponding properties(getter and setter).


I'm curious if I can simplify this without a string mixin.



You certainly don't need a string mixin, but you do need some 
code to react to the attribute.


Here's one that generates a wrapper function on-demand:

---

import std.stdio;
import std.traits;

class Test {
@cool void foo_() {
writeln("cool function called");
}

mixin CoolFunctions;
}

// our UDA
enum cool;

// adds the decorator implementation
mixin template CoolFunctions() {
template opDispatch(string name) 
if(hasUDA!(__traits(getMember, typeof(this), name ~ "_"), cool)) {
auto opDispatch(Parameters!(__traits(getMember, 
typeof(this), name ~ "_")) params) {

writeln("cool before");
scope(success) {
writeln("cool after");
}
return __traits(getMember, this, name ~ 
"_")(params);

}
}
}

void main() {
auto test = new Test();
test.foo();
}

-


No string mixin (uses a mixin template instead), and not even a 
loop over the functions - it does them on-demand when used via 
opDispatch.




Can attributes trigger functionality?

2017-09-05 Thread Psychological Cleanup via Digitalmars-d-learn


I'm having to create a lot of boiler plate code that creates 
"events" and corresponding properties(getter and setter).


I'm curious if I can simplify this without a string mixin.

If I create my own attribute like

@Event double foo();

and I write any code that will trigger when the event is used and 
add more code(such as the setter property and events that I need?


Obviously I could write some master template that scans 
everything, but that seems to be far too much over kill. A string 
mixin is probably my only option but is a bit ulgy for me.


Since attributes can be defined by structures it seems natural 
that we could put functionality in them that are triggered when 
used but I'm unsure if D has such capabilities.


Thanks.







static foreach issues

2017-09-05 Thread Psychological Cleanup via Digitalmars-d

Nesting static foreach and using enum has latent problem.

static foreach()
  static foreach()
  {
 enum A = ;
  }

compiler complains because A is defined multiple times by the 
outer most foreach.


To fix this

static foreach()
  static foreach()
  {
 {
enum A = ;
 }
  }

But then compiler complains about unexpected { if in a scope 
where normal {}'s are not expected.


So there is no way out of this conundrum? Maybe we need static {}?






run unittest inside program

2017-09-05 Thread Psychological Cleanup via Digitalmars-d-learn
Is it possible to run a unit test without adding -unittest to the 
command line?


unittest X
{
   pragma(msg, "Boo!");
}

X;

void main() { }


Re: DUB and LTO?

2017-09-05 Thread Jon Degenhardt via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 11:36:06 UTC, Sönke Ludwig wrote:

Am 24.01.2017 um 17:02 schrieb Las:

How do I enable LTO in DUB in a sane way?
I could add it to dflags, but I only want it on release builds.



You can put a "buildTypes" section in your package recipe and 
override default dflags or lflags there just for the "release" 
build type. See 
https://code.dlang.org/package-format?lang=json#build-types


There are examples in my dub.json files. One here: 
https://github.com/eBay/tsv-utils-dlang/blob/master/tsv-sample/dub.json#L24-L28. All the dub.json files in the repo are setup this way. Turns on LTO (thin) for LDC on OS X, not used for other builds. Works in Travis-CI for the combos of os x and linux with ldc and dmd.


--Jon


Re: Hong Kong dlang Meetup

2017-09-05 Thread Lionello Lunesu via Digitalmars-d-announce

Let's occupy codeaholics:
https://www.meetup.com/Codeaholics/events/242640432/

On 6/9/2017 00:26, Lionello Lunesu wrote:

+1!

Let me know the dates and I'll blast it to the channels I'm on
(Codeaholics, Dim Sum Labs hacker space.)

L.

On 5/9/2017 03:25, Jonathan M Davis via Digitalmars-d-announce wrote:

Several of us from the D community will be in Hong Kong on a business
trip
next week (me, John Colvin, Atila Neves, and Ilya Yaroshenko), and our
client, Symmetry Investments[1], has offered to sponsor a dlang
meetup. We
haven't decided when exactly to meet up yet, but we're looking to meet up
sometime during the week of the 11th - 15th (probably on Thursday or
Friday
evening) and figured that we should see if anyone here was interested in
showing up and would thus have some stake in when during the week it
happened.

The current plan is that the meetup will take place at Symmetry's main
office in Chater House in Central Hong Kong.

- Jonathan M Davis

[1] http://symmetryinvestments.com/about-us/

Some open source dlang stuff whose developement was paid for by Symmetry:
https://github.com/kaleidicassociates

Of note is https://github.com/kaleidicassociates/excel-d which Atila
talked
about at dconf this year.







Re: Hong Kong dlang Meetup

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-announce
On Tuesday, September 05, 2017 10:19:10 sarn via Digitalmars-d-announce 
wrote:
> On Monday, 4 September 2017 at 19:25:59 UTC, Jonathan M Davis
>
> wrote:
> > Several of us from the D community will be in Hong Kong on a
> > business trip next week (me, John Colvin, Atila Neves, and Ilya
> > Yaroshenko), and our client, Symmetry Investments[1], has
> > offered to sponsor a dlang meetup. We haven't decided when
> > exactly to meet up yet, but we're looking to meet up sometime
> > during the week of the 11th - 15th (probably on Thursday or
> > Friday evening) and figured that we should see if anyone here
> > was interested in showing up and would thus have some stake in
> > when during the week it happened.
> >
> > The current plan is that the meetup will take place at
> > Symmetry's main office in Chater House in Central Hong Kong.
>
> Sounds interesting.  The 14th and 15th aren't good for me,
> otherwise the rest of the week is okay.
>
> Are you staying near the office?

I'll be staying at the Marriott, which is supposedly fairly close, but I
don't know exactly where it's situated with respect to the office. I don't
know where the others are staying.

- Jonathan M Davis



Re: Hong Kong dlang Meetup

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-announce
On Tuesday, September 05, 2017 00:16:54 Nicholas Wilson via Digitalmars-d-
announce wrote:
> On Monday, 4 September 2017 at 19:25:59 UTC, Jonathan M Davis
>
> wrote:
> > Several of us from the D community will be in Hong Kong on a
> > business trip next week (me, John Colvin, Atila Neves, and Ilya
> > Yaroshenko), and our client, Symmetry Investments[1], has
> > offered to sponsor a dlang meetup. We haven't decided when
> > exactly to meet up yet, but we're looking to meet up sometime
> > during the week of the 11th - 15th (probably on Thursday or
> > Friday evening) and figured that we should see if anyone here
> > was interested in showing up and would thus have some stake in
> > when during the week it happened.
> >
> > The current plan is that the meetup will take place at
> > Symmetry's main office in Chater House in Central Hong Kong.
> >
> > - Jonathan M Davis
> >
> > [1] http://symmetryinvestments.com/about-us/
> >
> > Some open source dlang stuff whose developement was paid for by
> > Symmetry: https://github.com/kaleidicassociates
> >
> > Of note is https://github.com/kaleidicassociates/excel-d which
> > Atila talked about at dconf this year.
>
> That would be the one week in September I couldn't be in HK (yay
> mid-semester tests), but if the business trip is only for one
> week then I won't be in HK at all.

I think that most of us are arriving sometime this weekend and leaving
sometime the next weekend. Based on some of what he said previously, Atila
might be staying longer, but I don't know. If you can't be there next week
though, he's probably the only one of us four that you'd stand a chance of
seeing by coming to Hong Kong the week after. So, I guess that it's just bad
timing. Sorry.

- Jonathan M Davis



Re: C `restrict` keyword in D

2017-09-05 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, September 05, 2017 18:32:34 Johan Engelen via Digitalmars-d 
wrote:
> On Monday, 4 September 2017 at 21:23:50 UTC, Moritz Maxeiner
>
> wrote:
> > On Monday, 4 September 2017 at 17:58:41 UTC, Johan Engelen
> >
> > wrote:
> >> (The spec requires crashing on null dereferencing, but this
> >> spec bit is ignored by DMD and LDC, I assume in GDC too.
> >> Crashing on `null` dereferencing requires a null-check on
> >> every dereferencing through an unchecked pointer, because 0
> >> might be a valid memory access, and also because
> >> ptr->someDataField is not going to lookup address 0, but
> >> 0+offsetof(someDataField) instead, e.g. potentially addressing
> >> a valid low address at 100, say.)
> >
> > It's not implemented as compiler checks because the "actual"
> > requirement is "the platform has to crash on null dereference"
> > (see the discussion in/around [1]). Essentially: "if your
> > platform doesn't crash on null dereference, don't use D on it
> > (at the very least not @safe D)".
>
> My point was that that is not workable. The "null dereference" is
> a D language construct, not something that the machine is doing.
> It's ridiculous to specify that reading from address 1_000_000
> should crash the program, yet that is exactly what is specified
> by D when running this code (and thus null checks need to be
> injected in many places to be spec compliant):
>
> ```
> struct S {
>ubyte[1_000_000] a;
>int b;
> }
> void main() {
> S* s = null;
> s.b = 1;
> }
> ```

dmd and the spec were written with the assumption that the CPU is going to
segfault your program when you dereference a null pointer. In the vast
majority of cases, that assumption holds. The problem of course is the case
that you bring up where you're dealing with objects that are large enough
that the CPU can't do that anymore. And as Moritz points out, all that's
required to fix that is to insert null checks for those types. It shouldn't
be necessary at all for the vast majority of types. The CPU already handles
them correctly - at least on any x86-based system. I would expect any other
modern CPU to do the same, but I'm not familiar enough with other such
systems to know for sure. Regardless, there definitely should be no need to
insert null checks all over the place in any x86-based code. At most, it's
needed in a few places to deal with abnormally large objects.

Regardless, for @safe to do its job, the program does need to crash when
dereferencing null. So, if the CPU can't do the checks like the spec
currently assumes, then the compiler is going to need to insert the checks,
and while that may hurt performance, I don't think that there's really any
way around that while still ensuring that @safe code does not corrupt memory
or access memory that it's not supposed to. @system code could skip it to
get the full performance, but @safe is stuck.

- Jonathan M Davis



Re: Templates, D way

2017-09-05 Thread Void-995 via Digitalmars-d

On Tuesday, 5 September 2017 at 21:18:11 UTC, crimaniak wrote:

On Tuesday, 5 September 2017 at 14:55:21 UTC, Void-995 wrote:

Using unions? Count and Offset are different 
depending on input data, so the address where they are is 
varying depending on which file I've loaded. Or I didn't get 
what you meant.
 Yes, so you need separate union type for every type of input 
data. But these values are known in compile time, so you can do 
mixin, creating the union for each type like this:


union MyBinaryStructA
{
ubyte[...] asBytes;
struct asStruct
{
align(1):
ubyte[...] dummy1; // padding before firstList
MyBinarySubStructAForA[...] firstList;
ubyte[...] dummy2; // padding between lists
MyBinarySubStructBForA[...] secondList;
...
}
}

unittest
{
MyBinaryStructA a;

a.asBytes = someBinarySourceForA; // fill from unstructured 
source


auto item = a.asStruct.firstList[1]; // access to structure 
element

}


The whole thing is that I don't know either padding nor elements 
count. Those values are read from file. First you need to read 
whole file data and cast those bytes as pointer to file header 
structure. Offset of each list is bigger then size of the parent 
structure. Length of each list vary from 0 to whatever.


Re: dub projects generate docs and host on code.dlang.org?

2017-09-05 Thread user1234 via Digitalmars-d

On Tuesday, 5 September 2017 at 02:08:08 UTC, Manu wrote:
On 4 September 2017 at 21:45, user1234 via Digitalmars-d < 
digitalmars-d@puremagic.com> wrote:



On Monday, 4 September 2017 at 10:47:47 UTC, Manu wrote:


Thoughts?
- Manu



It has existed in the past, see http://forum.dlang.org/thread/ 
weuxppabkrreaxbqq...@forum.dlang.org?page=1




Seems to be gone.


Yes of course it's gone. That's a fact. I wanted to bring this 
fact in the discussion. That has existed already. I think nobody 
cared about the initiative.


Re: Deimos X11 bindings license question

2017-09-05 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, September 05, 2017 18:23:00 jmh530 via Digitalmars-d wrote:
> On Tuesday, 5 September 2017 at 18:12:23 UTC, bachmeier wrote:
> > But LGPL and GPL are very different licenses. Also, while I
> > don't have time to participate in yet another debate on the
> > topic, the GPL does not in any way restrict users. Using GPL
> > code means you promise *not* to impose restrictions. Feel free
> > to use whatever license you want, but please do not make
> > inaccurate claims about them.
>
> I suppose it depends on how you define user. Someone who simply
> uses GPL code without distributing it would not face
> restrictions. However, if you use GPL code in a project and want
> to distribute it, then you also have to license that project as
> GPL.

The GPL ensures that code is always out in the open and available by
restricting what the folks working on it can do with it and with any code
that would get used with it. If you're using the GPL, you can't keep your
code private. You're forced to make it and anything that you link to it
available. The goal is to ensure that folks using any products built with
that code have access to the code and can do what they want with it. It's
taking freedom away from the developers while trying to ensure the freedom
of those who use it. The LGPL is less restrictive in that it can be linked
against code that isn't GPL or LGPL without forcing that code to be made
available, but ultimately, the code that is LGPL still forces you to make
any changes available and does not allow the developers the freedom to do
what they want with it.

On the other hand, licenses like the BSD licenses or Boost try and ensure
the freedom of the developers to do what they want with with the code. They
can put it in proprietary products and muck with it however they like and
don't have to provide any of their changes to anyone. At most, they have to
admit to using the code by distributing the copyright with the binary (in
the case of the BSD licenses anyway - Boost doesn't even require that). So,
the developers have full freedom, but the users of the products have zero
guarantee that they'll have access to any of that source code or the ability
to change the code in the product.

Ultimately, it's about who you want to give freedom to, and how you want to
restrict people. Neither group of licenses grants full freedom, because by
giving freedom to one group, you take it away from the other.

If you go with a BSD or Boost license, you're maximizing who can use your
software, but you have no guarantees that any improvements will be made
available, whereas the (L)GPL does guarantee that those improvements will be
made available (assuming that folks behave themselves and follow the license
anyway), but that means that there are a lot of projects that can't use your
software, because those restrictions are unacceptable to those developing
it.

Personally, I think that the Boost or BSD-type licenses are ultimately
better, but there's a good argument to be had that the (L)GPL has done a lot
of good too. And ultimately, which is most appropriate for your software
depends on what your goals are.

- Jonathan M Davis



Re: Deimos X11 bindings license question

2017-09-05 Thread Jonathan Marler via Digitalmars-d

On Tuesday, 5 September 2017 at 18:12:23 UTC, bachmeier wrote:
...the GPL does not in any way restrict users. Using GPL code 
means you promise *not* to impose restrictions...


Reading things like this is much more humorous when you have a 
solid background in logic and contradiction.  As for you 
bachmeier, I hope you don't sprain your neck trying to find all 
the things that must go right over your head.


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, September 05, 2017 15:05:09 12345swordy via Digitalmars-d wrote:
> On Tuesday, 5 September 2017 at 14:55:20 UTC, Bastiaan Veelo
>
> wrote:
> > On Tuesday, 5 September 2017 at 13:27:44 UTC, 12345swordy wrote:
> >> [...]
> >
> > I assume you think that is a long time. It could also mean it
> > is stable.
> >
> > [...]
>
> There is lack of interest regarding event driven programming!?
> I am not interested in add features like the other guy did, I am
> interested in fixing the bug regarding thread safety.

Certainly, anyone doing it is either using something else completely or is
just using std.signals as it is, and there seems to be almost zero interest
in doing anything with std.signals. Occasionally, someone pops up who cares
and says something about it, but largely std.signals is just left as-is and
at least does not appear to be a module that many folks care about. So,
either it works well enough for folks, or there really isn't much interest.
Looking at git blame, it does look like some work has been done on it in the
last couple of years, but I think that most of it was for documentation.
std.signals is an older module, and I don't think that anyone in particular
is really maintaining it. So, it really only gets work done on it when
someone decides that something needs fixing and steps in to do it. There has
occasionally been talk of redoing it from someone who care about it, but the
interest from others in the newsgroup has generally been pretty low.

Personally, the only times that I've done anything that involved something
like this have been for GUI programming, and that usually involves
mechanisms connected to the GUI toolkit. If I were looking to do anything
that involved sending messages across threads, I'd be using std.concurrency,
not std.signals, and if I weren't specifically dealing with multiple
threads, I wouldn't see much point in the whole signals and slots thing. I'd
just call the function. That's not to say that someone else wouldn't find
what std.signals is doing valuable, but I personally don't see much point.

Regardless, if you see an issue with std.signals or any other module in
Phobos that you think should be fixed, feel free to fix it and create a pull
request. If it's a massive overhaul, that would involve having to go through
the whole Phobos review process that goes with adding or replacing a module,
but for smaller stuff, you can just create a PR up on github. Largely, stuff
gets done around here because someone who cares steps up and does it, and
everyone has different things they care about, and not everyone has time to
work on stuff, and those that do, rarely have as much time as they'd like.
So, the work that gets done doesn't always match up with what someone in
particular is looking for, and often, the best way to fix that is to just do
it yourself. Ultimately, _someone_ has to, or it won't get done, and most
things that get done around here get done, because someone is scratching
their own itch, so to speak.

- Jonathan M Davis



Re: dub projects generate docs and host on code.dlang.org?

2017-09-05 Thread Andrei Alexandrescu via Digitalmars-d

On 09/05/2017 12:05 PM, Seb wrote:

On Tuesday, 5 September 2017 at 07:59:09 UTC, denizzzka wrote:

On Monday, 4 September 2017 at 10:47:47 UTC, Manu wrote:
Suggest; code.dlang.org should attempt to generate ddoc for each 
hosted project, host it, and clearly link to it from the project 
front-page. Hosted docs should be styled consistently (matching 
phobos?).


Thoughts?
- Manu


It would be nice if the DUB will be able to generate "docsets" for 
offline documentation browsers:


https://kapeli.com/dash (can be integrated into various IDEs!)
https://zealdocs.org/
http://devdocs.io/


This has been merged this week:
http://devdocs.io/d/


Nice! Who did the work? -- Andrei



Re: Interface inheritance

2017-09-05 Thread jmh530 via Digitalmars-d

On Tuesday, 5 September 2017 at 21:44:07 UTC, jmh530 wrote:


This is related to Issue 2538:
https://issues.dlang.org/show_bug.cgi?id=2538

The spec has more information on interfaces here
https://dlang.org/spec/interface.html


And here is a simpler example:

interface I1
{
void A();
}

interface I2: I1
{
final void A() { }
}

class B: I2
{
   //It is an error to declare this class either with A or 
without it

}



[Issue 2538] Final method is not involved in inteface method resolution

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2538

John Hall  changed:

   What|Removed |Added

 CC||john.michael.h...@gmail.com

--- Comment #11 from John Hall  ---
This issue is discussed on the forum here:
https://forum.dlang.org/post/awkmkusrqnzdkyeyx...@forum.dlang.org

--


Re: Interface inheritance

2017-09-05 Thread jmh530 via Digitalmars-d

On Tuesday, 5 September 2017 at 20:15:44 UTC, GGB wrote:
What are the rules regarding one interface (not class, but 
interface) inheriting from another?


Nothing in the documentation seems to refer to interface 
inheritance, only to class inheritance.


I have tried to do some code with this, and the compiler does 
not complain about one interface inhering from another, but it 
does give some strange results when the child interface tries 
to implement an abstract method in the parent interface.




This is related to Issue 2538:
https://issues.dlang.org/show_bug.cgi?id=2538

The spec has more information on interfaces here
https://dlang.org/spec/interface.html



Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 19:59:27 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 19:44:40 UTC, EntangledQuanta 
wrote:
Just an idea for you: in delphi you can set the properties of 
a component (a class with runtime reflection enabled) on 
runtime. You can even call the methods and events of a 
component. I build a Delphi Bridge for D (see recent post on 
announce). It is almost the same scenario as here are also 
dll calls involved.
What I want to say, you could build something like the Delphi 
rtti for your D classes and make generic methods available 
via the dll interface.




But that would be quite a bit of work? Modifying the compiler? 
I'm just looking for something relatively straightforward and 
simple ;)


It is possible without modifying the compiler. In every class 
you want enable for runtime reflection you need to add a 
generic method which generates for all public 
properties/methods coding to fill/call them. It is a mix of 
templates and mixins.
In the end compile time reflection capabilities of D are so 
powerful that you can write runtime reflection with it.


Thanks for the tip!

Kind regards
André


Thanks, Yeah, that is essentially what I was going to do with 
attributes, but rather than having a member do it, have a free 
function that tries to do the same thing...


But then the question remains how to output that information so 
it can then be used to link in to the "script" that will be 
compiled?


Re: C `restrict` keyword in D

2017-09-05 Thread Moritz Maxeiner via Digitalmars-d

On Tuesday, 5 September 2017 at 18:32:34 UTC, Johan Engelen wrote:
On Monday, 4 September 2017 at 21:23:50 UTC, Moritz Maxeiner 
wrote:
On Monday, 4 September 2017 at 17:58:41 UTC, Johan Engelen 
wrote:


(The spec requires crashing on null dereferencing, but this 
spec bit is ignored by DMD and LDC, I assume in GDC too.
Crashing on `null` dereferencing requires a null-check on 
every dereferencing through an unchecked pointer, because 0 
might be a valid memory access, and also because 
ptr->someDataField is not going to lookup address 0, but 
0+offsetof(someDataField) instead, e.g. potentially 
addressing a valid low address at 100, say.)


It's not implemented as compiler checks because the "actual" 
requirement is "the platform has to crash on null dereference" 
(see the discussion in/around [1]). Essentially: "if your 
platform doesn't crash on null dereference, don't use D on it 
(at the very least not @safe D)".


My point was that that is not workable. The "null dereference" 
is a D language construct, not something that the machine is 
doing.


While "null dereference" is a language construct "null" is 
defined as actual address zero (like it's defined in C/C++ by 
implementation) and dereference means r/w from/to that virtual 
memory address, it is something the machine does: Namely, memory 
protection, because the page for address 0 is (usually) not 
mapped (and D requires it to not be mapped for @safe to work), 
accessing it will lead to a page fault, which in turn leads to a 
segmentation fault and then program crash.


It's ridiculous to specify that reading from address 1_000_000 
should crash the program, yet that is exactly what is specified 
by D when running this code (and thus null checks need to be 
injected in many places to be spec compliant):


```
struct S {
  ubyte[1_000_000] a;
  int b;
}
void main() {
   S* s = null;
   s.b = 1;
}
```


In order to be spec compliant and correct a compiler would only 
need to inject null checks on dereferences where the size of the 
object being pointed to (in your example S.sizeof) is larger than 
the bottom virtual memory segment of the target OS (the one which 
no C compatible OS maps automatically and you also shouldn't map 
manually).
The size of that bottom segment, however, is usually 
_deliberately_ large precisely so that buggy (C) programs crash 
on NULL dereference (even with structures as the above), so in 
practice, unless you invalidate assumptions about expected 
maximum structure sizes made by the OS, null dereferences can be 
assumed to crash.


Re: Templates, D way

2017-09-05 Thread crimaniak via Digitalmars-d

On Tuesday, 5 September 2017 at 14:55:21 UTC, Void-995 wrote:

Using unions? Count and Offset are different 
depending on input data, so the address where they are is 
varying depending on which file I've loaded. Or I didn't get 
what you meant.
 Yes, so you need separate union type for every type of input 
data. But these values are known in compile time, so you can do 
mixin, creating the union for each type like this:


union MyBinaryStructA
{
ubyte[...] asBytes;
struct asStruct
{
align(1):
ubyte[...] dummy1; // padding before firstList
MyBinarySubStructAForA[...] firstList;
ubyte[...] dummy2; // padding between lists
MyBinarySubStructBForA[...] secondList;
...
}
}

unittest
{
MyBinaryStructA a;

a.asBytes = someBinarySourceForA; // fill from unstructured 
source


auto item = a.asStruct.firstList[1]; // access to structure 
element

}


Re: Templates, D way

2017-09-05 Thread crimaniak via Digitalmars-d

On Tuesday, 5 September 2017 at 14:43:19 UTC, John Colvin wrote:
On Tuesday, 5 September 2017 at 12:41:45 UTC, Computermatronic 
wrote:

On Tuesday, 5 September 2017 at 12:20:14 UTC, crimaniak wrote:

[...]


I find it very strange that this works, as a non-mixin 
template should not be able to capture the context of where it 
was instantiated. If you take the alias template parameters 
out it behaves how it should (that is an error message saying 
this is not accessible).


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


What kind of harm can this be? Can this be considered a feature?


Re: Deimos X11 bindings license question

2017-09-05 Thread Walter Bright via Digitalmars-d

On 9/4/2017 10:54 AM, Vadim Lopatin wrote:
That said, I don't know if the Oracle v. Google case and its precedent that 
APIs are copyrightable impact this common understanding. After all, it was 
commonly understood prior to that case that that copyright applies to 
implementations, not interfaces. Now that the court has established the 
opposite, does the same hold true for licensing? I don't know of any legal 
cases that have decided either way.


If APIs do not have copyright protections, then licensing rules do not apply.

It looks like we need to get permission from 17 developers - all x11 binding 
contributors.


Additionally, contributors to Deimos/libX11

[...]
WalterBright


Of course I grant mine.



Interface inheritance

2017-09-05 Thread GGB via Digitalmars-d
What are the rules regarding one interface (not class, but 
interface) inheriting from another?


Nothing in the documentation seems to refer to interface 
inheritance, only to class inheritance.


I have tried to do some code with this, and the compiler does not 
complain about one interface inhering from another, but it does 
give some strange results when the child interface tries to 
implement an abstract method in the parent interface.


What I am trying to do in structurally like this:

interface I1
{
abstract x *A();
}

interface I2: I1
{
final x *A() { ... }
final int B() { return f(A()); }
}

interface I3: I1
{
final int C() { return g(A()); }
}

class C1: I3
{
final x *A() { ... }
}

class C2: I2
{
   // should not need to define A() because that should be 
defined in I2

   // Not allowed to define A() because already defined in I2
}


Re: Editor recommendations for new users.

2017-09-05 Thread Dukc via Digitalmars-d

On Sunday, 27 August 2017 at 10:28:29 UTC, Dukc wrote:
I'm sure there are other good options too. The problem with 
geany is that it's syntax highlighting and auto-completion 
depend on having the file where the symbol's defined open. But 
that's because it's primarily a lightweight editor, not so much 
an IDE. It has some ide features, but I am not using them and 
don't know whether you can could solve these by creating a geny 
project.


Also, like Lopatin said, DLangIDE is, at least theoretically a 
very good option. Despide being a real IDE, it is much smaller 
than Geany I meantioned, despite Geany being considered 
lightweight. And it's highlighting doesn't depend on files being 
opened fo editing. I have just started to use it, trough. Whether 
it's stable and polished enough to work well, I cannot tell yet.


Re: D vs Rust

2017-09-05 Thread Ali Çehreli via Digitalmars-d

On 09/04/2017 08:13 AM, Eljay wrote:

> the original language was Object Pascal.

Just a random connection: Bastiaan Veelo's DConf presentation was about 
parsing Extended Pascal.


  http://dconf.org/2017/talks/veelo.html

> Sorry if I didn't express myself clearly.

I agree that D rocks! :p

Ali



Re: Finding chars in strings

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 18:04:16 ag0aep6g via Digitalmars-d-learn 
wrote:
> On 09/05/2017 05:54 PM, Per Nordlöw wrote:
> > Follow up question: If a character literal has type char, can we always
> > assume it's an ASCII character?
>
> Strictly speaking, this is a character literal of type char: '\xC3'.
> It's clearly above 0x7F, and not an ASCII character. So, no.
>
> But if it's an actual character, not an escape sequence, then yes (I
> think). A wrong encoding setting in your text editor could mess with
> that, though.

Aside from escape sequences, a literal should not result in a non-ASCII
value for a char, but in general, it's a bad idea to assume that a char is
an ASCII character unless you've verified that already or somehow know based
on where the input came from that the char or chars that you're dealing with
are all ASCII. And you have to remember that VRP is in play as well, so if
it gets involved, you could end up with a char that's not an ASCII
character. And IIRC, character literals are almost always treated as dchar
unless a cast or VRP gets involved. So, I wouldn't be in a hurry to assume
that using character literals would guarantee that you're dealing with only
ASCII. Ultimately, std.ascii.isASCII is your friend if there's any risk of
something not being ASCII when you need it to be ASCII.

- Jonathan M Davis




Re: Making a repo of downloaded dub package

2017-09-05 Thread Dukc via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 08:43:02 UTC, Jonathan M Davis 
wrote:
Yeah. I'm fairly certain that that's your only option. dub is 
not designed with the idea that you would be editing the source 
code that it downloads. That's just intended for building the 
code that you are editing. It does support adding local repos 
to get pulled in via dub so that you can have your local stuff 
depend on other local stuff, but when dub downloads something, 
it's really just for its internal use.


- Jonathan M Davis


It seems that if I reclone the repo into another directory and 
copy it's history (.git directory) into the dub package, it works 
except that DUB or something else has converted the line endings 
to wrong format. I have not tested this throughly yet so I'm not 
sure it does the trick but may be worth trying if somebody else 
has the same problem.




Re: Finding chars in strings

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 17:55:20 ag0aep6g via Digitalmars-d-learn 
wrote:
> On 09/05/2017 05:43 PM, Per Nordlöw wrote:
> > If a character literal has type char, always below 128, can we always
> > search for it's first byte offset in a string without decoding the
> > string to a range of dchars?
>
> Yes. You can search for ASCII characters (< 128) without decoding. The
> values in multibyte sequences are always above 127.

Unfortunately, you'll have to use something like std.utf.byCodeUnit or
std.string.representation to do it; otherwise, you get hit with the
autodecoding. But yeah, UTF-8 is designed to be compatible with ASCII, so
all ASCII characters are valid UTF-8 code units and don't require decoding.
The decoding is just required if you're dealing with non-ASCII characters,
which is another reason why the autodecoding is annoying.

- Jonathan M Davis




Re: D scripting

2017-09-05 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 19:44:40 UTC, EntangledQuanta 
wrote:
Just an idea for you: in delphi you can set the properties of 
a component (a class with runtime reflection enabled) on 
runtime. You can even call the methods and events of a 
component. I build a Delphi Bridge for D (see recent post on 
announce). It is almost the same scenario as here are also dll 
calls involved.
What I want to say, you could build something like the Delphi 
rtti for your D classes and make generic methods available via 
the dll interface.




But that would be quite a bit of work? Modifying the compiler? 
I'm just looking for something relatively straightforward and 
simple ;)


It is possible without modifying the compiler. In every class you 
want enable for runtime reflection you need to add a generic 
method which generates for all public properties/methods coding 
to fill/call them. It is a mix of templates and mixins.
In the end compile time reflection capabilities of D are so 
powerful that you can write runtime reflection with it.


Thanks for the tip!

Kind regards
André


Re: C `restrict` keyword in D

2017-09-05 Thread dukc via Digitalmars-d

On Tuesday, 5 September 2017 at 18:32:34 UTC, Johan Engelen wrote:
My point was that that is not workable. The "null dereference" 
is a D language construct, not something that the machine is 
doing. It's ridiculous to specify that reading from address 
1_000_000 should crash the program, yet that is exactly what is 
specified by D when running this code (and thus null checks 
need to be injected in many places to be spec compliant):


```
struct S {
  ubyte[1_000_000] a;
  int b;
}
void main() {
   S* s = null;
   s.b = 1;
}
```

-Johan


Perhaps it should nullcheck exceptionally large types which may 
overflow the memory protected area, but not others?





Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 19:19:19 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 18:37:17 UTC, EntangledQuanta 
wrote:

On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta 
wrote:
I would like to use D as a "scripting" language for my D 
app. There seems to be no such thing.


Since we can include the D compiler in our distribution, it 
is easy to enable "plugin" capabilities, but directly 
interfacing with the source code seems like it would require 
a bit of work(duplicating the code that one wants to include 
so it can be linked in and "hot swapping").


Which OS do you use? I had a similiar idea but failed on 
windows due to some strange effects. I think they were caused 
by the known windows dll unload bug, discussed here: 
http://forum.dlang.org/thread/rreyasqnvyagrkvqr...@forum.dlang.org


At the end I decided to use the script engine from Adam Ruppe 
(arsd) until this bug is fixed.


Kind regards
André



Yes, windows ;/ Seems that thread has some answers! Maybe bug 
him enough to fix the bug?


How far did you get with it?

"The problem seems to only manifest when a proper DllMain() 
method is exported from the library.  If none is provided, or 
if the given implementation can be optimized away, the error 
does not ocurr."


Was that the case for you too? That could be overcome with 
just using a normal function that is called right after 
loading?


I'm curious how the exporting of code as that seems to be the 
biggest challenge(so that we don't have to hand write the 
exports ourselves).



Thanks.


My issue was that after unload the shared library, the dll file 
was still locked for deletion on the file system. Therefore I 
was not able to change something in my "script" and restart it. 
Somehow even after terminating in task manager, the dll file 
was still locked. I assume this reproducable effect is caused 
by the known issue.

I already give up at this point ):


Hmm, I used to have that problem with windows and visual studio. 
It was a Visual studio issue. Not sure if that is what you were 
using.  Sometimes it's just programs that lock on to it for no 
good reason.


There are ways around that: Use "unlocker" to unlock the file 
before deletion. Possibly rename the file to a random name 
opening up the space. Remove the generated files later when they 
build up. Load the DLL from memory(There are some online memory 
DLL loaders).


Just an idea for you: in delphi you can set the properties of a 
component (a class with runtime reflection enabled) on runtime. 
You can even call the methods and events of a component. I 
build a Delphi Bridge for D (see recent post on announce). It 
is almost the same scenario as here are also dll calls involved.
What I want to say, you could build something like the Delphi 
rtti for your D classes and make generic methods available via 
the dll interface.




But that would be quite a bit of work? Modifying the compiler? 
I'm just looking for something relatively straightforward and 
simple ;)





Re: D on Tiobe Index

2017-09-05 Thread dukc via Digitalmars-d-announce

On Friday, 1 September 2017 at 10:18:25 UTC, Vadim Lopatin wrote:


I believe DlangIDE can become such tool.
Runs on all platforms. Small.

which includes syntax highlighting, auto-complete, 
symbol-information on hover, go to declaration,


Supports it using embedded DCD.


and runtime debugging for D.


Debugging needs a lot of improvements to became usable.

Project is easy to contribute for D developers since written in 
D.


Other good canditate is BBasile's CoEdit. It's very much like 
DLangIDE in that it has roughly the same feature set, at least 
according to readme. It is also very actively maintained like 
your project. But it has the disadvantage of being written in 
Pascal.


I agree with that size thing, the whole DUB package is 40MB with 
release build. And without the DUB cache even of that sinks to 
one-third. Under a percent compared to 1.5GB I measured Visual 
Studio to take!


Re: D scripting

2017-09-05 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 18:37:17 UTC, EntangledQuanta 
wrote:

On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta 
wrote:
I would like to use D as a "scripting" language for my D app. 
There seems to be no such thing.


Since we can include the D compiler in our distribution, it 
is easy to enable "plugin" capabilities, but directly 
interfacing with the source code seems like it would require 
a bit of work(duplicating the code that one wants to include 
so it can be linked in and "hot swapping").


Which OS do you use? I had a similiar idea but failed on 
windows due to some strange effects. I think they were caused 
by the known windows dll unload bug, discussed here: 
http://forum.dlang.org/thread/rreyasqnvyagrkvqr...@forum.dlang.org


At the end I decided to use the script engine from Adam Ruppe 
(arsd) until this bug is fixed.


Kind regards
André



Yes, windows ;/ Seems that thread has some answers! Maybe bug 
him enough to fix the bug?


How far did you get with it?

"The problem seems to only manifest when a proper DllMain() 
method is exported from the library.  If none is provided, or 
if the given implementation can be optimized away, the error 
does not ocurr."


Was that the case for you too? That could be overcome with just 
using a normal function that is called right after loading?


I'm curious how the exporting of code as that seems to be the 
biggest challenge(so that we don't have to hand write the 
exports ourselves).



Thanks.


My issue was that after unload the shared library, the dll file 
was still locked for deletion on the file system. Therefore I was 
not able to change something in my "script" and restart it. 
Somehow even after terminating in task manager, the dll file was 
still locked. I assume this reproducable effect is caused by the 
known issue.

I already give up at this point ):

Just an idea for you: in delphi you can set the properties of a 
component (a class with runtime reflection enabled) on runtime. 
You can even call the methods and events of a component. I build 
a Delphi Bridge for D (see recent post on announce). It is almost 
the same scenario as here are also dll calls involved.
What I want to say, you could build something like the Delphi 
rtti for your D classes and make generic methods available via 
the dll interface.


Kind regards
André


Re: GitBook about D on embedded ARM Linux

2017-09-05 Thread thinwybk via Digitalmars-d-announce

On Sunday, 3 September 2017 at 16:17:37 UTC, thinwybk wrote:
In the beginning porting some of the C++ classes from 
https://github.com/derekmolloy/exploringBB/tree/master/chp06 
could be a good starting point.


...the complete C++ HAL can be found here: 
https://github.com/derekmolloy/exploringBB/tree/master/library




Re: Deimos X11 bindings license question

2017-09-05 Thread Adam D. Ruppe via Digitalmars-d

On Tuesday, 5 September 2017 at 18:23:00 UTC, jmh530 wrote:
However, if you use GPL code in a project and want to 
distribute it, then you also have to license that project as 
GPL.


Which just means your users also promise not to put restrictions 
on their users.


It is like the 13th amendment in the US constitution.


Re: SIMD under LDC

2017-09-05 Thread Johan Engelen via Digitalmars-d-learn

On Monday, 4 September 2017 at 20:39:11 UTC, Igor wrote:
I found that I can't use __simd function from core.simd under 
LDC and that it has ldc.simd but I couldn't find how to 
implement equivalent to this with it:


ubyte16* masks = ...;
foreach (ref c; pixels) {
c = __simd(XMM.PSHUFB, c, *masks);
}

I see it has shufflevector function but it only accepts 
constant masks and I am using a variable one. Is this possible 
under LDC?


You can use the module ldc.gccbuiltins_x86.di, 
__builtin_ia32_pshufb128 and __builtin_ia32_pshufb256.


(also see 
https://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/X86-Built_002din-Functions.html)


Please file a feature request about shufflevector with variable 
mask in our (LDC) issue tracker on Github; with some code that 
you'd expect to work. Thanks.


- Johan




Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta 
wrote:
I would like to use D as a "scripting" language for my D app. 
There seems to be no such thing.


Since we can include the D compiler in our distribution, it is 
easy to enable "plugin" capabilities, but directly interfacing 
with the source code seems like it would require a bit of 
work(duplicating the code that one wants to include so it can 
be linked in and "hot swapping").


Which OS do you use? I had a similiar idea but failed on 
windows due to some strange effects. I think they were caused 
by the known windows dll unload bug, discussed here: 
http://forum.dlang.org/thread/rreyasqnvyagrkvqr...@forum.dlang.org


At the end I decided to use the script engine from Adam Ruppe 
(arsd) until this bug is fixed.


Kind regards
André



Yes, windows ;/ Seems that thread has some answers! Maybe bug him 
enough to fix the bug?


How far did you get with it?

"The problem seems to only manifest when a proper DllMain() 
method is exported from the library.  If none is provided, or if 
the given implementation can be optimized away, the error does 
not ocurr."


Was that the case for you too? That could be overcome with just 
using a normal function that is called right after loading?


I'm curious how the exporting of code as that seems to be the 
biggest challenge(so that we don't have to hand write the exports 
ourselves).



Thanks.





Re: C `restrict` keyword in D

2017-09-05 Thread Johan Engelen via Digitalmars-d
On Monday, 4 September 2017 at 21:23:50 UTC, Moritz Maxeiner 
wrote:
On Monday, 4 September 2017 at 17:58:41 UTC, Johan Engelen 
wrote:


(The spec requires crashing on null dereferencing, but this 
spec bit is ignored by DMD and LDC, I assume in GDC too.
Crashing on `null` dereferencing requires a null-check on 
every dereferencing through an unchecked pointer, because 0 
might be a valid memory access, and also because 
ptr->someDataField is not going to lookup address 0, but 
0+offsetof(someDataField) instead, e.g. potentially addressing 
a valid low address at 100, say.)


It's not implemented as compiler checks because the "actual" 
requirement is "the platform has to crash on null dereference" 
(see the discussion in/around [1]). Essentially: "if your 
platform doesn't crash on null dereference, don't use D on it 
(at the very least not @safe D)".


My point was that that is not workable. The "null dereference" is 
a D language construct, not something that the machine is doing. 
It's ridiculous to specify that reading from address 1_000_000 
should crash the program, yet that is exactly what is specified 
by D when running this code (and thus null checks need to be 
injected in many places to be spec compliant):


```
struct S {
  ubyte[1_000_000] a;
  int b;
}
void main() {
   S* s = null;
   s.b = 1;
}
```

-Johan


Re: Deimos X11 bindings license question

2017-09-05 Thread jmh530 via Digitalmars-d

On Tuesday, 5 September 2017 at 18:12:23 UTC, bachmeier wrote:


But LGPL and GPL are very different licenses. Also, while I 
don't have time to participate in yet another debate on the 
topic, the GPL does not in any way restrict users. Using GPL 
code means you promise *not* to impose restrictions. Feel free 
to use whatever license you want, but please do not make 
inaccurate claims about them.


I suppose it depends on how you define user. Someone who simply 
uses GPL code without distributing it would not face 
restrictions. However, if you use GPL code in a project and want 
to distribute it, then you also have to license that project as 
GPL.


Re: Deimos X11 bindings license question

2017-09-05 Thread bachmeier via Digitalmars-d
On Tuesday, 5 September 2017 at 16:32:47 UTC, Jonathan Marler 
wrote:
On Sunday, 3 September 2017 at 16:10:11 UTC, Gary Willoughby 
wrote:

Hi,

A few years ago I forked the Deimos X11 bindings[1] repo to 
add dub support. Since then my repo[2] has received bug fixes 
and as such it's being used in many projects. (Also, in the 
following years dub support was added to the Deimos repo too.) 
I had a question from a developer as to the license of the 
code in my repo. I used the LGPL because the original used it.


My question, is there a legal way to change the current 
license to Boost or MIT or something like? Because this 
particular developer wanted to use it in a project where LGPL 
was incompatible.


[1]: https://github.com/D-Programming-Deimos/libX11
[2]: https://github.com/nomad-software/x11


+1 for getting away from the GPL.  Though I understand the 
sentiment coming from the FSF, the practical consequences of 
using GPL licenses is restricting the users of your 
library/application.  By going to a non-restrictive license 
like you suggest (Boost/MIT), it will allow the code to be used 
by anyone, instead of just those who conform to the GPL.


I'm assuming this is why you're trying to move to another 
license, I thought I would explicitly state this in the thread 
so as to educate others on the reasons why they may or may not 
want to use the GPL in their own projects.


But LGPL and GPL are very different licenses. Also, while I don't 
have time to participate in yet another debate on the topic, the 
GPL does not in any way restrict users. Using GPL code means you 
promise *not* to impose restrictions. Feel free to use whatever 
license you want, but please do not make inaccurate claims about 
them.


Re: C++ / Why Iterators Got It All Wrong

2017-09-05 Thread Mark via Digitalmars-d
On Saturday, 2 September 2017 at 20:22:44 UTC, Robert M. Münch 
wrote:
Iterators are not the silver bullet. But IIRC you can specify 
if you want to iterate over a graph BF or DF. If you just need 
to "iterate" over the elements things work pretty good IMO. If 
you want to select a sub-set and then iterate things get much 
complicater anyway.


There isn't really some finite (or small, anyway) choice here. I 
may want to iterate over a binary tree in 
preorder/inorder/postorder DF order. I may want to iterate over 
it in BF order. I may want to handle the left son before the 
right one, or vice versa. This is already 8 iterators. In C++ 
land I also need to provide const and non-const versions of each 
iterator, which brings it up to 16 iterators (I'm not sure what's 
the situation in D - can you have const ranges and still be able 
to call popFront on them?)


From the implementor's side, this is a headache. However, it's 
not that bad in a language in D, since "static if" saves you a 
lot of code in cases like this.


The bigger problem is on the user's side: Which iterator should 
she use? For most applications more than one type of iterator 
will be adequate, but the "right" choice will often be 
implementation-dependent. For instance, if the tree in question 
is a complete binary tree, then it is often implemented as an 
array that contains the tree's elements in BF order. Therefore, 
if some operation on the tree can be done by traversing it BF 
then the user should probably use a BF iterator, for performance 
reasons. But the user doesn't know how the tree is implemented, 
so she can't make that choice...


If the implementor informs the user about the implementation in 
the documentation, then his data structure is a cost-free 
abstraction (assuming that the user always chooses wisely...) but 
also a leaky one. If he doesn't, then the abstraction doesn't 
leak but it is no longer cost-free. He can't have both.


A simpler example is a class interface for a (two-dimensional) 
matrix. You would expect the interface to provide a row-major 
order iterator and a column-major order one. Again, from the 
user's POV, the right choice (performance wise) will be dependent 
on the implementation. Asymptotic complexity is sometimes 
considered an essential detail of a "true" abstraction but this 
doesn't help here since the difference in performance is only 
observed in practice.


This is why I find the presentation in the OP - "Why iterators 
got it all wrong" - a bit iffy. Iterators did get a lot of things 
wrong, but the presentation focuses on relatively mundane issues 
- ugly syntax and somewhat annoying semantics.


[Issue 9776] Make raw write mode the default

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9776

--- Comment #14 from anonymous4  ---
Not documented that std.file doesn't use C stdio and is not compatible with it
(and not intended) and no remark to not mix it with stdio as was suggested
here.

--


Re: SIMD under LDC

2017-09-05 Thread Igor via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 01:11:29 UTC, 12345swordy wrote:
On Monday, 4 September 2017 at 23:06:27 UTC, Nicholas Wilson 
wrote:

Don't underestimate ldc's optimiser ;)

I seen cases where the compiler fail to optimized for smid.


I tried it and LDC optimized build did generate SIMD instructions 
from regular code but it used multiple ones to do job so it is 
about 1.4 times slower than manual SIMD version with DMD. That is 
probably good enough for me.


Re: Deimos X11 bindings license question

2017-09-05 Thread Jonathan Marler via Digitalmars-d
On Sunday, 3 September 2017 at 16:10:11 UTC, Gary Willoughby 
wrote:

Hi,

A few years ago I forked the Deimos X11 bindings[1] repo to add 
dub support. Since then my repo[2] has received bug fixes and 
as such it's being used in many projects. (Also, in the 
following years dub support was added to the Deimos repo too.) 
I had a question from a developer as to the license of the code 
in my repo. I used the LGPL because the original used it.


My question, is there a legal way to change the current license 
to Boost or MIT or something like? Because this particular 
developer wanted to use it in a project where LGPL was 
incompatible.


[1]: https://github.com/D-Programming-Deimos/libX11
[2]: https://github.com/nomad-software/x11


+1 for getting away from the GPL.  Though I understand the 
sentiment coming from the FSF, the practical consequences of 
using GPL licenses is restricting the users of your 
library/application.  By going to a non-restrictive license like 
you suggest (Boost/MIT), it will allow the code to be used by 
anyone, instead of just those who conform to the GPL.


I'm assuming this is why you're trying to move to another 
license, I thought I would explicitly state this in the thread so 
as to educate others on the reasons why they may or may not want 
to use the GPL in their own projects.


Re: Hong Kong dlang Meetup

2017-09-05 Thread Lionello Lunesu via Digitalmars-d-announce

+1!

Let me know the dates and I'll blast it to the channels I'm on 
(Codeaholics, Dim Sum Labs hacker space.)


L.

On 5/9/2017 03:25, Jonathan M Davis via Digitalmars-d-announce wrote:

Several of us from the D community will be in Hong Kong on a business trip
next week (me, John Colvin, Atila Neves, and Ilya Yaroshenko), and our
client, Symmetry Investments[1], has offered to sponsor a dlang meetup. We
haven't decided when exactly to meet up yet, but we're looking to meet up
sometime during the week of the 11th - 15th (probably on Thursday or Friday
evening) and figured that we should see if anyone here was interested in
showing up and would thus have some stake in when during the week it
happened.

The current plan is that the meetup will take place at Symmetry's main
office in Chater House in Central Hong Kong.

- Jonathan M Davis

[1] http://symmetryinvestments.com/about-us/

Some open source dlang stuff whose developement was paid for by Symmetry:
https://github.com/kaleidicassociates

Of note is https://github.com/kaleidicassociates/excel-d which Atila talked
about at dconf this year.





Re: DLang IDE [RU]

2017-09-05 Thread TM via Digitalmars-d-learn
Из более серьезных улучшений, я бы предложил возможность в 
Workspace Explorer добавлять пакеты, переименовывать пакеты / 
модули, перемещать пакеты / модули и удалять пакеты / модули. Но 
это, очевидно уже будет требовать некоторых усилий на реализацию. 
А так, за неимением, IDE работает впаре с файловым менеджером (в 
моем случае это проводник Winodws или Far).


Re: dub projects generate docs and host on code.dlang.org?

2017-09-05 Thread Seb via Digitalmars-d
On Tuesday, 5 September 2017 at 02:21:26 UTC, Nicholas Wilson 
wrote:

On Monday, 4 September 2017 at 10:47:47 UTC, Manu wrote:
I've seen a lot of dub projects with embedded ddoc that 
follows phobos

example.
These projects are then hosted on code.dlang.org, but often, 
the docs are

never generated and hosted anywhere.
In the event they are, links to docs are ad-hoc and 
unpredictable, and the

formatting/styling/etc is not standard/consistent.

Suggest; code.dlang.org should attempt to generate ddoc for 
each hosted project, host it, and clearly link to it from the 
project front-page. Hosted docs should be styled consistently 
(matching phobos?).


Thoughts?
- Manu


Mir uses http://docs.algorithm.dlang.io/latest/index.html for 
its docs. Perhaps something like it could be extended for other 
projects?
I think Sebastian Wilzbach would be the person to contact about 
this.


Unfortunately the setup for Mir's repositories is quite 
complicated as it's based on Ddoc and dlang.org.
I think a better approach would be to use adrdox or Ddox with the 
scod theme [1].


[1] https://github.com/MartinNowak/scod


Re: dub projects generate docs and host on code.dlang.org?

2017-09-05 Thread Seb via Digitalmars-d

On Tuesday, 5 September 2017 at 07:59:09 UTC, denizzzka wrote:

On Monday, 4 September 2017 at 10:47:47 UTC, Manu wrote:
Suggest; code.dlang.org should attempt to generate ddoc for 
each hosted project, host it, and clearly link to it from the 
project front-page. Hosted docs should be styled consistently 
(matching phobos?).


Thoughts?
- Manu


It would be nice if the DUB will be able to generate "docsets" 
for offline documentation browsers:


https://kapeli.com/dash (can be integrated into various IDEs!)
https://zealdocs.org/
http://devdocs.io/


This has been merged this week:
http://devdocs.io/d/



Re: Finding chars in strings

2017-09-05 Thread ag0aep6g via Digitalmars-d-learn

On 09/05/2017 05:54 PM, Per Nordlöw wrote:
Follow up question: If a character literal has type char, can we always 
assume it's an ASCII character?


Strictly speaking, this is a character literal of type char: '\xC3'. 
It's clearly above 0x7F, and not an ASCII character. So, no.


But if it's an actual character, not an escape sequence, then yes (I 
think). A wrong encoding setting in your text editor could mess with 
that, though.


Re: Finding chars in strings

2017-09-05 Thread ag0aep6g via Digitalmars-d-learn

On 09/05/2017 05:43 PM, Per Nordlöw wrote:
If a character literal has type char, always below 128, can we always 
search for it's first byte offset in a string without decoding the 
string to a range of dchars?


Yes. You can search for ASCII characters (< 128) without decoding. The 
values in multibyte sequences are always above 127.


Re: Finding chars in strings

2017-09-05 Thread Per Nordlöw via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 15:43:02 UTC, Per Nordlöw wrote:
If a character literal has type char, always below 128, can we 
always search for it's first byte offset in a string without 
decoding the string to a range of dchars?


Follow up question: If a character literal has type char, can we 
always assume it's an ASCII character?


Re: dub projects generate docs and host on code.dlang.org?

2017-09-05 Thread Laeeth Isharc via Digitalmars-d

On Tuesday, 5 September 2017 at 03:15:58 UTC, Adam D. Ruppe wrote:

On Monday, 4 September 2017 at 11:15:08 UTC, Joakim wrote:
While it's an interesting suggestion, dub has 355 open issues, 
would be better if more people pitched in on those:


I have zero interest in fixing dub issues since I have zero 
interest in using dub.


If one of the libraries were compelling... and I actually knew 
about it though, that equation may change.


Making the code repository show documentation will do a lot to 
make the library more discoverable and valuable, which in turn, 
can drive dub use and bring with it more contributors.


I think this is a good idea (and I bought a VM to set up to do 
it myself, but I went too cheap and the 512 MB of memory isn't 
enough to actually build the docs! ugh.)


If you want a larger VM email me specs and I will set one up for 
you.


I guess the doc generation doesn't need much changing on dub.  
Maybe an extra command line option to build and publish docs that 
calls a field specified in dub.sdl like postgenerate command 
because you don't want to build docs every time and creating 
separate build configurations means you now have double the 
number, with and without docs.  And custom command allows you to 
use a different doc generator.  But we could have a default 
command to generate those for dub the repository.


And then the template for the web site would just need to have a 
link to appropriate directory added?


We have contributed to dub in past - John Colvin worked on this.  
One problem was lack of bandwidth to review pull requests.  If we 
get better review and still don't have contributions then one can 
address that directly, but for now review seems the bottleneck.






Re: C `restrict` keyword in D

2017-09-05 Thread Dukc via Digitalmars-d

On Monday, 4 September 2017 at 18:03:51 UTC, Johan Engelen wrote:


It's need for auto-vectorization, for example.

I would support an LDC PR for adding a magic UDA to be able to 
attach 'restrict' with C-semantics to function parameters. E.g.

```
 // add restrict to parameters 1 and 2
void foo(int, int*, int*) @restrict(1,2)
```


That probably explains it in case of c. But I still think that D 
might be able to do this better without language changes. This 
way (not compiler-checked for errors):

```
for(int i = 0; i < a.length; i+=8)
{   int[8] aVec = a[i .. i+8], bVec = b[i .. i+8], cVec;
foreach(j; 0 .. 8) cVec[j] = aVec[j].foo(bVec[j]);
c[i .. i+8] = cVec[];
}
```

Of course, if we want to support this we should construct a 
high-level library template that chooses the correct vector size 
for the platform, eliminates that outer for loop and handles 
uneven array lenghts.


[Issue 15399] unaligned pointers are not @safe

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15399

ag0ae...@gmail.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||ag0ae...@gmail.com
 Resolution|FIXED   |---

--- Comment #5 from ag0ae...@gmail.com ---
Reopening because these very slight variations are still accepted:

1) hosts[n] = Unaligned(0, new Victim);
2) Unaligned u = { p: new Victim }; hosts[n] = u;

--


DLang IDE [RU]

2017-09-05 Thread TM via Digitalmars-d-learn

Да простят англоязычные участники :)
С попеременным успехом пытаюсь оседлать DLang IDE, связи с чем 
накопился ряд вопросов, прежде всего к автору.

Рабочая станция: I3-550, ОС Windows 7 Pro SP1 русская, 32 битная.

1. Невозможно собрать как IDE, так и любой пример из DlangUI, 
если в профиле пользователя windows используются символы 
кириллицы. Компиляция через DMD/LDC падает на DlangUI с:
module exception is in file 
'C:\Users\русский_юзернейм\AppData\Roaming\dub\packages\derelict-util-2.0.6\derelict-util\source\derelict\util\exception.d' which cannot be read


2. Под англоязычной учетной записью windows последняя удачная 
сборка IDE была 0.7.45 или 0.7.46, дальше DMD начал падать с "Out 
of memory", LDC также начал выдавать ошибку. Проблема также 
похоже во "внутренностях" DlangUi, так как примеры DLangUi не 
собираются ровно с теми же симптомами. Пробовал как советовалось 
в рекомендациях чистить папку с "кашем" dub, но безрезультатно.


3. Баг непосредственно DLang IDE: при создании "главного" файла 
пакета package.d в новом файле не корректно прописывается строчка 
module, создается строка вида "module mypackage.package", когда 
должна быть "module mypackage"


Есть также несколько небольших пожеланий по улучшению 
"юзабилити", но тут конечно на усмотрение автора.
1. Добавить возможность выбора размера шрифта для области 
редактирования. Я крайне редко меняю подобные настройки в IDE, но 
в данном случае дефолтный шрифт оказался откровенно мелковат 
(возможно под Linux ситуация несколько иная), пришлось за не 
имением выбора размера шрифта искать более крупный шрифт.


2. В области Workspace Explorer на одном уровне иерархии модули и 
пакеты сортируются по алфавиту, но "вперемешку" с друг другом, в 
отличие от того же Notepad++, где сначала по алфавиту сортируются 
пакеты, а потом модули. Понимая, что такой режим также может 
оказаться неудобным для части пользователей, предлагаю сделать 
настройку с режимом сортировки. И если, файлы package.d имеют 
некий "особый" статус в языке, возможно имеет смысл выделять их 
как-то (например другой иконкой или font.bold=true)


3. Очень непривычное поведение редактора при копипасте строки. 
Обычная комбинация: Home, Shift+End (выделяется вся строка), 
Ctrl+C, End (для снятия выделения), Enter (для перехода на другую 
строку), Ctrl+V оканчивается тем, что End после Ctrl+C не снимает 
выделение строки (как это делали все известные мне до сих пор 
редакторы, даже консольный редактор в Far Manager), а последующий 
Enter не переводит каретку, а удаляет выделенную строку. 
Возможно, опять же, это какое-то неизвестное мне каноническое 
поведение, но крайне неудобно.


P.S. В любом случае, Вадим, огромное спасибо за проделанную 
работу. Если нужна какая-то более подробная информация по 
проблемам с компиляцией, то не стесняйтесь, спрашивайте. Но как я 
понимаю скриншоты этот форум не поддерживает.


Возможно есть какой-нибудь другой вариант "русскоязычного" 
обсуждения IDE/GUI, например через e-mail или русскоязычный 
форум, чтобы не залезать сюда или на гитхаб со своим русским 
самоваром? Я к сожалению, при достаточно свободном чтении на 
английском, не могу того же сказать скилл чукчи-писателя, но 
добавить свои пять копеек иногда хочется :D




Finding chars in strings

2017-09-05 Thread Per Nordlöw via Digitalmars-d-learn
If a character literal has type char, always below 128, can we 
always search for it's first byte offset in a string without 
decoding the string to a range of dchars?


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread Bastiaan Veelo via Digitalmars-d
On Tuesday, 5 September 2017 at 14:55:20 UTC, Bastiaan Veelo 
wrote:

According to [5] it  is already thread safe.

[5] 
http://forum.dlang.org/post/sxuiargigylszcurp...@forum.dlang.org


The docs seem to state the contrary, though:

* This struct is not thread-safe in general, it just handles the
* concurrent parts of the GC.


https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d

Bastiaan.


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread 12345swordy via Digitalmars-d
On Tuesday, 5 September 2017 at 15:18:08 UTC, Bastiaan Veelo 
wrote:

On Tuesday, 5 September 2017 at 15:05:09 UTC, 12345swordy wrote:
I am not interested in add features like the other guy did, I 
am interested in fixing the bug regarding thread safety.


Sure, ripping out the extra features and keeping the fixes 
might be what would get this accepted. I didn't review it 
though, so I'm not sure. Anyway, it's your call.


Bastiaan.


I am not planning to use the library that you have link earlier.

Alex


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread Bastiaan Veelo via Digitalmars-d

On Tuesday, 5 September 2017 at 15:05:09 UTC, 12345swordy wrote:
I am not interested in add features like the other guy did, I 
am interested in fixing the bug regarding thread safety.


Sure, ripping out the extra features and keeping the fixes might 
be what would get this accepted. I didn't review it though, so 
I'm not sure. Anyway, it's your call.


Bastiaan.



[Issue 9776] Make raw write mode the default

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9776

--- Comment #13 from Vladimir Panteleev  ---
(In reply to anonymous4 from comment #12)
> Not documented though.

How so? The documentation for stdioOpenmode says "range or string represting
the open mode (with the same semantics as in the C standard library fopen
function)", so the defaults for unspecified options are left to the C standard
library implementation. AIUI, it's not part of the language because on POSIX
binary and text modes behave the same.

--


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread 12345swordy via Digitalmars-d
On Tuesday, 5 September 2017 at 14:55:20 UTC, Bastiaan Veelo 
wrote:

On Tuesday, 5 September 2017 at 13:27:44 UTC, 12345swordy wrote:

[...]


I assume you think that is a long time. It could also mean it 
is stable.


[...]


There is lack of interest regarding event driven programming!?
I am not interested in add features like the other guy did, I am 
interested in fixing the bug regarding thread safety.


Alex


[Issue 5866] std.math.sin(float), std.math.cos(float) to return float

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5866

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |WORKSFORME

--- Comment #6 from RazvanN  ---
The code in the original bug report now compiles successfully on git HEAD
ubuntu 16.04. Closing as WORKSFORME.

--


Re: Templates, D way

2017-09-05 Thread Void-995 via Digitalmars-d

On Tuesday, 5 September 2017 at 14:01:02 UTC, crimaniak wrote:

On Tuesday, 5 September 2017 at 12:54:20 UTC, Void-995 wrote:
Thanks, that definitely working and doesn't require mixin with 
strings. But while waiting for response I've tried another 
thing, and I doubt I would able do to that without string now:

...
int %sCount;
int %sOffset;


Yes, you can make such custom names only with string mixin, as 
I know. Computermatronic gives a good example how to do it 
simple way. I can give two additional advises: as I understand 
offsets as sizes are fixed so think about using unions to 
access sub structures instead of these auto-generated methods; 
I have a long history of using tricks like this starting from 
CHAIN MERGE usage in GW-BASIC to add some functions and for now 
such things are definitely code smell for me. There is always a 
way to do the same, but better.


Using unions? Count and Offset are different 
depending on input data, so the address where they are is varying 
depending on which file I've loaded. Or I didn't get what you 
meant.


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread Bastiaan Veelo via Digitalmars-d

On Tuesday, 5 September 2017 at 13:27:44 UTC, 12345swordy wrote:
On Tuesday, 5 September 2017 at 12:09:55 UTC, Bastiaan Veelo 
wrote:
I don't really know, but there are some alternatives on dub 
that try to improve on std.signals, for example 
https://code.dlang.org/packages/phobosx. Not sure thread 
safety is part of the efforts.


Bastiaan.


The recent updated is from 2015. That's not what I consider to 
be ideal.


I assume you think that is a long time. It could also mean it is 
stable.


All I am saying is before you start looking into fixing the 
existing std.signals, it may be beneficial to look at 
improvements that others have made. The review thread is here 
[1], voting thread is here [2] (it was a tie). It was not 
accepted into phobos due to lack of thorough review and too 
little interest. Some people think std.signals should be 
deprecated and removed altogether, others think it is a shame it 
didn't get in. Positive feedback exists [3, 4].


Maybe you are the right person to brush this implementation up, 
address the critiques, and open a new PR. According to [5] it is 
already thread safe.


Bastiaan.

[1] 
http://forum.dlang.org/post/ujlhznaphepibgtpc...@forum.dlang.org
[2] 
http://forum.dlang.org/post/nhnitsaqijyhnmgcu...@forum.dlang.org

[3] http://forum.dlang.org/post/mkm17h$1ic$5...@digitalmars.com
[4] https://issues.dlang.org/show_bug.cgi?id=17011
[5] 
http://forum.dlang.org/post/sxuiargigylszcurp...@forum.dlang.org


Re: Struct with float members in betterC

2017-09-05 Thread user1234 via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 11:58:18 UTC, Azi Hassan wrote:

Hi,

I'm trying to create the following struct in betterC but I keep 
getting undefined reference errors when I try to compile the 
code :


[...]

I'm aware that betterC is still experimental at this point, but 
I thought I'd ask here to make sure it is indeed a bug before 
filing a bug report. Thanks in advance.


bug +1.


Re: Templates, D way

2017-09-05 Thread John Colvin via Digitalmars-d
On Tuesday, 5 September 2017 at 12:41:45 UTC, Computermatronic 
wrote:

On Tuesday, 5 September 2017 at 12:20:14 UTC, crimaniak wrote:

[...]


I find it very strange that this works, as a non-mixin template 
should not be able to capture the context of where it was 
instantiated. If you take the alias template parameters out it 
behaves how it should (that is an error message saying this is 
not accessible).


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


[Issue 17809] New: "this" is implicitly captured by template with alias parameter

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17809

  Issue ID: 17809
   Summary: "this" is implicitly captured by template with alias
parameter
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: john.loughran.col...@gmail.com

template A()
{
auto A() { return this; }
}

template B(alias a)
{
auto B() { return this; }
}

struct S
{
int a;

// Error: 'this' is only defined in non-static member functions, not A
alias foo0 = A!();

// OK ??? I don't think this should work
alias foo1 = B!(a);
}

--


[Issue 17809] "this" is implicitly captured by template with alias parameter

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17809

John Colvin  changed:

   What|Removed |Added

   Keywords||accepts-invalid

--


Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:56:20 UTC, Andrea Fontana 
wrote:
I used `lines(stdin)` as in 
https://dlang.org/phobos/std_stdio.html#.lines . My source 
code is here


https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 .

Thanks for your support.


I think formattedRead is consuming your string.


Great catch. You're right. Thanks a lot.

`strip()` returns a slice. I use another reference variable to 
save them and it's fine now.


[code]
auto line_st = line.strip();
auto line_st2 = line_st;


writefln("Stripped lined is %s", line_st2); // works fine
[/code]



Re: vibed services stop response after several days of work

2017-09-05 Thread crimaniak via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 13:51:40 UTC, Sönke Ludwig wrote:

The error is most likely caused by issuing two requests to the 
MySQL server from two different tasks on the same connection. 
Usually, mysql-native uses a connection pool to avoid this, but 
that could have been circumvented by accident.


In this case, you have `Data is pending on the connection. Any 
existing ResultRange must be consumed or purged before performing 
any other communication with the server.` usually.




[Issue 12171] Parenthesis-less call fails in static array length context

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12171

--- Comment #3 from RazvanN  ---
Seeing as the platform on which the bug was reported is windows, I modified to
WORKSFORME, if anyone has a windows platform, please try the example and reopen
if necessary.

--


[Issue 12171] Parenthesis-less call fails in static array length context

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12171

RazvanN  changed:

   What|Removed |Added

 Resolution|FIXED   |WORKSFORME

--


[Issue 12171] Parenthesis-less call fails in static array length context

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12171

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #2 from RazvanN  ---
This code successfully compiles on git HEAD ubuntu 16.04. Closing as fixed.

--


Re: Templates, D way

2017-09-05 Thread crimaniak via Digitalmars-d

On Tuesday, 5 September 2017 at 12:54:20 UTC, Void-995 wrote:
Thanks, that definitely working and doesn't require mixin with 
strings. But while waiting for response I've tried another 
thing, and I doubt I would able do to that without string now:

...
int %sCount;
int %sOffset;


Yes, you can make such custom names only with string mixin, as I 
know. Computermatronic gives a good example how to do it simple 
way. I can give two additional advises: as I understand offsets 
as sizes are fixed so think about using unions to access sub 
structures instead of these auto-generated methods; I have a long 
history of using tricks like this starting from CHAIN MERGE usage 
in GW-BASIC to add some functions and for now such things are 
definitely code smell for me. There is always a way to do the 
same, but better.




[Issue 11729] protected toString causes strange error message

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11729

--- Comment #5 from RazvanN  ---
There is nothing wrong with the compiler message. The toString method is not
visible outside the module it was declared so the template constraint
hasToString!(T, Char) fails (as it should). I think we should close this.

--


Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 13:40:18 UTC, Ky-Anh Huynh wrote:

On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote:


Maybe it has something to do with how you read from STDIN. Can 
you show that part of the code to see if I can reproduce the 
issue ?


I used `lines(stdin)` as in 
https://dlang.org/phobos/std_stdio.html#.lines . My source code 
is here


https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 .

Thanks for your support.


I think formattedRead is consuming your string.

Andrea


[Issue 11729] protected toString causes strange error message

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11729

--- Comment #4 from anonymous4  ---
And I think this can't be patched in phobos: formatObject can't work with
protected toString, hence it must be skipped, which results in the generic
template mismatch error.

--


Re: vibed services stop response after several days of work

2017-09-05 Thread Sönke Ludwig via Digitalmars-d-learn

Am 01.09.2017 um 12:31 schrieb Suliman:

On Friday, 1 September 2017 at 08:01:24 UTC, Suliman wrote:

I got same problem on Windows Server 2016 and on Linux Debian 8.5.
I have few very simple backend based on vibed 0.8.1, compiler dmd 
2.075.1.


nginx servise is do port forwarding. Nothing more is used.

After several days of working I am begining to get "502 Bad Gateway" 
error. The service is not down, it's continue to working, but on 
Windows task manager I seen very low memory usage (0.4MB) and on Linux 
I see next: https://snag.gy/ban3jX.jpg (i am not familiar with Linux 
and do not sure if process is alive or not because htop do not show it)


The code is *very* simple https://github.com/bubnenkoff/dlang.ru

Is there any ideas how to diagnostic the problem?


I got error https://paste.ofcode.org/exCL5S2vbp6qhYBqj7v6ez

Is it's issue with libevent?

Does even-loop depend on used OS?




The dpaste shown doesn't seem to match the code in the repository. There 
is a reference to vibe.web.rest and the mysql-native driver, which I 
couldn't find in the dlang.ru source code.


The error is most likely caused by issuing two requests to the MySQL 
server from two different tasks on the same connection. Usually, 
mysql-native uses a connection pool to avoid this, but that could have 
been circumvented by accident.


[Issue 9626] More precise error message in some cases when failed template constraint

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9626

anonymous4  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=11729

--


[Issue 11729] protected toString causes strange error message

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11729

anonymous4  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=9626

--- Comment #3 from anonymous4  ---
Issue 9626 is for compiler diagnostic. But I'm not sure we want to patch this
case by case instead of improving diagnostic in compiler.

--


Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote:


Maybe it has something to do with how you read from STDIN. Can 
you show that part of the code to see if I can reproduce the 
issue ?


I used `lines(stdin)` as in 
https://dlang.org/phobos/std_stdio.html#.lines . My source code 
is here


https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 
.


Thanks for your support.


[Issue 17808] New: VisualD doesn't work if Visual Studio is installed to non-ASCII path

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17808

  Issue ID: 17808
   Summary: VisualD doesn't work if Visual Studio is installed to
non-ASCII path
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: minor
  Priority: P1
 Component: visuald
  Assignee: nob...@puremagic.com
  Reporter: karol.m.stas...@gmail.com

Created attachment 1656
  --> https://issues.dlang.org/attachment.cgi?id=1656=edit
Build script with mangled paths

Windows 10, Polish locale, Visual Studio Community 2015, VisualD 0.45.1.

Visual Studio is installed at D:\Pliki programów (x86)\Microsoft Visual Studio
14.0 

When I run the installer for VisualD, it detects that I have VS2015 installed,
but then it proceeds to install the extension to D:\Pliki program�
(x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions

Note the invalid character.

After the installation, Visual Studio listed the extension on the extension
list, but the extension obviously did not load. I was unable to create any D
projects or change D-related settings.

After I moved the extension manually, it loaded and I could create a new
project, but then it still wouldn't work: 
- running the x86 target displays a console window for a fraction of a second,
shows the following in the output, and does nothing else:

C:\Windows\SysWOW64\kernel32.dll unloaded.
C:\Windows\SysWOW64\dbghelp.dll unloaded.
The thread 0x7a4 has exited with code 0 (0x0).
The thread 0x29c has exited with code 0 (0x0).
The thread 0xf4 has exited with code 0 (0x0).
The program '[2596] ConsoleApp1.exe' has exited with code 0 (0x0).

- as for the x64 target, the build script (x64\Debug\ConsoleApp1.build.cmd)
contains wrong paths (two different ones!) as well, so VS cannot build
anything. I've attached the file.

VS failed to produce any executables.

--


[Issue 11729] protected toString causes strange error message

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11729

anonymous4  changed:

   What|Removed |Added

   Keywords||diagnostic

--- Comment #2 from anonymous4  ---
I suppose something like this:

class A
{
protected override string toString(){ return null; }
}
void f()
{
import std.stdio;
write(new A);
}
std/format.d(3450): Error: template instance
std.format.formatObject!(LockingTextWriter, A, char) does not match template
declaration formatObject(Writer, T, Char)(ref Writer w, ref T val, ref const
FormatSpec!Char f) if (hasToString!(T, Char))

--


Re: Templates, D way

2017-09-05 Thread crimaniak via Digitalmars-d
On Tuesday, 5 September 2017 at 12:41:45 UTC, Computermatronic 
wrote:

I find it very strange that this works, ...
I'm too. :) In any case, it's not a big deal. It's possible to 
modify this template to transfer `this` as the first parameter 
and modify its usage accordingly.





[Issue 4555] Double newlines with std.file.readText

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4555

--- Comment #5 from RazvanN  ---
Since this one was reported originally, I think it would make more sense to
mark 9776 as a duplicate of this one. Either way, the issues reference each
other so I guess anything works.

--


[Issue 9776] Make raw write mode the default

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9776

anonymous4  changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc

--- Comment #11 from anonymous4  ---
*** Issue 4555 has been marked as a duplicate of this issue. ***

--


[Issue 4555] Double newlines with std.file.readText

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4555

anonymous4  changed:

   What|Removed |Added

 Resolution|WONTFIX |DUPLICATE

--- Comment #4 from anonymous4  ---


*** This issue has been marked as a duplicate of issue 9776 ***

--


[Issue 9776] Make raw write mode the default

2017-09-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9776

--- Comment #12 from anonymous4  ---
(In reply to Vladimir Panteleev from comment #8)
> Whether you agree or disagree, everything here works "as designed"

Not documented though.

--


Re: I would like to draw attention regarding std.signals

2017-09-05 Thread 12345swordy via Digitalmars-d
On Tuesday, 5 September 2017 at 12:09:55 UTC, Bastiaan Veelo 
wrote:

On Monday, 4 September 2017 at 23:19:31 UTC, 12345swordy wrote:

The current bug that I like to focus on is the following:
"Not safe for multiple threads operating on the same signals 
or slots. "


However boost.signals2 is thread safe, so I was wondering what 
is currently preventing std.signals from being thread safe? 
How hard is it currently?


I don't really know, but there are some alternatives on dub 
that try to improve on std.signals, for example 
https://code.dlang.org/packages/phobosx. Not sure thread safety 
is part of the efforts.


Bastiaan.


The recent updated is from 2015. That's not what I consider to be 
ideal.


Regardless if the bug were to be simply fixed by using mutex then 
it would have it done so already. This implies that it's more 
difficult then it seems which is why I am asking how hard 
currently.


  1   2   >