Detroit symptoms Wayne Ellington in just ignificant recruiting victory

2019-03-07 Thread Wele cvb via Digitalmars-d-learn
The Detroit Pistons received a unanticipated and ignificant 
recruiting victoryas a result of coming in the direction of 
phrases with cost-free representative Wayne Ellington, for each 
ESPN Adrian Wojnarowski. Ellington, a 6-foot-5 capturing defend, 
is a vocation 38 per cent 3-stage marksman and contains turn out 
to be a large-quantity shooter inside latest seasons. Numerous 
groups were being within pursuit of Ellington immediately after 
he was waived by means of the Phoenix Suns 
https://www.pistonsshirt.com/Khyri_Thomas_T_Shirt-24 . The Suns 
discovered Ellington within a bundle with the Warm that netted 
them Tyler Johnson inside change for Ryan Anderson. The Thunder, 
Sixers and Celtics ended up reportedly involving the groups 
intrigued inside following Ellington.As a result why did he just 
take Detroit? It doesn problems that Pistons govt Arn Tellem made 
use of in direction of be Ellington representative. Detroit 
roster is currently at a highest of 15 avid gamers, therefore 
somebody will include toward be waived in direction of deliver 
space for Ellington. The likeliest prospect is past to start 
with-spherical opt for Henry Ellenson, who includes in no way 
carved out a job inside Detroit and who will be an endless 
absolutely free consultant the moment the period. Improve: It 
was, inside truth, Ellenson who received waived:Detroit Pistons 
software toward launch in advance Henry Ellenson in direction of 
crank out place for Wayne Ellington Even though he clears 
waivers, league means inform Yahoo Sporting activities.Ellington 
simplest issue is at capturing defend, still the Pistons are ripe 
with bodies that effort and hard work most straightforward at 
taking pictures shield, despite the fact that taking in extremely 
small readily available at the minor ahead issue. The workers 
presently traded absent its greatest 2 low forwards in just 
Reggie Bullock (himself undersized for the place) and Stanley 
Johnson. Detroit will almost certainly supply instant-yr 
participant Luke Kennard the 1st shot at having upon the 
commencing minor in advance part, with Glenn Robinson III as his 
principal backup and the not long ago discovered Svi Mykhailiuk 
one more element alternative. That signifies that Ellington joins 
Bruce Brown, Langston Galloway and Khyri Thomas as choices for 
the capturing protect vacation spot. Brown includes not too long 
ago been starting off at taking pictures safeguard with Bullock 
at reduced in advance. With consequently substantially turnover, 
it appears to be including Dwane Casey may well experiment for a 
When till he unearths a mixture he is satisfied with. The wing 
place contains predominantly been a nightmare all period for the 
Pistons, with Bullock the basically preserving grace. He is at 
the moment absent. Brown is a superior defender still contains 
virtually no offensive activity and is inclined in the direction 
of starter problems. Galloway operates incredibly hot and 
occasionally incredibly 
https://www.pistonsshirt.com/Blake_Griffin_T_Shirt-14 , 
unbelievably chilly and Kennard is continue to also passive and 
within just his individual mind as he attempts in direction of 
determine out how in the direction of suit into the circulation 
of the offense and produce the straight options upon the area. 
Robinson, in the meantime, consists of been a disappointing 
totally free representative acquisition for Detroit who hasn 
furnished considerably upon both conclusion and disregarded 
season with an ankle harm. Even now, the staff members is little 
by little going absent towards the failures of the Stan Van Gundy 
regimen Jose Calderon T-Shirt, and inside of Svi, Ellington, 
Kennard and even recently aquired significant person Thon 
Manufacturer, Detroit at bare minimum contains a prayer of 
setting up in direction of create some 3-issue photographs. That 
surely be a sight for sore eyes. Even more Versus Detroit 
Negative Boys Pistons at Warm greatest rating: Detroit proceeds 
playoff drive with gain in opposition to Miami Jon Leuer T-Shirt, 
119-96 Pistons at Warm GameThread: Video game period, Television, 
probabilities, and far more Pistons at Warmth preview: Detroit 
carries momentum into Miami Pistons vs. Hawks greatest ranking: 
Thon Manufacturer hits activity champion in just wild activity 
Pistons at Hawks GameThread: Recreation period, Tv set, 
possibilities, and excess Pistons at Hawks preview: Matchup 
comfort? Detroit Optimum Study Pistons at Warmth greatest rating: 
Detroit proceeds playoff thrust with acquire towards Miami, 
119-96 Following a complicated earn inside of Atlanta the night 
time right before, the Detroit Pistons ongoing their successful 
tactics within just South Seashore. Pistons vs. Hawks very last 
rating: Thon Manufacturer hits recreation champion inside wild 
video game Stanley Johnson couldn Pistons at Warm preview: 
Detroit carries momentum into Miami Upon the moment night time of 
a again-towards-again 

