Re: Is @live attribute working yet?

2022-04-24 Thread Paolo Invernizzi via Digitalmars-d-learn

On Sunday, 24 April 2022 at 12:21:29 UTC, elfstone wrote:
On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi 
wrote:

On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:

[...]


You need to use the flag `-preview=dip1021`

  test.d(8,30): Error: variable `test.test.p` assigning to 
Owner without disposing of owned value


Weird, it's still not working here. I have tried the flag with 
dub, and dmd.


You are right with 2.099.1, it seems to be included in the 
2.100.0-beta.1 ...


  pinver@Moria test % /Users/pinver/dlang/dmd-2.099.1/osx/bin/dmd 
-preview=dip1021 -c -o- src/test.d
  pinver@Moria test % 
/Users/pinver/dlang/dmd-2.100.0-beta.1/osx/bin/dmd 
-preview=dip1021 -c -o- src/test.d
  src/test.d(8): Error: variable `test.test.p` assigning to Owner 
without disposing of owned value





Re: Is @live attribute working yet?

2022-04-24 Thread Paolo Invernizzi via Digitalmars-d-learn

On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a 
warning.


import std.stdio;
import core.stdc.stdlib;

@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
free(p);
}

void main()
{
test();
writeln("???");
}

Isn't it supposed to trigger an error according to the doc 
(https://dlang.org/spec/ob.html)?


@live void test()
{
auto p = allocate();
p = allocate(); // error: p was not disposed of
release(p);
}


You need to use the flag `-preview=dip1021`

  test.d(8,30): Error: variable `test.test.p` assigning to Owner 
without disposing of owned value


Re: Strong typing and physical units

2020-07-28 Thread Paolo Invernizzi via Digitalmars-d-learn

On Tuesday, 28 July 2020 at 11:04:00 UTC, Cecil Ward wrote:
Of course, in C I used to do something like strong typing with 
an opaque type achieved by using something like typedef struct 
_something {} * type1; and then I had to do casting to get back 
the real type, which was unchecked but it did prevent the user 
from mixing up the types type1 and type2 say as they weren’t 
assignment compatible.


I would really like strong typing to be a built in feature. 
Would anyone else support this?


Once upon a time, typedef was present and backed by the compiler, 
but nowadays you can find it in Phobos [1], but with some quirk 
...


[1] https://dlang.org/phobos/std_typecons.html#.Typedef



Re: D and Async I/O

2020-05-12 Thread Paolo Invernizzi via Digitalmars-d-learn

On Monday, 11 May 2020 at 15:02:59 UTC, bauss wrote:

On Monday, 11 May 2020 at 14:02:54 UTC, Russel Winder wrote:
OK, so I need to create an asynchronous TCP server (not HTTP 
or HTTPS, this is

a real server ;-) ).

I think the normal response is "Use Vibe.d". However, recently 
I see Hunt is an alternative. Has anyone any way of choosing 
between the two?




vibe.d is much more mature than Hunt, that would be my take on 
it.


Also Hunt lacks documentation etc.

I notice that Hunt uses it's own library eschewing all of 
Phobos. Is this an

indicator that Phobos is not suitable for networking activity?


std.socket is terrible, so yes that is an indicator.

You can't even wrap something up fast in it either.

Basically it's low-level while not being low-level at the same 
time. You have to handle __everything__ yourself pretty much.


Have a look also to Martin std.io [1] and Steven iopipes [2], if 
you need something simple.


[1] https://github.com/MartinNowak/io
[2] https://code.dlang.org/packages/iopipe






Re: Pattern matching via switch?

2020-03-17 Thread Paolo Invernizzi via Digitalmars-d-learn
On Sunday, 15 March 2020 at 18:52:01 UTC, Steven Schveighoffer 
wrote:


D doesn't support this natively. The closest you can get is 
something akin to what aliak wrote (you would need to write 
something, not sure if Phobos or some package has implemented 
the feature), or use cascaded if statements:


I've just given a fast look at the thread, so maybe I'm wrong, 
but this [1] should be ok for pattern matching using plain and 
simple Phobos ...


[1] https://dlang.org/phobos/std_variant.html#.visit




Re: Cool name for Dub packages?

2020-03-07 Thread Paolo Invernizzi via Digitalmars-d-learn

On Saturday, 7 March 2020 at 09:31:27 UTC, JN wrote:

