On Saturday, 6 January 2018 at 23:32:42 UTC, Paul Backus wrote:
On Saturday, 6 January 2018 at 03:38:35 UTC, codephantom wrote:
or even..
a.append( s.to!ConvertToElementType(a) );
That's not valid code of course, but the semantics are all
contained in that single chunk.
This works:
import
On Saturday, 6 January 2018 at 03:08:19 UTC, Ali Çehreli wrote:
I agree with your point as well.
A better name can help there a little.
void ConvertAndAppend(T, S)(ref T[] arr, S s) {
arr ~= s.to!T;
}
problem solved ;-)
btw. I never thought that I would be able (or actually..willing)
On Saturday, 6 January 2018 at 03:08:19 UTC, Ali Çehreli wrote:
It's hard to find a balance between fully explicit and fully
automatic. I find myself going back and forth between those two
extremes.
Ali
Code is something that humans write and read (and read far more
than write).
So I pref
On Saturday, 6 January 2018 at 01:33:11 UTC, Ali Çehreli wrote:
One solution is to wrap ~= in a function template. Now the
conversion is automatically made to the element type of the
array:
...
.
I think append() could be a part of std.array but I can't find
anything like that in Phobos.
On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote:
On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley
wrote:
double[] D = [3.14159];
Can you guess what D is? :D
It took me a while but I finally came up with "a slice of pi"
a slice of pi is irrational.
On Friday, 29 December 2017 at 09:38:50 UTC, Vino wrote:
Let me re-frame the question with an example, as the Dsafe
the below line of code is considered as unsafe(Pointer
arithmetic), so let imagine that we have several similar line
of code, how do we find such unsafe line, does the compile
On Friday, 29 December 2017 at 08:21:10 UTC, Vino wrote:
Hi All,
Is there a way to find or test which line of a give code is not
safe(possible memory corruption).
From,
Vino.B
That question needs to be refined ;-)
On Wednesday, 20 December 2017 at 13:41:06 UTC, Vino wrote:
Hi Ali,
Thank you very much, below are the observations, our program
is used to calculate the size of the folders, and we don't see
any improvements in the execution speed from the below test,
are we missing something. Basically we
On Wednesday, 20 December 2017 at 14:30:55 UTC, bauss wrote:
I can't seem to find anything in Phobos that allows you to
specify custom formats for dates.
sometimes it's just better to take control of things yourself ;-)
https://forum.dlang.org/post/dmxdtciktpggcxybd...@forum.dlang.org
so I have a text file containing 3 lines(e.g):
5, "hello", 4.3
"hello", 4.3
"hello", "world", 1, 2, 3, 5.5
Now I want to create tuples from each line.
However, (using line 1 as example), I get:
Tuple!string("5, \"hello\", 4.3")
but I really want:
Tuple!(int, string, double)(5, "hello", 4.3)
On Tuesday, 19 December 2017 at 10:24:47 UTC, Vino wrote:
foreach (d; taskPool.parallel(xxx,20)) : As in Windows 2008
whatever value is set for the parallel the total number of
threads does not increase more than 12.
So not sure if this is correct, so can any one explain me on
same.
som
On Tuesday, 19 December 2017 at 01:30:07 UTC, Mike Franklin wrote:
writeln(S.j);
// Error: Instance symbols cannot be used through types.
I don't understand why you would say that is a bug.
i.e.
//
import std.stdio;
struct S
{
int j;
}
void main()
{
writeln(typeof(S.j
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote:
alias a = s.i; // illegal, s.i is an expression
Actually, as I understand it, the example provided in 10. is
legal (because it aliases a type), and the example provided in 3.
is illegal (because it aliases an expression)
perhaps t
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote:
alias a = s.i; // illegal, s.i is an expression
alias a = s.i; (this is an alias to a type, since s.i is an int)
Hence it is actually 'legal', as far as I understand.
i.e... "AliasDeclarations create a symbol that is an alias for
On Saturday, 16 December 2017 at 14:14:28 UTC, Vino wrote:
Yes, will give a try.
From,
Vino.B
well, this sort of gets there ;-)
// -
module test;
import std.stdio;
import std.variant;
import std.typecons;
import std.conv;
import std.string;
void main()
{
Variant[] arr;
auto x
On Sunday, 17 December 2017 at 08:32:20 UTC, Ryan David Sheasby
wrote:
Hey guys. First time poster here. I've searched high and low
but can't seem to find a simple sleep/delay/wait/pause function
in the core or in phobos. The most recent information I can
find about it is this forum post from 1
On Sunday, 17 December 2017 at 08:26:03 UTC, Jonathan M Davis
wrote:
assert(0) does indeed turn into a HLT instruction in -release
mode (as does any assertion that's known to be false at compile
time). It's a special case intended for marking code that's
supposed to be unreachable. Without -rel
On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote:
If you return inside a scopeguard though, the exception (or
error!) is swallowed. https://run.dlang.io/is/GEtQ6D
The scope guard will not 'swallow' it, if you use -release mode.
Which suggests to me, that assert(0) operates differe
On Friday, 15 December 2017 at 17:21:55 UTC, Vino wrote:
Hi All,
Request your help, Is it possible to an template array
something similar as below so that we can insert any type of
value(string, int etc). If possible can you provide me a
example of how to define such array.
Array!(Tuple!(
On Wednesday, 13 December 2017 at 18:24:09 UTC, Thomas wrote:
Or is there a better solution for tracing the error position
from root till the branch ?
Speaking of tracing exceptions, here's my favourite one .. so far
;-)
(I mean come on.. debugging is great fun!)
btw. If you compile/run th
On Wednesday, 13 December 2017 at 07:35:40 UTC, Jonathan M Davis
wrote:
In general, you probably want to cast the SysTime to a DateTime
if you're going to do something like that.
yes, I would agree ;-)
Of course the intention was not really to just format it the same
way as Clock.currTime() d
On Tuesday, 12 December 2017 at 22:20:41 UTC, datboi wrote:
Hi, I'm learning D (obliviously)
learning D in an oblivious manner can be difficult ;-)
On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote:
Hi All,
Request out help on date formatting, I have code which output
the date and time as below , i we need it without the last few
numbers.,ie "-MMM-DD HH:MM:SI"
Output : 2017-Sep-06 16:06:42.7223837
Required Output : 2017-Sep
On Tuesday, 12 December 2017 at 02:15:13 UTC, codephantom wrote:
just playing around with this
also...in case you only want to read n bytes..
// ---
module test;
import std.stdio, std.file, std.exception;
import std.datetime.stopwatch;
void main()
{
string fil
On Monday, 11 December 2017 at 20:51:41 UTC, Jordi Gutiérrez
Hermoso wrote:
I'd like to read from a file, one byte at a time, without
loading the whole file in memory.
just playing around with this
//
module test;
import std.stdio, std.file, std.exception;
void ma
On Saturday, 9 December 2017 at 14:49:28 UTC, Seb wrote:
randomSample doesn't sort its returned range
Not by design, however, because it samples in the order that the
elements appear, *if* those elements are already sorted (whether
by design or explicately sorted), then the results of the
r
On Saturday, 9 December 2017 at 14:18:00 UTC, Seb wrote:
Yeah, you are very welcome. It's a bit hidden in the docs:
Yes. Thanks for that.
After lots of reading, and testing, I managed to get a simple,
one liner ;-)
(doesn't seem like .release is needed though.)
// ---
auto draw8Nu
On Saturday, 9 December 2017 at 04:31:33 UTC, SimonN wrote:
Yes, this works, and your algorithm would even accept arbitary
random-access ranges, not merely arrays.
Would be nice if I could do it all as a 'one liner':
//
int[] draw8Numbers()
{
import std.algorithm.sorting : sor
On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote:
`sort` returns a SortedRange of ushorts, not an array of
ushorts. Make it:
```
import std.array : array;
return sort(numbers.take(8)).array;
```
--Ryan
That's it!
Thanks Ryan.
On Friday, 8 December 2017 at 19:13:20 UTC, vino wrote:
Hi,
The code is same just copy pasted the code form Windows 7 into
Windows 2003 and executed, in Windows 7 the log file is of size
0 where as in windows 2003 the log file is of size 2 byte where
the log file in both the server is empty.
Anyone got ideas on how to get sort() working in the *return*
statement?
//
ushort[] draw8Numbers()
{
import std.meta : aliasSeqOf;
import std.range : iota;
ushort[] numbers = [ aliasSeqOf!(iota(1,46)) ];
import std.random : randomShuffle;
randomShuffle(numbers)
On Wednesday, 6 December 2017 at 09:59:12 UTC, codephantom wrote:
On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote:
This is question not directly related to language concepts,
it's got more to do with the application. I would appreciate
if anyone would point to me how I could optimize
On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote:
This is question not directly related to language concepts,
it's got more to do with the application. I would appreciate if
anyone would point to me how I could optimize this bit of code
Compile it with ldc ;-)
On Tuesday, 5 December 2017 at 13:31:17 UTC, Marc wrote:
Does D have a native function to capitalize only the first
letter of the word? (I'm asking that so I might avoid reinvent
the wheel, which I did sometimes in D)
//
module test;
import std.stdio;
void main()
{
strin
On Monday, 4 December 2017 at 11:30:02 UTC, codephantom wrote:
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote:
The original program is as below
Error:
FunTest.d(52): Error: template FunTest.ptProcessFiles cannot
deduce function from argument types !()(string,
Array!(Tuple!(string, s
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote:
The original program is as below
Error:
FunTest.d(52): Error: template FunTest.ptProcessFiles cannot
deduce function from argument types !()(string,
Array!(Tuple!(string, string)) function(string FFs,
string Step, int DirAged), File,
On Saturday, 2 December 2017 at 14:23:48 UTC, Vino wrote:
Hi,
Even tried the Option "Run with Highest Privilege" but no
luck. and also tried with option "Configure for : Windows Vista
, Windows Server 2008"
From,
Vino.B
You haven't accidently ticked the 'Do not store password' option?
Th
On Saturday, 2 December 2017 at 07:48:14 UTC, Vino wrote:
Even tried with the below code, it works manually but not via
Windows scheduler with option "Run whether user is logged on or
not"
Are you using appropriate credentials in the scheduled task?
On Saturday, 2 December 2017 at 04:28:57 UTC, Wanderer wrote:
Thanks! This works. But it seems a little bit suspicions that
D's type for handler function has `nothrow` `@nogc` and
`@system`. I wonder why is that?
During execution of that handler, it make sense to prohibit the
allocation of an
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote:
Is there any method to cleanup on Ctrl-C?
// --
import std.stdio;
import core.thread;
extern(C) void signal(int sig, void function(int));
extern(C) void exit(int exit_val);
extern(C) void handle(int
On Friday, 24 November 2017 at 14:30:44 UTC, A Guy With a
Question wrote:
I would have expected 0 to be the default value. What's the
logic behind having them being NaN by default?
https://dlang.org/spec/type.html
http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723
On Thursday, 30 November 2017 at 00:52:25 UTC, codephantom wrote:
...
sorry, don't know how the int * got in there ;-)
Anyway..who said you can't use pointers in D?
Just change:
//SomeType bar = foo;
SomeType * bar = &foo;
On Thursday, 30 November 2017 at 00:40:51 UTC, David Colson wrote:
Hello all!
I'm getting settled into D and I came into a problem. A code
sample shows it best:
class SomeType
{
string text;
this(string input) {text = input;}
}
void main()
{
SomeType foo = new SomeType("Hello");
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:
Hi All,
Can you please provide me some example on who to validate an
email address as the document dose not have an example for the
same
Ex: vino.bhee...@hotmail.com
Conditions :
The domain should contain only "hotmail.com"
The ema
On Tuesday, 28 November 2017 at 22:42:27 UTC, Mike Wey wrote:
isMail only checks the formatting of the email address and
optionally if the domain has a MX record.
I don't believe MX validation (checkDns) is implemented yet.
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:
Hi All,
Can you please provide me some example on who to validate an
email address as the document dose not have an example for the
same
Ex: vino.bhee...@hotmail.com
Conditions :
The domain should contain only "hotmail.com"
The ema
On Tuesday, 28 November 2017 at 19:32:40 UTC, Vino wrote:
Can you provide me a example, as the link does not have any
examples.
From,
Vino.B
btw... yes documentation is an acknowledged issue with regards to
phobos...but..that aside...it can also be useful (and wise) to
look at the unit t
On Tuesday, 28 November 2017 at 05:10:39 UTC, bauss wrote:
null != void
also...void is a completely useless concept for initialisation.
what can you determine about the nothingness of void? ... nothing.
writeln(typeof(void).stringof); // ?? what do I know now? nothing.
vs
Nullable!int x;
On Tuesday, 28 November 2017 at 05:10:39 UTC, bauss wrote:
null != void
"initialized or not?" != void
On Saturday, 25 November 2017 at 15:34:21 UTC, John Chapman wrote:
Is there any way of determining whether a variable has been
initialized or not? For example, if something is declared like
this:
int x = void;
can I check if it's void before I use it, say, in a function
it's been passed to
On Friday, 24 November 2017 at 05:01:17 UTC, Basile B. wrote:
On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote:
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:
If I add -noboundscheck flag all works fine.
dmd version is 2.076.1
Why -betterC flag not 'include' -nobo
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:
If I add -noboundscheck flag all works fine.
dmd version is 2.076.1
Why -betterC flag not 'include' -noboundscheck flag?
It's bug or in some cases it's useful?
Interestingly, ldc2 will compile this ok, without the
-noboundscheck
On Monday, 20 November 2017 at 08:37:32 UTC, kerdemdemir wrote:
bool boolList[] = { a, b, c };
D alternative(at least my D alternative) seem long. Is there
any better way for
initialing and pushing values at the same time.
Erdem
Your use of the appender method suggest to me you want to be
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim
Grostad wrote:
Uhm, no? What do you mean by 'primary focus of program design'
and in which context?
I the context that, this is specifically what Stroustrup says in
his book (The Design and Evolution of C++ 1994)
"Simula's class
On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim
Grostad wrote:
No, classes is a powerful modelling primitive. C++ got that
right. C++ is also fairly uniform because of it.
Yes, I agree that classes are a powerful modelling primitive, but
my point was that Stroustrup made classes the
On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote:
The reason he can dismiss D, so easily, is because of his
starting premise that C is flawed. As soon as you begin with
that premise, you justify searching for C's replacement, which
makes it difficult to envsion something like D.
On Wednesday, 15 November 2017 at 09:26:49 UTC, Ola Fosheim
Grøstad wrote:
I don't think Go is much affected by the corporate…
Umm
"We made the language to help make google more productive and
helpful internally" - Rob Pike
https://www.youtube.com/watch?v=sln-gJaURzk
2min:55sec
To be
On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad
wrote:
It [C]is flawed... ESR got that right, not sure how anyone can
disagree.
Well I 'can' disagree ;-)
Is a scalpel flawed because someone tried to use it to screw in a
screw?
Languages are just part of an evolutionary cha
On Tuesday, 14 November 2017 at 04:31:43 UTC, Laeeth Isharc wrote:
He mentions D, a bit dismissively.
http://esr.ibiblio.org/?p=7724&cpage=1#comment-1912717
The reason he can dismiss D, so easily, is because of his
starting premise that C is flawed. As soon as you begin with that
premise, you
On Monday, 13 November 2017 at 06:25:20 UTC, Tony wrote:
I am on Ubuntu 16.04. Thanks, I didn't know that "producing a
core file" was configurable, and it appears that it isn't.
ok. that's because Ubuntu is not (by default) setup for
developers.
But you can enable core dump for your executab
On Monday, 13 November 2017 at 05:01:18 UTC, Tony wrote:
I am getting the message from my program execution:
"Segmentation fault (core dumped)"
But I don't see a core file in the current directory or in my
home directory. Is there one somewhere? Would I be able to do
anything meaningful with
On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote:
As others have said, rename the .d file, since files are
considered modules. I have since changed my notes to reflect
this change. Sorry for the confusion.
Chuck Allison
When coming to a new language I tend to write lots of
On Wednesday, 8 November 2017 at 12:48:41 UTC, codephantom wrote:
Apparently its a bug in LDC (but personally, it's a bug I like).
mistyped: I meant a bug in GDC, not LDC.
On Wednesday, 8 November 2017 at 12:17:14 UTC, bauss wrote:
That's because the module name becomes `write` then.
yeah I knew that.
I was trying to demonstrate how (when the module name is
'write'), then the compiler is ok with:
o.write;
but not:
write(o);
even though semantically they a
On Wednesday, 8 November 2017 at 03:33:08 UTC, bauss wrote:
--
Compiles fine with DMD: https://dpaste.dzfl.pl/95b896aa242f
ahh.. that site saves it with some random temporary file name I
assume.
If it saved it as writ
On Wednesday, 8 November 2017 at 03:33:08 UTC, bauss wrote:
--
Compiles fine with DMD: https://dpaste.dzfl.pl/95b896aa242f
you saved it as?: write.d
you didn't add in a module statement?
and it compiled??
On Tuesday, 7 November 2017 at 21:32:26 UTC, Adam D. Ruppe wrote:
On Tuesday, 7 November 2017 at 21:25:00 UTC, dan wrote:
I looked in my distribution's object.d (debian stretch, gdc, in
Did you import std.stdio in the file?
If so, it is calling the std.stdio.write on the object (this is
call
On Tuesday, 31 October 2017 at 04:27:27 UTC, Joel wrote:
Ok, thanks guys.
why not throw in some UFCS too...just because you can ;-)
import std.stdio;
void main()
{
int foo;
if (foo.bar != 0) // would be nice if I could do: (int
foo.bar != 0)
{
throw new Exception("foo.b
Can anyone help me to understand why the format in the second
writeln below, does not format the output with commas?
void main()
{
import std.stdio, std.format;
writeln( format("%,.1f", 84543432.951172) ); // 84,543,433.0
writeln( format("%,.0f", 84
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote:
I want to use C++ libraries for machine learning and deep
learning. How do I add C++ libraries to my d code.
on FreeBSD, I use:
for C static binding:
--
clang -c sample.c
dmd -L-lc foo.d sample.o
or
ldc -L-lc foo.d
70 matches
Mail list logo