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

2023-10-05 Thread angel via Digitalmars-d-announce
I think if `class` is a reference type, it should've been 
explicit:

```sh
class C {
...
}

auto obj = new C();

void func(ref C obj)
{
...
}

```

I don't mind if it does not compile without the `ref`, but it 
should be on the table - WYSIWYG.


Re: Destroy All Memory Corruption

2021-04-22 Thread angel via Digitalmars-d-announce

On Thursday, 22 April 2021 at 13:08:39 UTC, matheus wrote:

On Thursday, 22 April 2021 at 01:31:09 UTC, Ali Çehreli wrote:

On 4/19/21 6:12 PM, Walter Bright wrote:
I'll be doing a reprise of my DConf 2020 talk on Destroy All 
Memory Corruption on April 21, 2021 at 7PM PST.


https://nwcpp.org/

Except this time it'll be live, not prerecorded.

All are welcome!


This is happening in half an hour. It requires MS Teams, which 
requires a MS (or Skype) account.


Ali


Just a pity that in this day and age with all the methods/ways 
available to stream a video they use such platform.


This restrains people like myself to participate/watch, and I 
believe much more.


Please when doing such thing, have a backup strategy that 
people can watch on any browser without account or installing 
anything.


Matheus.


MS Teams works fine on Linux.
And I'm actually not sure you would need an MS account, and even 
if you needed - it's free, and doesn't require you install any MS 
products.


Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-06 Thread angel via Digitalmars-d-announce

On Wednesday, 6 January 2021 at 09:24:28 UTC, Mike Parker wrote:


The Feedback Thread is here:
https://forum.dlang.org/post/qglydztoqxhhcurvb...@forum.dlang.org


Why not "int[auto] arr = [1, 2, 3]" ?
IMHO auto keyword is less ambiguous than $.


Re: DIP 1030-- Named Arguments--Formal Assessment

2020-09-17 Thread angel via Digitalmars-d-announce

On Thursday, 17 September 2020 at 12:58:06 UTC, Mike Parker wrote:

DIP 1030, "Named Arguments", has been accepted.



I would really want to see tuples ...


Re: Mimicking a shell

2019-12-29 Thread angel via Digitalmars-d-learn

On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote:

Hi,

Is there a way to forward all input and output from a shell? 
This implies that e.g. pressing the left arrow on the keyboard 
is immediately being forwarded to the shell and that the output 
from a shell would be *exactly* the same as output from my D 
program (that would include the prompt and VGA colouring).


Kind regards,
Jan


IMHO, this is kinda what you need:
https://github.com/greenduck/shell-tunnel/blob/master/shell-tunnel.c

Sorry, this code is in C, but converting it to D would be fairly 
straight forward.


Re: What is the point of a synchronized lock on a single return statement?

2019-11-25 Thread angel via Digitalmars-d-learn
On Monday, 25 November 2019 at 08:22:17 UTC, Andrej Mitrovic 
wrote:
From: 
https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8c03/std/concurrency.d#L1913-L1916:


-
///
final @property bool isClosed() @safe @nogc pure
{
synchronized (m_lock)
{
return m_closed;
}
}
-

I don't understand the purpose of this lock. The lock will be 
released as soon as the function returns, and it returns a copy 
of a boolean anyway. Am I missing something here?


I think this code can be rewritten as
---
final @property bool isClosed() @safe @nogc pure
{
bool ret;

synchronized (m_lock)
{
ret = m_closed;
}

return ret;
}
---

Normally, if the memory location of m_closed is aligned, the 
assignment to 'ret' should be atomic, however if you cannot make 
assumptions about alignment, the access should be protected.


Re: The Future of the GtkDcoding Blog

2019-11-21 Thread angel via Digitalmars-d-announce