Do we have any cool name for Dub packages?

Rust has 'crates'
Crystal has 'shards'
Python has 'wheels'
Ruby has 'gems'


Frankly, I simply hate all that shuffle around names ... it's so 
difficult to understand people when it's referring to them ...we 
already had to remember a gazillion on things, including horrible 
ubuntu names instead of simple numbers! :-)


Packages are ... well packages!

:-P

/P


Re: Meta question - what about moving the D - Learn Forum to a seperate StackExchange platform?

2019-10-18 Thread Paolo Invernizzi via Digitalmars-d-learn

On Friday, 18 October 2019 at 11:45:33 UTC, Seb wrote:
On Friday, 18 October 2019 at 10:55:59 UTC, Martin Tschierschke 
wrote:

[...]


In the state of the D survey, there were more people in favor 
of StackOverflow than D.learn, but to be fair the majority 
voted for "I don't care"


https://rawgit.com/wilzbach/state-of-d/master/report.html


Maybe it's possible to simply add an up/down vote functionality 
to the forum only, just keeping the compatibility with the 
newsgroup ...


It's a win/win solution!


Re: Vibe.d Error

2019-10-18 Thread Paolo Invernizzi via Digitalmars-d-learn

On Friday, 18 October 2019 at 08:06:30 UTC, Vino wrote:

On Thursday, 17 October 2019 at 19:02:14 UTC, Vino wrote:

[...]


Hi Andre,

  I tried install vibe.d in SUSE linux 12 SP2 and facing the 
below error, tried the options as per the link 
https://github.com/vibe-d/vibe.d/issues/1748, still no luck and 
the lib's are installed in the server


[...]


The same here on macOS Catilina ... I'm too interested in a 
solution for that


Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)

2019-10-14 Thread Paolo Invernizzi via Digitalmars-d-learn

On Monday, 14 October 2019 at 05:36:44 UTC, Joel wrote:
On Friday, 11 October 2019 at 11:38:27 UTC, Jacob Carlborg 
wrote:

[...]


I get this since Catalina:

Joel-Computer:VacSpace joelchristensen$ dub
Failed to invoke the compiler dmd to determine the build 
platform: dyld: lazy symbol binding failed: Symbol not found: 
_dyld_enumerate_tlv_storage

  Referenced from: /usr/local/bin/dmd
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _dyld_enumerate_tlv_storage
  Referenced from: /usr/local/bin/dmd
  Expected in: /usr/lib/libSystem.B.dylib


Joel-Computer:VacSpace joelchristensen$

I use Home Brew (brew upgrade dmd, and brew upgrade dub)
Brew is only up to 2.087.1 at the moment - John Colvin seems to 
be the man that mantains dmd with brew.


I confirm that DMD downloaded from the official script works like 
charms on Catilina. You can rely on that right now ...




Re: ld errors in osx Catalina

2019-10-09 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 9 October 2019 at 16:08:41 UTC, rikki cattermole 
wrote:

On 09/10/2019 11:33 PM, David Briant wrote:

[...]


D as a native language links against libc, so using the system 
c compiler as the linker is a viable method to prevent having 
to look things up.


Perhaps try ldc? That uses LLVM so may be better on OSX.

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

Also those versions on homebrew look to be at least one version 
out of date.