Re: How can I make a nested array and flatten it at run time in D?

2019-03-07 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 08, 2019 at 01:00:43AM +, Philos Kim via Digitalmars-d-learn 
wrote:
> I want to make a nested array and flatten it at run-time like this.
> 
> auto nestedArray = [1, 2, [3, 4], 5];

You can't write it this way because the nested array has a different
type from the other elements. You have to write this as:

auto nestedArray = [[1], [2], [3, 4], [5]];


> auto flattenedArray = myFun(nestedArray);

Use std.algorithm.iteration.joiner:

flattenedArray = nestedArray.joiner.array;

Or simpler, use std.array.join:

flattenedArray = nestedArray.join;


> writeln(flattenedArray);   // => [1, 2, 3, 4, 5]


T

-- 
People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG


Re: How can I make a nested array and flatten it at run time in D?

2019-03-07 Thread James Blachly via Digitalmars-d-learn

On 3/7/19 8:00 PM, Philos Kim wrote:

I want to make a nested array and flatten it at run-time like this.

auto nestedArray = [1, 2, [3, 4], 5];

auto flattenedArray = myFun(nestedArray);

writeln(flattenedArray);   // => [1, 2, 3, 4, 5]


How can I do this in D?

Please help me out!



There are simpler ways, but looking at the below Rosetta Code link can 
be very instructive:


https://rosettacode.org/wiki/Flatten_a_list



How can I make a nested array and flatten it at run time in D?

2019-03-07 Thread Philos Kim via Digitalmars-d-learn
I want to make a nested array and flatten it at run-time like 
this.


auto nestedArray = [1, 2, [3, 4], 5];

auto flattenedArray = myFun(nestedArray);

writeln(flattenedArray);   // => [1, 2, 3, 4, 5]


How can I do this in D?

Please help me out!



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:50 schrieb Johannes Loher:
> [...]

As a small addition, if you always want to pass the function name as a
parameter, you can simplify this to the following:

```
enum profile_scope(string name = __FUNCTION__) = "import core.stdc.stdio
: printf; printf(\""
~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
mixin(profile_scope!());
foo();
}

extern (C) void foo() {
mixin(profile_scope!());
}
```
This will print
```
main.main
main.foo
main.foo
main.main
```
to the commandline.



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:21 schrieb Simon:
> 
> Is there a way to achieve this while compiling with -betterC? I use a
> custom string struct right now, and your version needs TypeInfo,
> concatening using ~ needs the garbage collector. I have the feeling D is
> really not agreeing with the way I want to do things. If this is not
> possible, I will just roll with the Adam's struct solution.
> 

Using Adams struct solution is perfectly fine. I believe it is probably
the cleaner solution overall.

My solution depends on TypeInfo because format does. I used format
because it makes the string more readable. You can avoid this and use
string concatenation in combination with providing the function name as
template parameter instead:

```
enum profile_scope(string name) = "import core.stdc.stdio : printf;
printf(\""
~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
mixin(profile_scope!"func1");
}

```
This uses string concatenation only at compile time and not during run
time, so it does not require the garbage collector and is compatible
with betterC :)


Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn

On Thursday, 7 March 2019 at 20:34:48 UTC, Johannes Loher wrote:


auto profile_scope(string name)
{
import std.format : format;
return q{import std.stdio : writeln; writeln("%1$s"); 
scope(exit)

writeln("%1$s");}.format(name);
}

void main()
{
mixin(profile_scope("func1"));
}


Is there a way to achieve this while compiling with -betterC? I 
use a custom string struct right now, and your version needs 
TypeInfo, concatening using ~ needs the garbage collector. I have 
the feeling D is really not agreeing with the way I want to do 
things. If this is not possible, I will just roll with the Adam's 
struct solution.




Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 21:07 schrieb Simon:
> Hello,
> 
> I am currently porting the frontend of my instrumenting profiler to D.
> It features a C++-makro that profiles the time between entering and
> leaving a scope (achieved with con-/destructors in C++). Since D has
> scopeguards, I hoped to achieve this by creating a mixin that generates
> the following code:
> 
> measure("func1");
> scope(exit) measure("func1");
> 
> Since I of course don't want to type a mixin for that everytime I want
> to use it, I tried to alias it:
> 
> import std.meta : Alias;
> alias profile_scope(string name) = Alias!(mixin("measure(\"" ~ name ~
> "\"); scope(exit) measure(\"" ~ name ~ "\");"));
> 
> I expected this to generate the code above by typing
> profile_scope("func1") in my programm. However the compiler (dmd) gives
> me the following error:
> 
> source\main.d(24): Error: template plattform.profile_scope cannot deduce
> function from argument types !()(string), candidates are:
> source\plattform.d(262):    plattform.profile_scope(string name)
> 
> This looks like a deduction/overload kind of error, which has me
> completly confused since there is no other identifier of the name
> "profile_scope" in my programm and the error message shows only one
> candidate.
> 
> Is there any way I can achive generating those two statements using only
> something that effectively looks like a function call/C-macro with an
> argument?
The error you are seeing is due to the fact that you pass "func1" as
runtime parameter instead of as a teamplate parameter. You would need to
do `profile_scope!("func1");`. However, this will still not work and
you'll get an error message similar to this:
```
main.d(4): Error: incomplete mixin expression writeln("func1");
scope(exit) writeln("func1");
main.d(8): Error: template instance `main.profile_scope!"func1"` error
instantiating
```

The underlying problem is that you can only alias expressions, i.e. you
cannot use alias to generate macro like functionality.

`measure("func1"); scope(exit) measure("func1");` is not an expression,
it is simply a statement, so the alias cannot work.

If you want to inject code directly at some place, basically your only
option is to use a string mixin. I understand that you do not want to
write `mixin` all the time, but to me, this does not look that bad:
```
auto profile_scope(string name)
{
import std.format : format;
return q{import std.stdio : writeln; writeln("%1$s"); scope(exit)
writeln("%1$s");}.format(name);
}

void main()
{
mixin(profile_scope("func1"));
}
```
(replace writeln with your appropriate function call, "measure" in your
example).



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 7 March 2019 at 20:07:27 UTC, Simon wrote:

measure("func1");
scope(exit) measure("func1");


I would suggest just using a struct. Make its constructor do the 
first measure, and its destructor do the second measure.


I betcha you can avoid mixin entirely.


Re: 2 class issues

2019-03-07 Thread ag0aep6g via Digitalmars-d-learn

On 07.03.19 11:38, spir wrote:
-1- How to enforce that subclasses implement given methods without using 
"abstract", which seems to make the whole class abstract?


Not, as far as I can tell. You can't force derived classes to override 
an existing implementation. And you can't omit the implementation 
without making the class abstract.


-2- How to have "constant" (predefined) class instances at the 
module-level?


Just like so?

