Re: Master Thesis using D Programming language.

2020-08-25 Thread Arun via Digitalmars-d-learn

On Monday, 24 August 2020 at 19:56:49 UTC, Tariq Siddiqui wrote:

Hello everyone,

I am looking for a master thesis topic using D Programming 
language. Earlier I choose Design by Introspection, but I did 
not find enough material in academic journals. DbI total 
material which I found is DConf Andrei talk and the similar 
talk at Google campus, which starts with 50 Deutsche Mark story 
and ends with explaining PbD, DbI and other Dlang internals. No 
doubt that Andrei's discussion was great. DbI as a topic is 
excellent, but as per my university requirements, I was not 
able to find five articles in the last five years in any 
academic journal, to start the initial discussion about the 
research topic.


I am still opened with my topic, next week, I have to submit my 
draft proposal. Till now, I did not meet my dissertation 
advisor.


I am looking for something practical and less theoretical. I 
have found some thesis done using Rust, you guys as a language 
expert can these below projects be achievable using D 
Programming language.


http://www.barrelfish.org/publications/ma-foellmic-bfrust.pdf
https://www.diva-portal.org/smash/get/diva2:1238890/FULLTEXT01.pdf
https://github.com/Gankra/thesis/blob/master/thesis.pdf

Regards,
Tariq Siddiqui.


D for a @safer Linux Kernel was worked on by Alexandru Militaru: 
https://www.youtube.com/watch?v=weRSwbZtKu0


You can also browse the previous GSoC proposals at 
https://wiki.dlang.org/GSOC_2019_Ideas and 
https://wiki.dlang.org/GSOC_2018_Ideas of which some might 
qualify as masters thesis. These are pretty hands on requiring 
good understanding of the theory as well.


D blog had a similar post recently. 
https://dlang.org/blog/2020/08/23/symmetry-autumn-of-code-2020-projects-and-participants/


--
Arun


Vibe.d timer - change callback?

2020-08-25 Thread codic via Digitalmars-d-learn
I'd like to be able to change the callback of a vibe.d Timer (eg 
created with 
http://vibe-core.dpldocs.info/v1.9.3/vibe.core.core.createTimer.html) after creation, something like:


auto timer = createTimer();
timer.rearm(duration, /*...*/);
timer.callback = delegate {
   // things
}

An alternative method would be to recreate the timer, like so:

auto timer = createTimer();
timer.rearm(duration, /*...*/);
auto timer = createTimer();
timer.rearm(duration - timer.elapsed);

However, I can't find an `elapsed` property or similar in the 
documentation.


Re: Master Thesis using D Programming language.

2020-08-25 Thread aberba via Digitalmars-d-learn

On Monday, 24 August 2020 at 19:56:49 UTC, Tariq Siddiqui wrote:

Hello everyone,

I am looking for a master thesis topic using D Programming 
language. Earlier I choose Design by Introspection, but I did 
not find enough material in academic journals. DbI total 
material which I found is DConf Andrei talk and the similar 
talk at Google campus, which starts with 50 Deutsche Mark story 
and ends with explaining PbD, DbI and other Dlang internals. No 
doubt that Andrei's discussion was great. DbI as a topic is 
excellent, but as per my university requirements, I was not 
able to find five articles in the last five years in any 
academic journal, to start the initial discussion about the 
research topic.

Academic don't know innovation. Only history :)



I am still opened with my topic, next week, I have to submit my 
draft proposal. Till now, I did not meet my dissertation 
advisor.


Metaprogramming as suggested sounds interesting upon second 
thought. On Wikipedia, only D and C++ seems to have sufficient 
implementation among mainstream languages. With D's being 
exceptionally capable.


So you might want to do something around that...and how it 
impacts software development.




I am looking for something practical and less theoretical. I 
have found some thesis done using Rust, you guys as a language 
expert can these below projects be achievable using D 
Programming language.


Yep. Its does. Metaprogramming really has a very significant 
benefit in practice. And disign by introspection is one way it 
can be used.




Re: Master Thesis using D Programming language.

2020-08-25 Thread aberba via Digitalmars-d-learn

On Tuesday, 25 August 2020 at 16:52:17 UTC, aberba wrote:

On Monday, 24 August 2020 at 19:56:49 UTC, Tariq Siddiqui wrote:
Academic don't know innovation. Only history :)


Academia*


Re: How to get the element type of an array?

2020-08-25 Thread Jon Degenhardt via Digitalmars-d-learn

On Tuesday, 25 August 2020 at 15:02:14 UTC, FreeSlave wrote:
On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt 
wrote:
What's the best way to get the element type of an array at 
compile time?


Something like std.range.ElementType except that works on any 
array type. There is std.traits.ForeachType, but it wasn't 
clear if that was the right thing.


--Jon


Why not just use typeof(a[0])

It does not matter if array is empty or not. Typeof does not 
actually evaluate its expression, just the type.


Wow, yet another way that should have been obvious! Thanks!

--Jon


Re: How to get the element type of an array?

