Hello. I want to parallelize a computation which has two for
loops, one nested within another. All
inner-loop-param+outer-loop-param combinations can be computed
independent of one another.
As I suspected,
[https://forum.dlang.org/post/xysyidbkjdinclmrx...@forum.dlang.org](this forum post)
On Wednesday, 21 November 2018 at 18:36:06 UTC, Vladimirs
Nordholm wrote:
https://github.com/vladdeSV/termcolor-d
https://github.com/jamadagni/textattr/
Saw a library recently which allowed you to color text, but it
had an odd syntax.
Maybe the documentation, in trying to be exhaustive,
On Friday, 9 November 2018 at 22:28:28 UTC, JN wrote:
It looks to me like the textattr.d is all that is needed?
Should be easy to put it in a separate package that could be
uploaded to dub registry.
Yes indeed textattr.d is all that is needed! For C too
textattr.c|h are all that are needed.
On Thursday, 8 November 2018 at 19:26:15 UTC, Bastiaan Veelo
wrote:
Cool, must remember this in case I need it one day. Do you have
plans to add it to the dub registry?
Don't know how. Can follow instructions if provided. Does DUB
also allow multi-language libs one of which is D?
++ and Python
use the C code for internal processing but the D code is a
separate implementation for easy inclusion of textattr.d in a D
compilation command without requiring any external linking.
Copyright: Shriramana Sharma, 2018
License: BSD-2-Clause
On Wednesday, 25 October 2017 at 00:35:29 UTC, Ali Çehreli wrote:
> char[] name = "/tmp/XX".dup;
remain valid. The actual issue is the missing '\0'. So,
consider toStringz in this case:
https://dlang.org/library/std/string/to_stringz.html
Thanks for your reply, but can you clarify
Hello. I want a function to be able to take any arguments like
write() and print them out but quoting string arguments of length
more than 1. So I write the following quote:
import std.stdio;
string myFunc(string arg) { return '\"' ~ arg ~ '\"'; }
void myWrite(T ...)(T args)
{
foreach
On Sunday, 22 October 2017 at 15:21:37 UTC, Shriramana Sharma
wrote:
For my program right now I'm using a souped-up version using a
static array:
char[20] name = "/tmp/XX";
Hmm I was wondering if I needed it to be static, and verily,
substituting:
char[] name = "/
On Saturday, 17 January 2015 at 17:16:41 UTC, Tobias Pankrath
wrote:
You're looking for core.sys.posix.stdlib : mkstemp.
I think that should be used by std.stdio.File as well, care to
create an enhancement request in bugzilla?
Though this thread is old, I ran into the issue when wanting to
Have reported https://issues.dlang.org/show_bug.cgi?id=17907
On Tuesday, 17 October 2017 at 08:26:12 UTC, Daniel Kozak wrote:
You can:
import fun : fun;
Yes I found this but it is unnecessarily verbose.
At the same time I also find that it is possible to declare a
struct or class with the same name as module:
str.d:
struct str { int a; }
strmain.d:
On Tuesday, 17 October 2017 at 07:33:15 UTC, evilrat wrote:
Compiler made that way so it doesn't guess or assume too much,
because later on it will bite you when you don't even expect
that, and in some unpredictable place too.
Can you give an example for when it will bite me? It seems very
Hello.
fun.d:
import std.stdio;
void fun() { writeln("Hello"); }
main.d:
import fun;
void main() { fun(); }
$ dmd -oftest fun.d main.d
main.d(2): Error: function expected before (), not module fun of
type void
Why can't I use a function of the same name as the module? IIUC
import fun
On Saturday, 14 October 2017 at 17:17:41 UTC, Petar Kirov
[ZombineDev] wrote:
Why not simply add extern (C) wrappers for your D code? I see
no point of using C, unless you want to be portable to arcane
architectures.
With this approach you'll have both the portability of C and
the advantages
On Saturday, 14 October 2017 at 14:51:12 UTC, Adam D. Ruppe wrote:
My terminal.d works with most that stuff.
Yes I did look into existing solutions. Mainly my desire was not
to work in D alone but something available at command line and as
a library for shell-scripts and other languages too.
Hello. I prepared a utility/library to output ANSI escape codes
for terminal text attributes with capabilities as advertised at
https://sites.google.com/site/jamadagni/files/temp/textattr-usage.html. (AFAIK this set of capabilities does not exist already in any existing package.)
This was
s = ta("s)";
>
> and using s all over the place will result in an allocation each time that
> s is used. However, you can combine the two and avoid that problem. e.g.
>
> enum e = ta("s");
> string s = e;
>
> The ta is run at compile time, and it's only evaluated once.
--
Shriramana Sharma, Penguin #395953
ag0aep6g wrote:
> On 03.03.2016 07:12, Shriramana Sharma wrote:
>> string ta(string s) { return s ~ "1"; }
>> template ta(string s) { enum ta = ta(s); }
>
> In `ta(s)` here, `ta` is the enum itself again. It's similar to `int x =
> x;`. Can't do that, of cours
cted.
Filed https://issues.dlang.org/show_bug.cgi?id=15764 just for the record.
--
Shriramana Sharma, Penguin #395953
name approach, so it brings us back
to the question as to why the name can't be re-used.
--
Shriramana Sharma, Penguin #395953
r: template instance .ta!"s" error instantiating
Please clarify what I am doing wrong? Thanks!
--
Shriramana Sharma, Penguin #395953
to a
template at compile time, and I (for obvious reasons) don't want to be
initialized at every function call, do I have to declare it `static
immutable`?
--
Shriramana Sharma, Penguin #395953
cation) every time the function is run?
--
Shriramana Sharma, Penguin #395953
'this'
(9): Error: cannot use syntax 'alias this = myCtorsInst', use 'alias
myCtorsInst this' instead
This is not what alias <> this is supposed to do, right? So how am I
supposed to get the mixed in ctors work?
--
Shriramana Sharma, Penguin #395953
Jacob Carlborg wrote:
> Looks like a limitation in the language.
Apparently already reported as well:
https://issues.dlang.org/show_bug.cgi?id=11500
--
Shriramana Sharma, Penguin #395953
g
that I cannot use ~ inside a @nogc function?
--
Shriramana Sharma, Penguin #395953
g argument types (int)
What is the problem in calling the mixed-in ctor?
--
Shriramana Sharma, Penguin #395953
of `immutable` was: never changes, whether via this
interface or otherwise. How does then the above work?
Using DMD 2.0.69.2 on Kubuntu 64 bit.
--
Shriramana Sharma, Penguin #395953
eded to make such a
union. But already making a union is breaking the type system in a way, no?
--
Shriramana Sharma, Penguin #395953
John Colvin wrote:
> Strictly speaking you aren't calling a constructor there, you're
> writing a struct literal.
Why do you say I'm not calling a constructor?
And that still doesn't answer the question of why can't we have an automatic
field-wise constructor for classes...
--
Shri
John wrote:
> It's nothing to do with the @property attribute. So you need to
> define a constructor. Also, use "new" when creating instances.
Thanks Simon and John. First actual usage of D classes and mistaken
assumption that C++ syntax is valid. :-)
--
Shriramana Sharma, Penguin #395953
:
std.regex.matchAll(R, RegEx)(R input, RegEx re) if (isSomeString!R &&
is(RegEx == StaticRegex!(BasicElementOf!R)))
If I use `auto` all is fine. Why is it impossible for a Regex object to be
`immutable`?
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> Why is it impossible for a Regex object to be
> `immutable`?
I find that I can't declare it as `const` either... This is most curious!
--
Shriramana Sharma, Penguin #395953
defined. Why can't the field-wise functionality be automatic for classes
too?
--
Shriramana Sharma, Penguin #395953
much that I cannot
create an immutable or const symbol referring to a Regex object but that I
cannot use it with matchAll etc. But of what use is a Regex object if it
cannot be used with matchAll etc?
--
Shriramana Sharma, Penguin #395953
re it immutable for
> example. I didn't look at the implementation to identify a
> precise cause though.
You mean ctRegex!(), but nope:
immutable numbers = ctRegex!r"\d+";
or doing const there gives the same error and using auto doesn't.
--
Shriramana Sharma, Penguin #395953
MD had something like -fdata-sections -ffunction-
sections, passing --gc-sections might be able to slim that down, I dunno...
--
Shriramana Sharma, Penguin #395953
bulky.
I suppose I could always maintain both the C and D versions separately.
--
Shriramana Sharma, Penguin #395953
applicable for classes.
Am I stuck with having to use the () for this even in D?
--
Shriramana Sharma, Penguin #395953
ylib and all that, but of course now I
realize that that is only telling the *linker* about the lib. How do I tell
the compiler to the lib? If Python CTypes can query and find out any library
with the SO filename I throw at it, can't a D compiler?
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> What I desire to do is be able to call a C library from a D template like
> octal to compute a string at compile time.
To be more explicit, I wrote a library in C since it's much leaner size-wise
than the D code (although admittedly much *much* more tedious to
:
1) Why exactly can't the compiler call a C function at compile time whereas
it can call a D function?
2) ... which itself only in the end calls that very same C
function IIANM?
I see druntime/import/core/math.d l 91:
double sqrt(double x); /* intrinsic */
--
Shriramana Sharma, Penguin
n libc?
--
Shriramana Sharma, Penguin #395953
Rikki Cattermole wrote:
> It will make it very hard to split std.math up.
I have no desire to split std.math up. :-)
What I desire to do is be able to call a C library from a D template like
octal to compute a string at compile time.
Is this possible or not?
--
Shriramana Sharma, Peng
http://dlang.org/spec/template.html#TemplateTupleParameter
says that an AliasSeq (wording needs to be updated) "is a sequence of any
mix of types, expressions or symbols."
Is a type not a symbol? I mean, alias can refer to both, no?
--
Shriramana Sharma, Penguin #395953
of specialization means an exact match but in the context of
constraints it means implicitly convertible, no? The specialization section
under http://dlang.org/spec/template.html is not very clear about this IMHO.
--
Shriramana Sharma, Penguin #395953
a new tuple that refers to the same
> objects as the previous one. So it doesn't deep copy... but
> remember this is irrelevant to any D program
I realize that but just wanted to know whether the word slicing is used in
this context in the same sense as elsewhere.
--
Shriramana Sharma, Penguin #395953
e name and complementary
constraints right?
--
Shriramana Sharma, Penguin #395953
marked @system? Only because one cannot be sure that the
input point refers to a valid null-terminated string?
--
Shriramana Sharma, Penguin #395953
. Or is
it just because the other C libraries haven't changed (!)...
--
Shriramana Sharma, Penguin #395953
since it relates to compiler internals.)
--
Shriramana Sharma, Penguin #395953
a single type, I know I have to put the specialization as in:
void func(T: int)(T t) { writeln(2); }
and that works, but how to make it more generic than that?
--
Shriramana Sharma, Penguin #395953
convertible to const(char)*?
--
Shriramana Sharma, Penguin #395953
Basile B. wrote:
> without the parens, 'const' means that the function doesn't
> mutate the state of the object or of the struct it's declared in.
> So it's meaningless for a global function.
Thank you people.
--
Shriramana Sharma, Penguin #395953
afe D type encapsulating a C string but
avoid allocation – is it possible or not?
Thanks!
--
Shriramana Sharma, Penguin #395953
I'm trying to interface to a C function:
extern(C) const char * textAttrN(const char * specString, size_t n);
and getting the error:
Error: function .textAttrN without 'this' cannot be const
Please advise as to what I'm doing wrong?! :-(
--
Shriramana Sharma, Penguin #395953
Rikki Cattermole wrote:
> string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to append to the
returned string using ~= or such? In which case it is not safe, right?
--
Shriramana Sharma, Penguin #395953
> > it is a poor design. fromStringz
> is explicit about this assumption.
OK thank you.
--
Shriramana Sharma, Penguin #395953
Jakob Ovrum wrote:
> The example should be restructured to `return 1;`
> from `main`.
https://github.com/D-Programming-Language/phobos/pull/3875
--
Shriramana Sharma, Penguin #395953
not be a valid
identifier no?
--
Shriramana Sharma, Penguin #395953
Jakob Ovrum wrote:
> Where's the reference documentation?
There's a README: http://code.dlang.org/packages/consoled, and the source
does seem to have DDoc comments...
--
Shriramana Sharma, Penguin #395953
http://dlang.org/phobos/std_getopt.html has a line in an example saying
exit(1);
Surely this works only if core.stdc.stdlib is imported? Should the example
be modified to show the import?
And is exit() the canonical way to exit the current process even in D?
--
Shriramana Sharma, Penguin
oposed library documentation, core.stdc is mentioned:
https://dlang.org/library/index.html, but core.sys.posix is not...
[sigh] This is why D's API version is still 0, as in 2.0.69.2 (at least my
interpretation of the weird zero-prefixed numbering being used).
--
Shriramana Sharma, Penguin #395953
In my recent search for D's equivalent of isatty, I found out that there is
a core.sys.posix module only by rgrepping under /usr/include/dmd. Why isn't
there a documentation page http://dlang.org/phobos/core_sys.html whereas
lots of other core.* modules are documented?
--
Shriramana Sharma
under core.sys.posix.unistd, and I suppose I can just pass to
it the output of std.stdio.File.getFP.
Is there any other way to do the desired test? Or is this the recommended
way?
--
Shriramana Sharma, Penguin #395953
son, alias sequences
can not "contain" or "encapsulate" expressions in un-evaluated form in any
way (unlike, say
http://docs.sympy.org/dev/modules/core.html#sympy.core.mul.Mul) in that the
components of the expression are lost by the time the AliasSeq gets defined.
--
Shr
is not a module being imported by anything else or even being compiled to a
library which would need to be later imported. In which case, why does it
insist that the file should be given a valid module name?
--
Shriramana Sharma, Penguin #395953
to be inferred as an `int`.
I thought that integer literals used to be inferred as the smallest integral
type that can fit them – am I mistaken?
--
Shriramana Sharma, Penguin #395953
Adam D. Ruppe wrote:
> but yours won't because to!ubyte(spec, 6) might just be > 240.
Thanks for that explanation. That's clear now.
--
Shriramana Sharma, Penguin #395953
that the AliasSeq is presented to the function body *as if* it
were a Tuple!(int, double) in that it can be accessed using [0] [1] etc, but
it is not *really* (in the sense of RTTI) a Tuple, is it? In which case,
what is it? Is it another "Voldemort" type?
--
Shriramana Sharma, Penguin #395953
2).stringof);
all print "1 + 2" (without the quotes) so it's not a simple compiler dumps
to string thing, but still I don't understand what this can be useful for...
--
Shriramana Sharma, Penguin #395953
mentary" topic, I asked it here. I
posted some "elementary" questions to D.learn even yesterday...
--
Shriramana Sharma, Penguin #395953
urself...
--
Shriramana Sharma, Penguin #395953
Seq stores only the
resultant value of the expression and not the expression itself (which may
be valid or not).
--
Shriramana Sharma, Penguin #395953
...
--
Shriramana Sharma, Penguin #395953
or not, what should I use to determine whether something is a
value or not?
These would be useful to identify the kind of a member of an AliasSeq...
--
Shriramana Sharma, Penguin #395953
cym13 wrote:
> So, no, it's not a Voldemort type, it's exactly what the compiler
> tells you it is: the sequence of types (int, double).
Hmmm it seems to me that if it's not a runtime-valid type, then typeof()
shouldn't work at all...
--
Shriramana Sharma, Penguin #395953
Ali Çehreli wrote:
> http://ddili.org/ders/d.en/enum.html#ix_enum.EnumMembers,%20std.traits
Ali that's great! Thank you!
--
Shriramana Sharma, Penguin #395953
rumbu wrote:
> Constant folding: a is evaluated at compile time to + infinity.
Hmm... I guess the compiler figures that if someone is hardcoding that
expression then they don't want to see an exception. Thanks for the
explanation.
--
Shriramana Sharma, Penguin #395953
?
--
Shriramana Sharma, Penguin #395953
is situation? Thanks.
--
Shriramana Sharma, Penguin #395953
ple = Tuple!(int, string);
FooTuple footu = FooTuple(1, "one");
auto ttp =
--
Shriramana Sharma, Penguin #395953
r a "Like" or "Upvote" button on
this forum. :-) Thanks!
--
Shriramana Sharma, Penguin #395953
;foo" == "goo"
Clearly, the AliasSeq is not able to store the expressions themselves since
they are automatically evaluated at compile time. It stores only the values
that the expressions evaluate to. Further, expressions which are not
evaluable at compile time aren't permitted in t
act nature of the object produced by .tupleof is still a mystery to
me. Would be good if someone threw more light on it.
Also: what is the use of presenting the members of a struct/class as a
tuple? Is it iteration?
--
Shriramana Sharma, Penguin #395953
std.stdio;
import std.math;
void main()
{
FloatingPointControl fc;
fc.enableExceptions(fc.severeExceptions);
real a = 1.0 / 0.0;
writeln(ieeeFlags.divByZero);
}
--
Shriramana Sharma, Penguin #395953
roundToNearest
which, I presume, ties to even.
Is there a difficulty in providing the option for tieing away from zero?
Thanks.
--
Shriramana Sharma, Penguin #395953
not clear what subnormalException refers to. Is it the "denormal
operand exception" mentioned at
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_handle.html?
Thanks.
--
Shriramana Sharma, Penguin #395953
embers. This will both help avoid the above hack and
only then will his reference to %s and %d having different effects for enums
be true...
Thanks once more to Ali for his book and you people for the replies!
--
Shriramana Sharma, Penguin #395953
uot;, suit); }
}
But I'm getting 0 1 2 3. Kindly advise.
--
Shriramana Sharma, Penguin #395953
ut D than me to do the edit and
respond here too.
Thanks.
--
Shriramana Sharma, Penguin #395953
n `switch`) is not executed if `break` happens.
So:
try { code_which_can_throw(); }
catch { handler(); }
default { only_if_didnt_throw(); }
finally { mandatory(); }
How does that look?
--
Shriramana Sharma, Penguin #395953
Hello. The following code works fine for me:
#! /usr/bin/env rdmd
import std.stdio;
void main() { writeln(2); }
So what is the use of the --shebang option of rdmd?
http://dlang.org/rdmd.html does not shed much light on this.
Thanks.
--
Shriramana Sharma, Penguin #395953
a D equivalent?
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> In Python one has the syntax try..except..else.. where code in the
> else clause will only be executed if an exception does not occur. (Ref:
> http://stackoverflow.com/a/22579805/1503120)
Official Python documentation:
https://docs.python.org/3/
(apart from catch).
--
Shriramana Sharma, Penguin #395953
The page http://dlang.org/exception-safe.html says:
"It's try-finally that becomes redundant."
IIUC this is because we have scope(exit).
Does this mean that `finally` should eventually be removed from the
language?
--
Shriramana Sharma, Penguin #395953
the message of 1. The graphic is too
complicated, and the significance of its components is not
self-evident.
Appreciate the work people are putting into this, though. No
offence to any artist intended...
--
Shriramana Sharma, Penguin #395953
cross-posted as I thought this is relevant to both
announce/learn.
--
Shriramana Sharma, Penguin #395953
cross-posted as I thought this is relevant to both
announce/learn.
--
Shriramana Sharma, Penguin #395953
1 - 100 of 231 matches
Mail list logo