const o = new Object; /* works for me */


The compiler requires a "static this ()".


For what code does it say that?

What does this 
actually mean (for a constructor)? What are the consequences, for either 
my code or client code? (The doc on the topic [2] is rather obscure for 
me, and I could not find better elsewhere.)


I'm also bluffed by "Static constructors have empty parameter lists." 
Does this mean I should manually fill the fields? (not a big deal, but 
why???) This may give:

     // Predefined pseudo-pattern "End-of-Text":
     auto EoT = new Pattern() ;   // ???
     EoT.name = "EoT" ;

     // Unique lexeme "end-of-text":
     auto eot = new Lexeme() ;   // ???
     eot.patname = "EoT" ;
     eot.slice = null ;
     eot.index = uint.max ;
Then, why have a constructor at all? This would also prevent me from 
making classes immutable, while conceptually all are immutable... (no 
reason for a pattern or a lexeme to change)


You're misunderstanding the nature of static constructors.

Static constructors are a special kind of function that runs once at the 
beginning of the program/thread, automatically. They're not constructors 
for static objects. You can't call static constructors from your code. 
`new Foo` calls a (normal) constructor; doesn't matter if you're 
creating a dynamic instance or a static one.


Re: 2 class issues

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 11:38 schrieb spir:
> Hello,
> 
> First, I am not very experimented with the combination of static lang
> (alloc & typing) and OO (class-based). I'm implementing a library for
> lexical analysis (lexing), with 2 minor issues:
> 
> -1- How to enforce that subclasses implement given methods without using
> "abstract", which seems to make the whole class abstract? (no info found
> in doc, actually, the page on classes [1] does not seem to even mention
> abstract classes)
> 
> -2- How to have "constant" (predefined) class instances at the
> module-level? The compiler requires a "static this ()". What does this
> actually mean (for a constructor)? What are the consequences, for either
> my code or client code? (The doc on the topic [2] is rather obscure for
> me, and I could not find better elsewhere.)
> 
> I'm also bluffed by "Static constructors have empty parameter lists."
> Does this mean I should manually fill the fields? (not a big deal, but
> why???) This may give:
>     // Predefined pseudo-pattern "End-of-Text":
>     auto EoT = new Pattern() ;   // ???
>     EoT.name = "EoT" ;
> 
>     // Unique lexeme "end-of-text":
>     auto eot = new Lexeme() ;   // ???
>     eot.patname = "EoT" ;
>     eot.slice = null ;
>     eot.index = uint.max ;
> Then, why have a constructor at all? This would also prevent me from
> making classes immutable, while conceptually all are immutable... (no
> reason for a pattern or a lexeme to change)
> 
> Thank you,
> diniz
> 
> [1] https://dlang.org/spec/class.html
> [2] https://dlang.org/spec/class.html#static-constructor

Regarding your first point: I don't think it is currently possible to
force derived classes to override functions from the base class while
also implementing these functions in the base class. What would the
usecase of this be anyways?

Regarding your second point: What excatly do you mean by '"constant"
(predefined) class'? Do you mean that you want to provide an instant
from that class? You can achieve this like the following:

```
class Test
{
}

Test testInstance;

static this() {
testInstance = new Test();
}
```
If you want the testInstance to be shared across threads:
```
class Test
{
}

shared Test testInstance;

shared static this() {
testInstance = new Test();
}
```

You seem to be misunderstanding how static class constructors work: They
are not invoked when you try to instanciate the class, but when the
module in which the class is located is loaded. This also explains why
they need to have empty parameter lists: You cannot pass arguments when
loading a module  static constructors are usually used to initialize
static class variables. Consider the following example:

```
import core.thread: Thread;

class Test
{

private static ulong i;

static this() {
i = Thread.getThis.id;
}
}
```
You cannot initialize `i` directly in its declaration because
`Thread.getThis.id` is only available at runtime (i.e. `private static
ulong i = Thread.getThis.id;` does not compile). To get around this, you
can use static constructors.



Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn

Hello,

I am currently porting the frontend of my instrumenting profiler 
to D. It features a C++-makro that profiles the time between 
entering and leaving a scope (achieved with con-/destructors in 
C++). Since D has scopeguards, I hoped to achieve this by 
creating a mixin that generates the following code:


measure("func1");
scope(exit) measure("func1");

Since I of course don't want to type a mixin for that everytime I 
want to use it, I tried to alias it:


import std.meta : Alias;
alias profile_scope(string name) = Alias!(mixin("measure(\"" ~ 
name ~ "\"); scope(exit) measure(\"" ~ name ~ "\");"));


I expected this to generate the code above by typing 
profile_scope("func1") in my programm. However the compiler (dmd) 
gives me the following error:


source\main.d(24): Error: template plattform.profile_scope cannot 
deduce function from argument types !()(string), candidates are:
source\plattform.d(262):plattform.profile_scope(string 
name)


This looks like a deduction/overload kind of error, which has me 
completly confused since there is no other identifier of the name 
"profile_scope" in my programm and the error message shows only 
one candidate.


Is there any way I can achive generating those two statements 
using only something that effectively looks like a function 
call/C-macro with an argument?


Re: 2 class issues -- PS

2019-03-07 Thread spir via Digitalmars-d-learn

from [https://dlang.org/spec/attribute.html#abstract] :

---
abstract Attribute

An abstract member function must be overridden by a derived class. Only virtual 
member functions may be declared abstract; non-virtual member functions and 
free-standing functions cannot be declared abstract.


Classes become abstract if any of its virtual member functions are declared 
abstract or if they are defined within an abstract attribute. Note that an 
abstract class may also contain non-virtual member functions.


Classes defined within an abstract attribute or with abstract member functions 
cannot be instantiated directly. They can only be instantiated as a base class 
of another, non-abstract, class.


Member functions declared as abstract can still have function bodies. This is so 
that even though they must be overridden, they can still provide ‘base class 
functionality’, e.g. through super.foo() in a derived class. Note that the class 
is still abstract and cannot be instantiated directly.

---

Is there thus another way to enforce overriding of given methods? I wish to 
instantiate superclasses for special instances, as shown in previous mail. It is 
not a big deal (I can live without this enforcement, and my clients as well 
since if they wish to implement their own subclasses, they will have to 
override) but I still wish to know that for further cases.


Thank you,
diniz



2 class issues

2019-03-07 Thread spir via Digitalmars-d-learn

Hello,

First, I am not very experimented with the combination of static lang (alloc & 
typing) and OO (class-based). I'm implementing a library for lexical analysis 
(lexing), with 2 minor issues:


-1- How to enforce that subclasses implement given methods without using 
"abstract", which seems to make the whole class abstract? (no info found in doc, 
actually, the page on classes [1] does not seem to even mention abstract classes)


-2- How to have "constant" (predefined) class instances at the module-level? The 
compiler requires a "static this ()". What does this actually mean (for a 
constructor)? What are the consequences, for either my code or client code? (The 
doc on the topic [2] is rather obscure for me, and I could not find better 
elsewhere.)


I'm also bluffed by "Static constructors have empty parameter lists." Does this 
mean I should manually fill the fields? (not a big deal, but why???) This may give:

// Predefined pseudo-pattern "End-of-Text":
auto EoT = new Pattern() ;   // ???
EoT.name = "EoT" ;

// Unique lexeme "end-of-text":
auto eot = new Lexeme() ;   // ???
eot.patname = "EoT" ;
eot.slice = null ;
eot.index = uint.max ;
Then, why have a constructor at all? This would also prevent me from making 
classes immutable, while conceptually all are immutable... (no reason for a 
pattern or a lexeme to change)


Thank you,
diniz

[1] https://dlang.org/spec/class.html
[2] https://dlang.org/spec/class.html#static-constructor