2020-08-25 Thread Jon Degenhardt via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 12:50:35 UTC, Steven Schveighoffer 
wrote:
The situation is still confusing though. If only 
'std.range.ElementType' is imported, a static array does not 
have a 'front' member, but ElementType still gets the correct 
type. (This is where the documentation says it'll return void.)


You are maybe thinking of how C works? D imports are different, 
the code is defined the same no matter how it is imported. 
*your* module cannot see std.range.primitives.front, but the 
range module itself can see that UFCS function.


This is a good characteristic. But the reason it surprised me was 
that I expected to be able to manually expand the ElementType (or 
ElementEncodingType) template see the results of the expressions 
it uses.


   template ElementType(R)
   {
   static if (is(typeof(R.init.front.init) T))
   alias ElementType = T;
   else
   alias ElementType = void;
   }

So, yes, I was expecting this to behave like an inline code 
expansion.


Yesterday I was doing that for 'hasSlicing', which has a more 
complicated set of tests. I wanted to see exactly which 
expression in 'hasSlicing' was causing it to return false for a 
struct I wrote. (Turned out to be a test for 'length'.)


I'll have to be more careful about this.


Re: How to get the element type of an array?

2020-08-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 25, 2020 at 03:02:14PM +, FreeSlave via Digitalmars-d-learn 
wrote:
> On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt wrote:
> > What's the best way to get the element type of an array at compile
> > time?
> > 
> > Something like std.range.ElementType except that works on any array
> > type. There is std.traits.ForeachType, but it wasn't clear if that
> > was the right thing.
> > 
> > --Jon
> 
> Why not just use typeof(a[0])
> 
> It does not matter if array is empty or not. Typeof does not actually
> evaluate its expression, just the type.

+1, why didn't I think of this before. :-D


T

-- 
Political correctness: socially-sanctioned hypocrisy.


Re: How to get the element type of an array?

2020-08-25 Thread FreeSlave via Digitalmars-d-learn

On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt wrote:
What's the best way to get the element type of an array at 
compile time?


Something like std.range.ElementType except that works on any 
array type. There is std.traits.ForeachType, but it wasn't 
clear if that was the right thing.


--Jon


Why not just use typeof(a[0])

It does not matter if array is empty or not. Typeof does not 
actually evaluate its expression, just the type.


Re: How to get the element type of an array?

2020-08-25 Thread Steven Schveighoffer via Digitalmars-d-learn

On 8/25/20 4:38 AM, Jon Degenhardt wrote:

On Tuesday, 25 August 2020 at 05:02:46 UTC, Basile B. wrote:

On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt wrote:

What's the best way to get the element type of an array at compile time?

Something like std.range.ElementType except that works on any array 
type. There is std.traits.ForeachType, but it wasn't clear if that 
was the right thing.


--Jon


I'm curious to know what are the array types that were not accepted by 
ElementType ( or ElementEncodingType ) ?


Interesting. I need to test static arrays. In fact 'ElementType' does 
work with static arrays. Which is likely what you expected.


Also note that due to autodecoding, ElementType says `dchar` for 
strings. ElementEncodingType should be the choice if you are looking for 
the array element type. But you could also use the techniques specified 
here (and might be less confusing).


But, if std.range is imported, a static array does indeed get a 'front' 
member. It doesn't satisfy isInputRange, but it does have a 'front' 
element.


Because you can't pop the front of a static array. front works because a 
static array automatically casts to a normal array (there is no 
specialized overload for static arrays).


The situation is still confusing though. If only 'std.range.ElementType' 
is imported, a static array does not have a 'front' member, but 
ElementType still gets the correct type. (This is where the 
documentation says it'll return void.)


You are maybe thinking of how C works? D imports are different, the code 
is defined the same no matter how it is imported. *your* module cannot 
see std.range.primitives.front, but the range module itself can see that 
UFCS function.


This is also why ElementType will fail on types that have UFCS front 
defined, but not imported directly from std.range.primitives.


-Steve


Re: How to get the element type of an array?

2020-08-25 Thread Jon Degenhardt via Digitalmars-d-learn

On Tuesday, 25 August 2020 at 05:02:46 UTC, Basile B. wrote:
On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt 
wrote:
What's the best way to get the element type of an array at 
compile time?


Something like std.range.ElementType except that works on any 
array type. There is std.traits.ForeachType, but it wasn't 
clear if that was the right thing.


--Jon


I'm curious to know what are the array types that were not 
accepted by ElementType ( or ElementEncodingType ) ?


Interesting. I need to test static arrays. In fact 'ElementType' 
does work with static arrays. Which is likely what you expected.


I assumed ElementType would not work, because static arrays don't 
satisfy 'isInputRange', and the documentation for ElementType 
says:


The element type is determined as the type yielded by r.front 
for an object r of type R. [...] If R doesn't have front, 
ElementType!R is void.


But, if std.range is imported, a static array does indeed get a 
'front' member. It doesn't satisfy isInputRange, but it does have 
a 'front' element.


The situation is still confusing though. If only 
'std.range.ElementType' is imported, a static array does not have 
a 'front' member, but ElementType still gets the correct type. 
(This is where the documentation says it'll return void.)


--- Import std.range ---
@safe unittest
{
import std.range;

ubyte[10] staticArray;
ubyte[] dynamicArray = new ubyte[](10);

static assert(is(ElementType!(typeof(staticArray)) == ubyte));
static assert(is(ElementType!(typeof(dynamicArray)) == 
ubyte));


// front is available
static assert(__traits(compiles, staticArray.front));
static assert(__traits(compiles, dynamicArray.front));

static assert(is(typeof(staticArray.front) == ubyte));
static assert(is(typeof(dynamicArray.front) == ubyte));
}

--- Import std.range.ElementType ---
@safe unittest
{
import std.range : ElementType;

ubyte[10] staticArray;
ubyte[] dynamicArray = new ubyte[](10);

static assert(is(ElementType!(typeof(staticArray)) == ubyte));
static assert(is(ElementType!(typeof(dynamicArray)) == 
ubyte));


// front is not available
static assert(!__traits(compiles, staticArray.front));
static assert(!__traits(compiles, dynamicArray.front));

static assert(!is(typeof(staticArray.front) == ubyte));
static assert(!is(typeof(dynamicArray.front) == ubyte));
}

This suggests the documentation for ElementType not quite correct.