On Tuesday, 19 November 2019 at 19:37:41 UTC, Ron Tarrant wrote:
In 2006, I started a blog on PHP-GTK 2.x that ran for 40 posts 
before the blog site I was using closed its door. By then, I 
was caught up in writing Corkboard, the first full-featured 
application I'd written for my own amusement in nearly 20 
years, and so I just let it slip away.


I think you should set up a "Donate" page on your site, so that 
an occasional visitor can say thank you.




Re: A tutorial teaching the basics about multimedia with the arsd library

2019-06-30 Thread angel via Digitalmars-d-announce

On Sunday, 30 June 2019 at 23:46:27 UTC, Murilo wrote:
Hi everyone, I am writing a tutorial teaching the basics about 
multimedia programming using the arsd library. This is a 
library all D programmers should have since it is very useful 
and easy. In this tutorial I will teach in a fun and easy way 
how to use it for GUIs, image displays, games, etc...


Here is the GitHub link: 
https://github.com/MuriloMir/arsd_multimedia_tutorial
And please join the official facebook Dlang group: 
https://www.facebook.com/groups/ProgrammingInD/


Very nice, thank you !
As has been pointed out by others, it would be great if code 
snippets could've been copyable.


Re: gtkDcoding Facelift

2019-06-23 Thread angel via Digitalmars-d-learn

On Sunday, 23 June 2019 at 10:55:52 UTC, Ron Tarrant wrote:
Stage 1 is now complete. Blog entries are color-associated in 
an effort to make things more visual. Each topic also has its 
own avatar. Points to anyone who can figure out why each avatar 
is associated with its topic.


https://gtkdcoding.com/


Great work,
thank you !


Re: Started a neat 3D model project of D's mascot in Paint3D

2019-06-04 Thread angel via Digitalmars-d-announce

On Tuesday, 4 June 2019 at 12:23:27 UTC, Aurélien Plazzotta wrote:

On Tuesday, 4 June 2019 at 01:54:28 UTC, Kaylan Tussey wrote:

I hope someone is better in paint3d than I am!

https://github.com/KaylanTussey/3DD


Very nice and thanks!
Perhaps you could add a C++ corpse being trampled by D guy, 
destroying the "++" letters, then the D hero keeps jumping on 
the C corpse and erase him as well to demonstrate D is trying 
to compete with both C++ and C.


My two cents anyway :)


Don't be cruel !


Re: DConf 2019 Livestream

2019-05-08 Thread angel via Digitalmars-d-announce

On Wednesday, 8 May 2019 at 08:00:15 UTC, Andrej Mitrovic wrote:

On Wednesday, 8 May 2019 at 07:57:40 UTC, Mike Parker wrote:
The venue uses WebEx for livestreaming. All the information is 
available in this PDF:


https://drive.google.com/open?id=1yekllbfOmxHqJNuuWIVeP9vNeROmfp1I


"When joining: Please connect using Internet Explorer, not 
Google Chrome or another web

browser."

You guys can't be serious, you're using WebEx?



Funny as it is, it actually works fine on Ubuntu/Firefox.



Re: Singleton in Action?

2019-02-02 Thread angel via Digitalmars-d-learn

On Saturday, 2 February 2019 at 19:23:58 UTC, Ron Tarrant wrote:
Thanks for the replies, fellow programmers. (generic, unisex, 
PC, and all-encompassing)


If I could trouble someone for a complete working example so I 
have something to study, that would be excellent.



I think that's what you really need:
[1] https://davesdprogramming.wordpress.com/
[2] https://www.youtube.com/watch?v=ZHmIAdlNtiM



Re: Reverse and sort array elements

2018-12-18 Thread angel via Digitalmars-d-learn

On Tuesday, 18 December 2018 at 12:07:37 UTC, Andrey wrote:

Hi,
Have array:

enum array = ["qwerty", "a", "baz"];

Need to reverse and sort array elements to get this result:

[a, ytrewq, zab]

Did this:

enum result = array.map!(value => value.retro()).sort();