If ldc on homebrew doesn't work, you should try the versions on 
the main site (which has dmg's) https://dlang.org/download.html


I confirm that ldc-1.18.0-beta2 works fine on mine Catalina, 
downloaded and activated with the official install script.


/Paolo


Re: D on ARM laptops?

2019-07-04 Thread Paolo Invernizzi via Digitalmars-d-learn

On Thursday, 4 July 2019 at 01:01:03 UTC, Nicholas Wilson wrote:

On Wednesday, 3 July 2019 at 20:49:20 UTC, JN wrote:
Does anyone know if and how well D works on ARM laptops (such 
as Chromebooks and similar)?


For example this one https://www.pine64.org/pinebook/ . Can it 
compile D? Obviously DMD is out because it doesn't have ARM 
builds. Not sure about GDC. How about LDC?


Haven't tried on laptops, but I can't imagine it would be too 
different to RasPi which LDC worked fine on.


We are using LDC on Jetson boards and it's working fine ...


Re: I really don't understand DUB

2019-04-15 Thread Paolo Invernizzi via Digitalmars-d-learn

On Sunday, 14 April 2019 at 20:51:10 UTC, Andre Pany wrote:

On Sunday, 14 April 2019 at 19:46:41 UTC, Ron Tarrant wrote:

[...]


You are totally right, it should be more intuitive how to use 
dub.


As far as I know if you do not specify in dub.json/dub.sdl what 
type of package you have (executable/library) dub make a guess. 
Is there an app.d it will default the targetType "executable", 
if not it will default the targetType "library".


To solve your specify the targetType explicitly in your dub.sdl 
file.


https://dub.pm/package-format-json.html#target-types

Kind regards
Andre


The Zen of Python, rule number two: explicit is better than 
implicit ...


I guess that just killing all that educated dub guess will turn 
dub into a much easier tool to grasp.


- P


Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Paolo Invernizzi via Digitalmars-d-learn
There's a rational behind the fact that there's not a 'shared' 
version of notify/wait method in Condition?


Thanks,
Paolo


Re: Convert output range to input range

2018-03-18 Thread Paolo Invernizzi via Digitalmars-d-learn

On Saturday, 17 March 2018 at 17:51:50 UTC, John Chapman wrote:

I'm trying to replace the old std.streams in my app with 
ranges. I'm interfacing with a networking library to which I 
supply a callback that when invoked provides the requested 
data. I write that data to an output range, but later on I need 
to read that data from the range too - which of course you 
can't do.


So what I'm looking for is the range-based equivalent of a 
MemoryStream.


I suggest you to give a fast read to this [1], reactive streams.
The D implementation [2] uses as a base an output range.

They are pretty good in handling time based series event, it this 
is your usecase...


[1] http://reactivex.io
[2] https://github.com/lempiji/rx

/Paolo


Re: Error: out of memory

2018-01-10 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 19:21:21 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 10 January 2018 at 19:15:00 UTC, Anonymouse wrote:

I don't see a 64 bit release though... might have to try to 
build it yourself from source using visual studio.


It's a long time I don't understand why there's not a 64bit 
distribution...

(along with a debug build of rt/phobos, btw)

/Paolo


Re: private keyword dont appear to do anything

2017-11-04 Thread Paolo Invernizzi via Digitalmars-d-learn

On Friday, 3 November 2017 at 23:32:52 UTC, H. S. Teoh wrote:

[...]


What's wrong with the introduction of another visibility 
attribute that behave like the C++ private?


Just curious...

---
Paolo



Re: Is it possible to specify the address returned by the address of operator?

2017-09-30 Thread Paolo Invernizzi via Digitalmars-d-learn

On Friday, 29 September 2017 at 22:15:44 UTC, Mengu wrote:

On Friday, 29 September 2017 at 02:34:08 UTC, DreadKyller wrote:

[...]


+1 for forum issue.


+1 please...


Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn

On Monday, 3 July 2017 at 17:30:51 UTC, Ali Çehreli wrote:

hOn 07/03/2017 10:13 AM, Paolo Invernizzi wrote:

> [...]
struct with
> [...]

I had difficulty understanding the requirements. For example, 
it's not clear whether you want the literal "first" and 
"second" names.


[...]


Thanks Ali,

I'm doing something similar, with inout ref in the b function: 
I'll stick with that.

Thanks again to all!

/Paolo


Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn

On Monday, 3 July 2017 at 16:41:51 UTC, vit wrote:

On Monday, 3 July 2017 at 13:53:45 UTC, Paolo Invernizzi wrote:

[...]


//https://dpaste.dzfl.pl/d59469c264b2

import std.algorithm : map, copy, equal;
import std.range : iota;

struct Foo {
int[3] a;
string[2] b;
}

ref T first(R : T[], T)(ref R x,){return x[0];}
ref T second(R : T[], T)(ref R x){return x[1];}

void worksOnA(R : int[N], size_t N)(ref R r) {
iota(1, N+1)
.map!(x => cast(int)x*2)
.copy(r[]);
}
void worksOnB(string[] r) { }


void main(){
auto foo = Foo();

foo.a.first = 1;
foo.a.second = 2;
assert(foo.a.first == 1);
assert(foo.a.second == 2);


foo.b.second = "test";
assert(foo.b.first == "");
assert(foo.b.second == "test");

foo.a.worksOnA();
assert(foo.a[].equal([2, 4, 6]));

}


Thanks for your solution, Vic!

It's not exactly the same, as first and second should be struct 
with partial fields from Foo, of different types.


/Paolo


Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn

I've struct like that:

struct Foo {
int a_1; float a_2; string a_3;
string b_1; double b_2;
}

I would like to transparently access that like:

foo.a.first
foo.b.second = "baz";

with an helper like:

auto a(...) { ... }
auto b(...) { ... }

that can be used also in functions that are expecting it:

void worksOnA(  ) { }
void worksOnB(  ) { }

auto foo = Foo( ... )
foo.a.worksOnA();
foo.b.worksOnB();

But I'm struggling in finding a good way to do it...
Suggestions?

Thanks!
/Paolo




Re: The reason for SIGSEGV function pointer problem

2017-06-07 Thread Paolo Invernizzi via Digitalmars-d-learn

On Wednesday, 7 June 2017 at 16:50:26 UTC, Russel Winder wrote:

In the constructor of an object to abstract the result of a 
call to the C library code, the parameter is:


check_frontend_t* cf



You should remove the pointer here...

/Paolo


Re: D and GDB

2017-06-04 Thread Paolo Invernizzi via Digitalmars-d-learn

On Sunday, 4 June 2017 at 19:24:17 UTC, Basile B. wrote:

On Sunday, 4 June 2017 at 18:13:41 UTC, Russel Winder wrote:

[...]


you have to pipe the output to ddemangle. Personally i don't 
know how to do this by hand since my IDE does the task 
automatically 
(http://bbasile.github.io/Coedit/widgets_gdb_commander).


Also i suppose you compiled with -g -gs ?


at `libdvbv5.d:140` you are calling the native 
`dvb_scan_transponder` in `libdvbv5.so` that's segfaulting...


Try to just log the arguments values you are using there...

/Paolo


Re: What is PostgreSQL driver is most stable?

2017-03-15 Thread Paolo Invernizzi via Digitalmars-d-learn

On Wednesday, 15 March 2017 at 09:18:16 UTC, Suliman wrote:

On Tuesday, 14 March 2017 at 13:36:04 UTC, Daniel Kozak wrote:

Dne 14.3.2017 v 14:21 Daniel Kozak napsal(a):

Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn 
napsal(a):


I need to develop App that should work on Linux and Windows. 
It need PostgreSQL driver. I tried Vadim's ddbc for 
PostgreSQL but it's fail on x64 version of PostgreSQL and 
possible will not on x64 PG on Linux (I can't test it now).


Could anybody advice me good driver without problems? I seen 
some pg-wrapers on code.dlang.ru, but do not have test all 
of them.

ddbc works fine for me

s/ddbc/ddb/


Am I rightn understand that DBRow! is allow to get only single 
row, and if I need array of rows I need to use foreach? If I am 
wrong could you provide an example please.


The retrieval of records is done via the execution of a 
(prepared) sql query, that returns a range object (PGResultSet), 
and the element of that range is the DBRow, in one of its form.


So, basically, the elements are retrieved on demand while you 
popFront that range, leveraging what the PostgreSQL stream 
protocol provide.


---
Paolo


Re: What is PostgreSQL driver is most stable?

2017-03-15 Thread Paolo Invernizzi via Digitalmars-d-learn

On Wednesday, 15 March 2017 at 08:50:11 UTC, Dsby wrote:
On Tuesday, 14 March 2017 at 16:24:31 UTC, Paolo Invernizzi 
wrote:

On Tuesday, 14 March 2017 at 13:32:31 UTC, Suliman wrote:
On Tuesday, 14 March 2017 at 13:21:39 UTC, Paolo Invernizzi 
wrote:

On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote:

[...]


I'm using ddb [1], a full-D implementation of the PostgreSQL 
protocol. Not everything it's in place, but it does its 
works, and the codebase is pretty simple, so it's not 
difficult to contribute if you need to add some feature 
that's missing for your use case.


[1] https://github.com/pszturmaj/ddb

---
Paolo


Does it work fine on Linux with x64 Postgres?


Yes

---
Paolo


We used dpq.
http://code.dlang.org/packages/dpq


I'm curious: ddb does not support yet arbitrary precision numbers 
[1], does dpq support them?


Thanks,
Paolo

[1] 
https://www.postgresql.org/docs/9.5/static/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL


Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Paolo Invernizzi via Digitalmars-d-learn

On Tuesday, 14 March 2017 at 13:32:31 UTC, Suliman wrote:
On Tuesday, 14 March 2017 at 13:21:39 UTC, Paolo Invernizzi 
wrote:

On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote:

[...]


I'm using ddb [1], a full-D implementation of the PostgreSQL 
protocol. Not everything it's in place, but it does its works, 
and the codebase is pretty simple, so it's not difficult to 
contribute if you need to add some feature that's missing for 
your use case.


[1] https://github.com/pszturmaj/ddb

---
Paolo


Does it work fine on Linux with x64 Postgres?


Yes

---
Paolo


Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Paolo Invernizzi via Digitalmars-d-learn

On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote:
I need to develop App that should work on Linux and Windows. It 
need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but 
it's fail on x64 version of PostgreSQL and possible will not on 
x64 PG on Linux (I can't test it now).


Could anybody advice me good driver without problems? I seen 
some pg-wrapers on code.dlang.ru, but do not have test all of 
them.


I'm using ddb [1], a full-D implementation of the PostgreSQL 
protocol. Not everything it's in place, but it does its works, 
and the codebase is pretty simple, so it's not difficult to 
contribute if you need to add some feature that's missing for 
your use case.


[1] https://github.com/pszturmaj/ddb

---
Paolo


Re: Natural sorted list of files

2017-02-06 Thread Paolo Invernizzi via Digitalmars-d-learn

On Monday, 6 February 2017 at 18:57:17 UTC, Ali Çehreli wrote:

On 02/06/2017 08:43 AM, Dmitry wrote:


Found this https://rosettacode.org/wiki/Natural_sorting#D
but there is error on ".groupBy!isDigit" (Error: no property 
'groupBy'

for type 'string').


I think  it's now std.algorithm.chunkBy. Please fix Rosetta 
Code as well. Thanks! :)


Ali


I'm missing Bearophile...
(and btw, Kenji)

/P


Re: [Semi-OT] I don't want to leave this language!

2016-12-08 Thread Paolo Invernizzi via Digitalmars-d-learn

On Thursday, 8 December 2016 at 11:09:12 UTC, ketmar wrote:

what can be done, tho, is article (or series of articles) 
describing what exactly druntime is, how it is compared to libc 
and libc++, why it doesn't hurt at all, how to do "bare metal" 
with custom runtime, why GC is handy (and how to limit GC 
impact if that is necessary), and so on. that is something D 
Foundation should do, i believe.


+1

/Paolo




Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-28 Thread Paolo Invernizzi via Digitalmars-d-learn

On Sunday, 27 November 2016 at 22:25:51 UTC, John Colvin wrote:
On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi 
wrote:

This is stated in documentation [1]:

immutable long[string] aa = [
  "foo": 5,
  "bar": 10,
  "baz": 2000
];

unittest
{
assert(aa["foo"] == 5);
assert(aa["bar"] == 10);
assert(aa["baz"] == 2000);
}

But results to:

   Error: non-constant expression ["foo":5L, "bar":10L, 
"baz":2000L]


Known bug?
If yes, Is there the need to emend the documentation, till the 
bug is open?

---
/Paolo


Known bug.

If you need a workaround, initialising the variable at 
load-time with `static this` should help in some cases.


Thank Joan,

The point is that I was trying to avoid some cycle between 
modules, detected by 2.072.
This bug leads to pollution in the use of static this only to 
workaround the limitation...


--
Paolo



Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread Paolo Invernizzi via Digitalmars-d-learn
On Saturday, 26 November 2016 at 19:57:21 UTC, Adam D. Ruppe 
wrote:
On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi 
wrote:

This is stated in documentation [1]:


What's the link?

This is a known limitation, it has never worked. The docs 
should reflect that, though some day, it might start working.


Sorry, I forgot to past it in the previous post: here it is.

https://dlang.org/spec/hash-map.html#static_initialization

--
Paolo


non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-26 Thread Paolo Invernizzi via Digitalmars-d-learn

This is stated in documentation [1]:

immutable long[string] aa = [
  "foo": 5,
  "bar": 10,
  "baz": 2000
];

unittest
{
assert(aa["foo"] == 5);
assert(aa["bar"] == 10);
assert(aa["baz"] == 2000);
}

But results to:

   Error: non-constant expression ["foo":5L, "bar":10L, 
"baz":2000L]


Known bug?
If yes, Is there the need to emend the documentation, till the 
bug is open?

---
/Paolo


Enumerate CTFE bug...

2016-11-21 Thread Paolo Invernizzi via Digitalmars-d-learn

I'm not sure if it's the same as #15064 bug:

import std.array, std.range, std.algorithm;

  immutable static foo = ["a", "b", "c"];
  auto bar(R)(R r)
  {
  string s = r[1];
  return s;
  }
  immutable static res = foo.enumerate.map!bar().array;

std/typecons.d(526): Error: reinterpreting cast from 
inout(ulong)* to inout(Tuple!(ulong, immutable(string)))* is not 
supported in CTFE

bug.d(9):called from here: r._Tuple_super()
std/algorithm/iteration.d(593):called from here: 
bar(this._input.front())

std/array.d(105):called from here: __r2091.front()
bug.d(15):called from here: array(map(enumerate(foo, 
0LU)))


---
Paolo


Re: test for equality of the content of two AA

2016-10-30 Thread Paolo Invernizzi via Digitalmars-d-learn

On Wednesday, 26 October 2016 at 19:03:45 UTC, Ali Çehreli wrote:

On 10/26/2016 08:03 AM, Paolo Invernizzi wrote:

[...]


If you mean D's AAs, then that is already implemented:

  void main() {
auto a = [ "hello" : 1, "world" : 2 ];
auto b = [ "world" : 2, "hello" : 1 ];
assert(a == b);
}

[...]


Thank you Ali, very exhaustive!


test for equality of the content of two AA

2016-10-26 Thread Paolo Invernizzi via Digitalmars-d-learn
As the subject states, what is the best idiomatic way for doing 
that?


Thanks in advance
/Paolo


Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread Paolo Invernizzi via Digitalmars-d-learn

On Wednesday, 26 October 2016 at 08:42:02 UTC, dm wrote:

Hi. I tried code below:

import std.concurrency;
import std.stdio;

void func()
{
throw new Exception("I'm an exception");
}

void main()
{
auto tID = spawn();
foreach(line; stdin.byLine)
send(tID, "");
}

I expect my application will die immediatly, but main thread 
still running and I don't see any errors.

I want to kill all my threads if it is unhandled exception.
How can I do that?


You need to link the threads, and at least one receive after the 
child thread has implicitly sent the exception to the main thread:


import std.concurrency;
import std.stdio;

---
void func()
{
throw new Exception("I'm an exception");
}

void main()
{
auto tID = spawnLinked();
receive((int dummy){});
}

---
/Paolo


Re: Reinstalled Mac

2016-09-29 Thread Paolo Invernizzi via Digitalmars-d-learn
On Thursday, 29 September 2016 at 11:43:32 UTC, Jacob Carlborg 
wrote:


Cool, what if I want to use different versions in different 
sessions, i.e. I have two tabs open in my terminal?


Ummm...
All the installed stuff is pretty well organised inside 
`/usr/local`, so this works...


---
hw0062:~ pinver$ /usr/local/Cellar/dmd/2.071.2/bin/dmd --version
DMD64 D Compiler v2.071.2
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
hw0062:~ pinver$ /usr/local/Cellar/dmd/2.071./bin/dmd --version
2.071.0_1/ 2.071.1/   2.071.2/
hw0062:~ pinver$ /usr/local/Cellar/dmd/2.071.0_1/bin/dmd --version
DMD64 D Compiler v2.071.0
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
---

/Paolo



Re: Reinstalled Mac

2016-09-29 Thread Paolo Invernizzi via Digitalmars-d-learn
On Thursday, 29 September 2016 at 06:24:08 UTC, Jacob Carlborg 
wrote:

On 2016-09-29 03:43, David Nadlinger wrote:
I've had good experiences using Homebrew, although you 
sometimes have to wait

a day or three for a new release to appear. — David


DVM doesn't have that problem :). How easy is it to have 
multiple versions of DMD installed using Homebrew?


It seems simple:

---
hw0062:~ pinver$ brew info dmd
dmd: stable 2.071.2 (bottled), HEAD
D programming language compiler for OS X
https://dlang.org/
/usr/local/Cellar/dmd/2.071.0_1 (561 files, 65.0M)
  Poured from bottle on 2016-06-23 at 14:51:10
/usr/local/Cellar/dmd/2.071.1 (561 files, 65.0M)
  Poured from bottle on 2016-07-06 at 09:48:40
/usr/local/Cellar/dmd/2.071.2 (561 files, 65.0M) *
  Poured from bottle on 2016-09-26 at 11:50:45
From: 
https://github.com/Homebrew/homebrew-core/blob/master/Formula/dmd.rb


hw0062:~ pinver$ dmd --version
DMD64 D Compiler v2.071.2
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright

hw0062:~ pinver$ brew switch dmd 2.071.0_1
Cleaning /usr/local/Cellar/dmd/2.071.0_1
Cleaning /usr/local/Cellar/dmd/2.071.1
Cleaning /usr/local/Cellar/dmd/2.071.2
13 links created for /usr/local/Cellar/dmd/2.071.0_1

hw0062:~ pinver$ dmd --version
DMD64 D Compiler v2.071.0
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
---

/Paolo



Re: Experience report on installing dmd 2.066.1 on OSX

2014-11-13 Thread Paolo Invernizzi via Digitalmars-d-learn

On Thursday, 13 November 2014 at 05:57:49 UTC, Joakim wrote:
On Wednesday, 12 November 2014 at 22:38:56 UTC, Ali Çehreli 
wrote:
A friend of mine installed dmd on OSX and recorded his 
experiences:


 http://cap-lore.com/Languages/D/Install.html

I wonder why he had to do manual work like running xattr. Is 
that expected on OSX?


Looks like they're now requiring that apps be signed with the 
developer's account, which I'm guessing the dmd dmg isn't:


http://stackoverflow.com/questions/24176378/why-my-dmg-is-not-getting-opened-without-asking-security-popup



Downloading the zip is still the most simple and easy way, IMHO...
Not a single problem on 10.10...
---
Paolo


Re: Dart bindings for D?

2014-10-30 Thread Paolo Invernizzi via Digitalmars-d-learn
On Thursday, 30 October 2014 at 06:57:23 UTC, Ola Fosheim Grøstad 
wrote:
There are also scripting frameworks that let you write portable 
code for web and mobile platforms, but they tend to be geared 
towards a special type of application.


E.g.
http://www.tidesdk.org/
http://cordova.apache.org/
http://get.adobe.com/air/


At work we are using Meteor [1] for everything related to the web 
products, and it's a VERY successful experience: easy to use, 
easy to deploy, incredible fast development timings.


Right now you can also target Android/iOS, so actually you can 
manage everything with just plain JS.


It turned to 1.0 release just yesterday, it's well funded I've 
bet it should be a long-runner framework.

Warmly suggested.

---
/Paolo

[1] http://www.meteor.com



Re: Why do some language-defined attributes have @ and some not?

2014-10-24 Thread Paolo Invernizzi via Digitalmars-d-learn

On Friday, 24 October 2014 at 00:37:26 UTC, Mike Parker wrote:


There are people out there using D who do not participate in 
the newsgroups. Walter has told us before that he gets emails 
from companies using D in production. He has to deal with 
complaints about code breakage that we aren't going to see here 
in the NG. Just keep in mind that no matter how many of us here 
agree on a breaking change, we are not the entirety of the D 
user base. And it has nothing to do with Reddit.


I think that Walter talked about emails complaining about silent 
breakage or regressions, and that's a totally different matter.


To be honest, I only remember that he talked about one single 
case, but maybe I'm wrong.

And I don't remember any complain about code deprecations.
---
/Paolo




Re: Why do some language-defined attributes have @ and some not?

2014-10-22 Thread Paolo Invernizzi via Digitalmars-d-learn
On Thursday, 23 October 2014 at 02:22:41 UTC, Jonathan M Davis 
wrote:
On Thursday, 23 October 2014 at 00:59:26 UTC, Shriramana Sharma 
via Digitalmars-d-learn wrote:


LOL. I understand the sentiment, but it's a waste of time.


Jonathan,

I agree It's impossible to debate such thing with Walter / Andrej 
right now, but I don't think It's a waste of time: every explicit 
and accountable opinion about that is a little stone to weigh in 
the balance.


---
/Paolo