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, 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
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
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
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
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
...
--
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
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
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
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
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
cross-posted as I thought this is relevant to both
announce/learn.
--
Shriramana Sharma, Penguin #395953
Comparing to standard compilers like GCC and Clang, the totally strange
syntax puts one off... Again, I'm not expert enough to do a PR for DMD.
--
Shriramana Sharma, Penguin #395953
for deleting them all when it itself is deleted?
--
Shriramana Sharma, Penguin #395953
that makes this more efficient? How is
this more efficient than setting the .length of the dynamic array directly?
I see there's a lot of logic going into ensureAddable() but doesn't this
logic happen within druntime for the regular dynamic arrays itself?
--
Shriramana Sharma, Penguin #395953
ect.html#.reserve>. The append
> operator is `~=`.
Thanks for that clarification. Now submitted a pull request.
--
Shriramana Sharma, Penguin #395953
to `a` should also reflect in `b`.
--
Shriramana Sharma, Penguin #395953
rsw0x wrote:
> use std.container.array
Thanks all for all the recommendations. When would one use
std.array.appender with a built-in array vs std.container.array.Array? What
are the pros and cons on either side?
--
Shriramana Sharma, Penguin #395953
Shriramana Sharma wrote:
> I'd just like to have a quick but reliable way to
> store real and int data types into a binary data file and read therefrom.
> Is there such a solution?
Wow thank you people! Nice to know I can do rawWrite and also have other
options.
BTW is there
data types into a binary data file and read therefrom. Is
there such a solution? The size of the data is fixed, but especially since I
have real values, I'd like to not write to limited fixed decimal text
format.
--
Shriramana Sharma, Penguin #395953
std.string.toStringz – why the strange name with z instead of toString0 or
toCString?
--
Shriramana Sharma, Penguin #395953
(isInputRange, Ranges))
/usr/include/dmd/phobos/std/range/package.d(3711):
std.range.zip(Ranges...)(StoppingPolicy sp, Ranges ranges) if (Ranges.length
&& allSatisfy!(isInputRange, Ranges))
I would have thought there would be no problem in creating a zip of three
arrays of equal length. What's the problem here?
--
Shriramana Sharma, Penguin #395953
anonymous wrote:
> Huh. I can't find any specification on this, but apparently the local
> overload set shadows any imported overload sets completely.
Should I file a bug on this then?
--
Shriramana Sharma, Penguin #395953
t
4. If there is a match in more than one overload set, then error
Here there is only one round(real, int) i.e. in the current module and only
one round(real) i.e. in the imported module, so as per rule 3, there should
be a clear resolution.
So why the conflict then?
--
Shriramana Sharma, Penguin #395953
(real), why is the compiler
complaining about not being able to call the overload function defined in
*this* module?
I don't see anything in http://dlang.org/module.html that says I cannot
define an overload of an imported function. Did I miss something?
--
Shriramana Sharma, Penguin #395953
points of one's program using MonoTime.currTime whose
unit is Duration.
1) Will then StopWatch be modified to use MonoTime?
2) Is StopWatch still useful?
3) Or should it also be deprecated?
--
Shriramana Sharma, Penguin #395953
In Python there is:
if __name__ == "__main__":
to allow the same source file to be treated as both an importable library
and as an executable script. In D is there any such mechanism to make a
main() compiled selectively, i.e. by some compile-time flag or such?
--
Shriramana Sharm
should replace all occurrences of `string` in arguments and
return values of functions by `const(char)[]`?
--
Shriramana Sharma, Penguin #395953
Is there a particular reason that File.byLine() returns char[] and not
string i.e. immutable(char)[]? Is it just to avoid being overly restrictive?
It seems that having to .idup it is inefficient...
--
Shriramana Sharma, Penguin #395953
Thanks people, for the replies. That's very clear now.
--
Shriramana Sharma, Penguin #395953
that but that's enough for me now...
--
Shriramana Sharma, Penguin #395953
r @property R()
/usr/include/dmd/phobos/std/regex/package.d(611): Error: inout on return
means inout must be on a parameter as well for @property R()
I'm totally not clear as to what the error about inout means, and how I can
fix this. Please advise. Thanks!
--
Shriramana Sharma, Penguin #395953
Ali Çehreli wrote:
> Actually, others gave the answer to that question, which was apparently
> not very clear. :)
Yes it was clear and I did understand it: and I posted a reply thanking the
others too, but for some reason it was still sitting in my outbox...
--
Shriramana Sharma, P
(is(T: const(char)[]))
{
import std.regex;
static auto inlineRE = ctRegex!`\$\(ta (.*?)\)`;
return text.replaceAll!(m => textAttr(m[1]))(inlineRE);
}
--
Shriramana Sharma, Penguin #395953
Thanks all, for your kind explanations.
Would then constString (for const(char)[]) and inoutString (for inout(char)
[]) be useful aliases if included in the runtime?
--
Shriramana Sharma, Penguin #395953
John Colvin wrote:
> On Wednesday, 14 October 2015 at 15:02:02 UTC, Shriramana Sharma
> wrote:
> What binary arithmetic operators do you need that real[] doesn't
> already support?
OMG silly me! I can already do a[] /= b[]... D is great! :-D Thanks a lot!
Shriramana Sharma wrote:
> Hello. I just came upon a need in my program to make binary arithmetic
> operators valid between two real[] in my programs, and thought of writing
> a global opOpAssign, but then looked through the documentation, found
> nothing on operator overloa
, so please don't suggest that (like it
was suggested in the other thread).
Thanks.
Shriramana Sharma.
the
basics approach whereas Andrei's book is more targeted at people
coming from other languages. (This is a judgment I read somewhere --
perhaps on this forum? -- and which I agree with, sorta.)
--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा
1 - 100 of 143 matches
Mail list logo