Got:
Error: template std.algorithm.sorting.sort cannot deduce 
function from argument types !()(MapResult!(__lambda1, 
string[])), candidates are:
/usr/include/dmd/phobos/std/algorithm/sorting.d(1849,1):
std.algorithm.sorting.sort(alias less = "a < b", SwapStrategy 
ss = SwapStrategy.unstable, Range)(Range r) if ((ss == 
SwapStrategy.unstable && (hasSwappableElements!Range || 
hasAssignableElements!Range) || ss != SwapStrategy.unstable && 
hasAssignableElements!Range) && isRandomAccessRange!Range && 
hasSlicing!Range && hasLength!Range)


How to solve the problem?


Did you try this ?

  import std.stdio;
  import std.algorithm;
  import std.range;
  import std.conv;

  void main()
  {
enum input = ["qwerty", "a", "baz"];
  	enum output = input.map!(value => 
value.retro().to!string()).array.sort();


writeln(input);
writeln(output);
  }



Re: allMembers broke for __

2018-06-17 Thread angel via Digitalmars-d

On Sunday, 17 June 2018 at 02:25:59 UTC, Adam D. Ruppe wrote:

On Sunday, 17 June 2018 at 01:02:17 UTC, DigitalDesigns wrote:
If this was a sane language constraint then any identifiers 
starting with __ that were not reserved would at least give a 
warning but particularly give an error! Not fail silently and 
break code in ways that cannot be determined otherwise.


It is undefined behavior to use ANY identifier with __ leading. 
C works exactly the same way.


I'm sure there are naive C programmers who use "__" prefix for 
their own purposes.


Maybe it would be cleaner to create more special syntax for 
"internal" functions/methods, e.g require some kind of UDA in 
addition to the "__" prefix:


@Dinternal
void __someMethod() ...

Then disallow "__" prefix altogether (with the exception above).

Now, if someone still uses both the UDA and the prefix, he really 
cannot say he didn't know.




Re: Submit D Machine Learning libraries

2018-01-10 Thread angel via Digitalmars-d

It is funny, there is 'DLib' under C++.

On Tuesday, 9 January 2018 at 20:39:25 UTC, aberba wrote:

On Tuesday, 9 January 2018 at 19:46:00 UTC, aberba wrote:
[1] is a curated list of machine learning libraries for 
several programming languages (no D library in list). I don't 
know much about ML that much to suggest any of those in the 
Dub registry. I know we have Vectorflow from Netflix 
(http://code.dlang.org/packages/vectorflow), D computer Vision 
(https://code.dlang.org/packages/dcv), and all these MIR 
related libs (http://code.dlang.org/search?q=mir)


Please make pull request for D at 
https://github.com/josephmisiti/awesome-machine-learning


[1] https://github.com/josephmisiti/awesome-machine-learning


Might win some people over.


Also http://code.dlang.org/packages/dopt (A numerical 
optimisation and deep learning framework)




Re: ArithEval v0.5.0 released

2018-01-07 Thread angel via Digitalmars-d-announce

On Sunday, 7 January 2018 at 20:41:57 UTC, Dechcaudron wrote:
Updating this library I coded more than a year ago, so that I 
could use it as an optional dependency of the coming up dli 
library.


It allows the runtime evaluation of simple math expressions 
like `1 + 2 * 3` or `1 ^ foo`, with foo being given values at 
run time.


It was never announced in this forum, so it is likely most of 
you never heard of it. The README pretty much sums up all there 
is to see, but do let me know if you guys have any specific 
doubt. Feedback is greatly appreciated.


Very cool !


Re: What do you want to see for a mature DLang?

2017-12-29 Thread angel via Digitalmars-d

Built-in tuples:

{val1, val2} = func();


On Friday, 29 December 2017 at 07:53:51 UTC, IM wrote:

I will start:

   -- Better compiler errors, better compiler errors, better 
compiler errors.



I really wish that the compiler errors could receive some 
refinement. Mostly it feels like some error text just being 
thrown at me. It needs to be better formatted, more helpful, 
with suggestions about how to fix (if possible).


To illustrate my point:

- See the compile errors I've just encountered with DMD: 
https://cdn.pbrd.co/images/H0q609l.png


- Now compare that with an error produced by rustc:
https://cdn.pbrd.co/images/H0q6bLi.png


Simple things like these make a big difference. D Lang has been 
around for a long while now, and hence signs of its maturity 
has to show everywhere, especially in the compiler, as well as 
the package manager.





Re: Proposal: Support for objects in switch statements

2017-11-04 Thread angel via Digitalmars-d
On Wednesday, 1 November 2017 at 01:16:32 UTC, solidstate1991 
wrote:
After I started to alter my graphics engine to use the multiple 
kinds of bitmaps (now using multiple language features, like 
templates and aliases) on one layer, I noticed that type 
detection of bitmap objects would be easier and better 
readable, if instead of:


if(bitmapObject.classinfo == typeof(Bitmap4Bit)){
...
}else if(bitmapObject.classinfo == typeof(Bitmap8Bit)){...

I could easily use this:

switch(bitmapObject.classinfo){
case typeof(Bitmap4Bit):
...
case typeof(Bitmap8Bit):
}

On the other hand I cannot really think other uses for such 
language feature, maybe with structs.


The idea IS good, I am sure it has already happened to many.
May it be there are some technical problems with it ?


What is wrong with core.stdc.signal ?

2017-10-27 Thread angel via Digitalmars-d
Core.stdc.signal.signal() requires that a signal handler function 
is "nothrow @nogc @system".
These attributes impose quite a limitation - one cannot even 
print which signal was accepted.
While if one imports this same function via "extern (C)" path, he 
can  freely throw and allocate memory in the signal handler. And 
this actually makes sense, as the handler function is called on 
top of the stack of where the code was running when the signal 
popped in, so it's like calling a function.

Why the limitation if it works ?



Re: How to list all process directories under /proc/

2017-09-22 Thread angel via Digitalmars-d-learn

On Sunday, 17 September 2017 at 08:15:58 UTC, Ky-Anh Huynh wrote:

Hi,

I want to list all processes by scanning /proc/. The following 
code doesn't work


[code]
  foreach (string fstatm; dirEntries("/proc/", "[0-9]*", 
SpanMode.shallow)) {

writefln("pid %s", fstatm);
  }
[/code]

as it only list a few entries before exiting

[code]
pid /proc/9
pid /proc/935
pid /proc/9146
pid /proc/9149
pid /proc/9150
pid /proc/9151
pid /proc/9756
pid /proc/9759
pid /proc/9760
pid /proc/9761
[/code]

I don't want to use `SpanMode.depth` or `SpanMode.breadth` 
because it will scan so deeply and there would be a permission 
problem.


Any ideas?

Thanks a lot



Are you familiar with libprocps ?
Maybe you had better make use of this library, or, at least, peek 
into its code, for reference.


Re: real simple delegate question.

2017-08-20 Thread angel via Digitalmars-d-learn

On Saturday, 19 August 2017 at 18:33:37 UTC, WhatMeWorry wrote:

On Friday, 18 August 2017 at 20:39:38 UTC, angel wrote:

On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote:

[...]


This actually appears correct ...
The 1-st example:
Each call to makeCalculator() increments a static (i.e. shared 
among all makeCalculator() instances) variable - context.

In addition, makeCalculator() generates a random variable.
Whereas the delegate merely captures these variables, and the 
displayed results reflect this.


The 2-nd example:
There is a single call to makeCalculator().
After this call, context == 1, randy == _apparently 2_.
Now the delegate, as has already been said, merely captures 
these values, so consecutive calls do not change the result.


Thanks. So,
auto calculator = makeCalculator();
is the actual call of the delegate? "Delegate is function 
pointer with context"

But what is
...calculator(0));

Or maybe another approach would be to ask, what type is the 
compiler replacing auto with.


No !
The actual call to the delegate is calculator(0).
But this delegate does not induce change on its context 
variables, so it is expectable that consecutive calls to 
calculator(0) produce the same results, isn't it ?
makeCalculator(), while not a delegate, also has a context 
variable - "static int context" - this is an "old-school" context 
variable implemented by the means of static variable.
Consecutive calls to makeCalculator() return delegates having 
different contexts, so each call to calculator(0) produces 
different results.


Re: real simple delegate question.

2017-08-18 Thread angel via Digitalmars-d-learn

On Friday, 18 August 2017 at 02:38:15 UTC, WhatMeForget wrote:


Can someone explain what is the difference between the two? 
Thanks.


module gates;
import std.stdio;
import std.random;

alias Calculator = int delegate(int);

Calculator makeCalculator()
{
static int context = 0;
int randy = uniform(1, 7);
context++;
writeln("context = ", context);
writeln("randy = ", randy);
return value => context + randy + value;
}

void main()
{
for (int i = 0; i < 3; i++)
{
auto calculator = makeCalculator();
writeln("The result of the calculation: ", 
calculator(0));

}
}
returns:
context = 1
randy = 5
The result of the calculation: 6
context = 2
randy = 2
The result of the calculation: 4
context = 3
randy = 6
The result of the calculation: 9

while the following

void main()
{
auto calculator = makeCalculator();  // thought just one 
would work

for (int i = 0; i < 3; i++)
{
writeln("The result of the calculation: ", 
calculator(0));

}
}
returns:
The result of the calculation: 3
The result of the calculation: 3
The result of the calculation: 3


This actually appears correct ...
The 1-st example:
Each call to makeCalculator() increments a static (i.e. shared 
among all makeCalculator() instances) variable - context.

In addition, makeCalculator() generates a random variable.
Whereas the delegate merely captures these variables, and the 
displayed results reflect this.


The 2-nd example:
There is a single call to makeCalculator().
After this call, context == 1, randy == _apparently 2_.
Now the delegate, as has already been said, merely captures these 
values, so consecutive calls do not change the result.


Re: Create class on stack

2017-08-05 Thread angel via Digitalmars-d-learn

On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote:
using gtk, it has a type called value. One has to use it to get 
the value of stuff but it is a class. Once it is used, one 
doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it in 
a delegate I would like to minimize unnecessary allocations. Is 
there any way to get D to allocate a class on the stack like a 
local struct?


Emplace ?
https://dlang.org/phobos/std_conv.html#emplace



Re: Is this related to D?

2017-07-26 Thread angel via Digitalmars-d
On Wednesday, 26 July 2017 at 18:09:23 UTC, Andrei Alexandrescu 
wrote:
I got this on a Google Alert for "dlang": 
https://launchpad.net/ubuntu/+source/language-pack-kn/1:17.10+20170724/+build/13147073. Is it connected to the D language? -- Andrei


No, this is related to Kannada language translation, which is a 
human language.


Re: Showcasing the power of D on HackerRank

2017-04-01 Thread angel via Digitalmars-d

On Saturday, 1 April 2017 at 19:17:01 UTC, aberba wrote:
HackerRank (https://www.hackerrank.com) "is a place where 
programmers from all over the world come together to solve 
problems in a wide range of Computer Science domains such as 
algorithms, machine learning, or artificial intelligence, as 
well as to practice different programming paradigms like 
functional programming.".


My point is, the modeling power, etc. of D can be showcased on 
this platform...


"We run regular hackathons with cash prizes. For our sponsored 
competitions, we even connect you to companies who are hiring 
as long as you opt-in to being contacted".


"Jobs. Solving the coding challenges at our Jobs page lets you 
apply for software engineering positions at a variety of 
companies at once, or even just the companies you're 
interested in working for."


"Paid Contributor. You can create your own challenges and 
become a paid contributor."


Is sound goo what I'm reading in their FAQ 
(https://www.hackerrank.com/faq)



D is already supported (at least in the algorithms section).



I take their challenges from time to time ... always in D.



Re: What about this logo ":D" to advertise the D language ?

2017-03-02 Thread angel via Digitalmars-d

On Thursday, 2 March 2017 at 12:31:27 UTC, qznc wrote:
On Thursday, 2 March 2017 at 09:45:40 UTC, Martin Tschierschke 
wrote:
On Thursday, 2 March 2017 at 09:05:43 UTC, Jared Jeffries 
wrote:

I'm not completely joking ;)

D deserves a lot more fame, because it really allows 
programmers to "develop with a smile", so maybe the logo and 
slogan should reflect it...


With D you can get the job done, as with C++, Java, C#, 
Node.js etc, but easier, faster, safer and with a lot more 
pleasure !


D is really good at this, hence the logo :D


I like it!

The D evolution:  :-(  =>  :-| =>  :-)  =>  ;-)  => :D
Why D? Give your coding a smile :D


Isn't it :C => :C++ => :D

Much better than :C# of course.



Your  :C++  looks like someone throwing up.
Well ... maybe this is intentional.


Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn

On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote:

On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote:

I'm looking for a better way to do this, if possible:

```
class Tool
{
string name;
}

T namedTool(alias Variable, T)()
{
T result = new T;
result.name = Variable.stringof;
return result;
}

void main()
{
Tool grep;
grep = namedTool!(grep,Tool);
assert(grep.name == "grep");
}
```

Ideally this would work like this:

```
Tool grep = namedTool!Tool;
assert(grep.name == "grep");
```

Possible ?


Sorry, but this does not make much sense to me ...
You expect "namedTool!Tool" to know that the name of the Tool 
must be set to "grep".
The expression evaluation proceeds from right to left, so at 
the time of analyzing "namedTool!Tool", the compiler knows 
nothing about "grep".
On the other hand, if you supplied the "grep" variable, the 
compiler could infer its type, like this:

```
...
auto namedTool(alias Variable)()
{
alias T = typeof(Variable);
T result = new T;
result.name = Variable.stringof;
return result;
}

void main()
{
Tool grep;
grep = namedTool!(grep);
assert(grep.name == "grep");
}
```


Or actually, maybe this will suite your case better:
```
template namedTool(T, alias Variable)
{
enum namedTool = T.stringof ~ " " ~ Variable ~ " = new " ~ 
T.stringof ~ ";" ~

 Variable ~ ".name = \"" ~ Variable ~ "\";";
}

void main()
{
mixin(namedTool!(Tool, "grep"));
assert(grep.name == "grep");
}
```


Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn

On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote:

I'm looking for a better way to do this, if possible:

```
class Tool
{
string name;
}

T namedTool(alias Variable, T)()
{
T result = new T;
result.name = Variable.stringof;
return result;
}

void main()
{
Tool grep;
grep = namedTool!(grep,Tool);
assert(grep.name == "grep");
}
```

Ideally this would work like this:

```
Tool grep = namedTool!Tool;
assert(grep.name == "grep");
```

Possible ?


Sorry, but this does not make much sense to me ...
You expect "namedTool!Tool" to know that the name of the Tool 
must be set to "grep".
The expression evaluation proceeds from right to left, so at the 
time of analyzing "namedTool!Tool", the compiler knows nothing 
about "grep".
On the other hand, if you supplied the "grep" variable, the 
compiler could infer its type, like this:

```
...
auto namedTool(alias Variable)()
{
alias T = typeof(Variable);
T result = new T;
result.name = Variable.stringof;
return result;
}

void main()
{
Tool grep;
grep = namedTool!(grep);
assert(grep.name == "grep");
}
```


Re: capture stdout or stderr

2017-02-01 Thread angel via Digitalmars-d-learn

On Wednesday, 1 February 2017 at 01:08:19 UTC, Emil wrote:
is it possible to intercept the  STDOUT or STDERR and capture 
the output into a variable ?



some pseudocode to explain what I mean

string[] output_buffer;
stdout.capture_to(output_buffer);

writeln("test 1"); # not printed
writeln("test 2"); # not printed

stdout.release(output_buffer);

writeln("test 3"); # printed
writeln(output_buffer); # prints '["test 1","test 2"]'


No.
Please keep in mind, that in Linux, for example, stdout is a file 
...
writeln() interacts with OS API, which, of course, has nothing to 
do with internal data structures of your application.
What you could probably do is replace writeln() with a custom 
logger. In your logger implementation you can add such 
functionality.






Re: @property get/set or public varaible?

2016-12-04 Thread angel via Digitalmars-d-learn

On Sunday, 4 December 2016 at 15:30:22 UTC, vladdeSV wrote:

Hello!

I have a question not directly related to D as it is with 
coding standards.


My issue at hand is if I have one variable for a class, which I 
want to be directly accessible for anything else, should it be

 1. public, or
 2. private, with @property get/setters?

From what I have been told is that variables should be private. 
But if I do not want to make any checks whatsoever when setting 
a variable, I see no benefit to the private approach.


Are there any other reasons to use get/setters?


Make the member variable public, if it serves your purpose.
If (and when) you feel like taking some control over setting and 
getting its value, you will upgrade it to @property 
setter/getter, making the actual member variable private.
For most reasonable use cases the upgrade should pass with no 
problems.

...
If you envision such an upgrade possibility, try to keep away 
from taking your member variable address, and other not 
method-friendly operations, that might hold the upgrade back.


Re: ThinLTO is there. I think that should settle the final/virtual debate

2016-12-04 Thread angel via Digitalmars-d

On Sunday, 4 December 2016 at 01:36:50 UTC, deadalnix wrote:

First, presentation:
https://www.youtube.com/watch?v=9OIEZAj243g

Some of this is available in LLVM today, and everything 
presented here will be in 4.0 . The long story short: ThinLTO 
can do most of what LTO does but with a price that is much 
closer to the one of a regular build than the one of a classic 
LTO build.


LTO optimization can devirtualize all function that do not need 
to be virtual, and even use profile infos to speculatively 
devirtualize - aka JVM grade devirtualization.


I would love to see this leveraged to finally put to rest the 
final vs virtual debate. If we use this tech properly, 
everything that do not need to be virtual can be finalized - 
except across shared object, which shouldn't be too much of an 
issue in practice.


IMHO it was always obvious that the proper way is 
"devirtualization" within compiler optimization process. The 
distinction between virtual and non-virtual methods is a break-in 
into optimization domain, which should be "transparent" to the 
developer. From the developer's POV, the correct semantics is 
when each method is virtual.


An interesting article on GC interaction with OS scheduler

2016-12-03 Thread angel via Digitalmars-d
This article presents an insight into a peculiar interaction 
between Java GC and Linux scheduler on the background of Linux 
containerization technology - the CGROUP.
IMHO the CGROUP only amplifies the discussed impact, that exists 
anyway.


A short summary:
Linux scheduler allocates a time slice for an application to run. 
When the time slice is depleted (i.e. all the application threads 
together have eaten up all the time resource), the application is 
stopped until next time slice is allocated.
Many-threaded GC is able to deplete the time slice very quickly, 
causing Stop-The-World effect, even in generally concurrent GC 
design.


https://engineering.linkedin.com/blog/2016/11/application-pauses-when-running-jvm-inside-linux-control-groups



Re: Examples Wanted: Usages of "body" as a Symbol Name

2016-10-05 Thread angel via Digitalmars-d

On Wednesday, 5 October 2016 at 02:11:14 UTC, Meta wrote:
I'm currently writing up a DIP to propose removing `body` as a 
keyword to allow it to be used for variable names, functions, 
etc. I'm looking for examples and contexts where `body` would 
normally be used as a variable, function name, alias, etc. This 
is what I have come up with off the top of my head:


- In web programming where "body" is a required tag in any 
valid HTML document. Ex:

- It is a name commonly used for XML tags and/or attributes
- Physics simulations as well in astronomical contexts 
("planetary bodyies", etc.)

- Video games, such as referring to the player character's body



Really, why do we need a _body_ ?
We have pre-condition and post-condition (in and out), everything 
else is a body.
It is simply inconsistent - a regular function with no in and out 
blocks has no body block. Now one adds a pre-condition (and / or 
post-condition) - whoop - one needs to wrap the whole function 
body ... well in a body expression.


Re: iPhone vs Android

2016-09-13 Thread angel via Digitalmars-d
I think the conclusions about iOS vs. Android OS-level memory 
collection are not applicable to D GC discussion.
An OS collects all the memory pages allocated for a process upon 
exit - no heap scan, no RC. It more resembles a one huge free() 
call.
The discussion is mainly about eager vs. less-eager 
not-currently-running process killing strategy.

D's GC lies in a different plane ...


Is it a bug in unittest ?

2016-09-01 Thread angel via Digitalmars-d
If one creates a unittest block in a templated class (or struct), 
the unittest block will be multiplied per class specialization, 
which might turn out to be quite large number.


E.g.
 struct A(T) {
 ...
 unittest {
 ...
 }
 }

 ...

 auto a = A!int;
 auto b = A!int;
 auto c = A!double;

The unittest block will be instantiated twice (per A!int and 
A!double).
But in some (many ?) cases unittest doesn't even exercise the 
generics, merely using some particular type.


What is it, a bug ?


Re: Is this the best way to share Tids between threads?

2016-08-14 Thread angel via Digitalmars-d

Let each thread have a name related to its task.
It is like having a shared Tid array, but already implemented.
Reference:
http://dlang.org/phobos/std_concurrency.html#.register



Re: [OT] The coolest (literally) desktop machine I've ever had

2016-08-14 Thread angel via Digitalmars-d
I happen to be CompuLab's ex-employee, and I have even been 
involved in SW development of the AirTop computer ...
So it is D-friendly at least to the extent, that a D fan was 
involved in its development.
It is indeed quite powerful. The technical support is also very 
good.
Building a fanless computer is not a simple issue at all, 
especially when it is such powerful.
As a side note, there are cheaper and much (physically) smaller 
computers such as IntensePC, that are also very cool - refer to 
www.compulab.co.il.
I am no more associated with CompuLab, so this is in no way an 
advertisement  :)




Re: Graylog Extended Log Format (GELF) for D

2016-04-09 Thread angel via Digitalmars-d-announce

But what about this ?
https://forum.dlang.org/thread/eryphpbznrrovjvxj...@forum.dlang.org


Re: Defer in D

2016-03-21 Thread angel via Digitalmars-d
I would, actually, like to see it integrated with the core 
language syntax, kinda:

scope(function) ...

While your solution is viable from the technical point of view, 
having a consistent language syntax could also be nice.


Re: The relationship of invariants and alias this

2014-11-11 Thread angel via Digitalmars-d

Wait !
x.value -= 100; would call the invariant ?
Alias this only rewrites your expression:
x -= 100; becomes x.value -= 100;
No method is called. Then there is no reason (is there ?) to call 
the invariant.

If you would create getter/setter properties ...


Re: spawnProcess() not child?

2014-11-03 Thread angel via Digitalmars-d-learn

The parent / child relationship always exists.
In POSIX OSs, you may ignore SIGCHLD signal (announcing child 
process death), so that in case of child process exit it will not 
become zombie, rather it will be disposed on the spot.
As a side note, in Linux, there exist a system call allowing 
process re-parenting, but it is intended for use in 
experimenting, rather than in normal use case.
Side note II, there is no real chance of wrapping PID numbers 
around in a reasonable time frame.