Recommendation for parallelism with nested for loops?

2022-08-18 Thread Shriramana Sharma via Digitalmars-d-learn
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)

Re: Getting a safe path for a temporary file

2017-10-27 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why is length being tested on an int?

2017-10-27 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Getting a safe path for a temporary file

2017-10-22 Thread Shriramana Sharma via Digitalmars-d-learn
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 = "/

Re: Getting a safe path for a temporary file

2017-10-22 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Can't use function with same name as module?

2017-10-17 Thread Shriramana Sharma via Digitalmars-d-learn
Have reported https://issues.dlang.org/show_bug.cgi?id=17907

Re: Can't use function with same name as module?

2017-10-17 Thread Shriramana Sharma via Digitalmars-d-learn
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:

Re: Can't use function with same name as module?

2017-10-17 Thread Shriramana Sharma via Digitalmars-d-learn
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

Can't use function with same name as module?

2017-10-17 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
cted. Filed https://issues.dlang.org/show_bug.cgi?id=15764 just for the record. -- Shriramana Sharma, Penguin #395953

Re: Unable to instantiate template with same name as function

2016-03-03 Thread Shriramana Sharma via Digitalmars-d-learn
name approach, so it brings us back to the question as to why the name can't be re-used. -- Shriramana Sharma, Penguin #395953

Unable to instantiate template with same name as function

2016-03-02 Thread Shriramana Sharma via Digitalmars-d-learn
r: template instance .ta!"s" error instantiating Please clarify what I am doing wrong? Thanks! -- Shriramana Sharma, Penguin #395953

`static` symbol needs to be `immutable` for compile-time access?

2016-01-22 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: `static` symbol needs to be `immutable` for compile-time access?

2016-01-22 Thread Shriramana Sharma via Digitalmars-d-learn
cation) every time the function is run? -- Shriramana Sharma, Penguin #395953

Re: mixed-in ctor not on par with explicit one?

2016-01-13 Thread Shriramana Sharma via Digitalmars-d-learn
'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

Re: mixed-in ctor not on par with explicit one?

2016-01-13 Thread Shriramana Sharma via Digitalmars-d-learn
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

Compiler complaining about ~ used on static array in @nogc fn

2016-01-13 Thread Shriramana Sharma via Digitalmars-d-learn
g that I cannot use ~ inside a @nogc function? -- Shriramana Sharma, Penguin #395953

mixed-in ctor not on par with explicit one?

2016-01-12 Thread Shriramana Sharma via Digitalmars-d-learn
g argument types (int) What is the problem in calling the mixed-in ctor? -- Shriramana Sharma, Penguin #395953

immutable promise broken in unions?

2016-01-02 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: immutable promise broken in unions?

2016-01-02 Thread Shriramana Sharma via Digitalmars-d-learn
eded to make such a union. But already making a union is breaking the type system in a way, no? -- Shriramana Sharma, Penguin #395953

Re: Why isn't field-wise constructor automatic for structs and not classes?

2016-01-02 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: @property not available for classes?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why can't a Regex object be immutable?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
: 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

Re: Why can't a Regex object be immutable?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why isn't field-wise constructor automatic for structs and not classes?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
defined. Why can't the field-wise functionality be automatic for classes too? -- Shriramana Sharma, Penguin #395953

Re: Why can't a Regex object be immutable?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
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: Why can't a Regex object be immutable?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: CTFE with C functions not possible?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
MD had something like -fdata-sections -ffunction- sections, passing --gc-sections might be able to slim that down, I dunno... -- Shriramana Sharma, Penguin #395953

Re: CTFE with C functions not possible?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
bulky. I suppose I could always maintain both the C and D versions separately. -- Shriramana Sharma, Penguin #395953

@property not available for classes?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
applicable for classes. Am I stuck with having to use the () for this even in D? -- Shriramana Sharma, Penguin #395953

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
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

CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
: 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

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
n libc? -- Shriramana Sharma, Penguin #395953

Re: CTFE with C functions not possible?

2015-12-31 Thread Shriramana Sharma via Digitalmars-d-learn
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

Is a type not a symbol?

2015-12-22 Thread Shriramana Sharma via Digitalmars-d-learn
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

: in template specialization vs constraint

2015-12-22 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
e name and complementary constraints right? -- Shriramana Sharma, Penguin #395953

Re: C string to D without memory allocation?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
marked @system? Only because one cannot be sure that the input point refers to a valid null-terminated string? -- Shriramana Sharma, Penguin #395953

Deimos recommendation still official?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
. Or is it just because the other C libraries haven't changed (!)... -- Shriramana Sharma, Penguin #395953

Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
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

What other than a pointer can be converted implicitly to const(char)*?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
convertible to const(char)*? -- Shriramana Sharma, Penguin #395953

Re: function without "this" cannot be const?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
afe D type encapsulating a C string but avoid allocation – is it possible or not? Thanks! -- Shriramana Sharma, Penguin #395953

function without "this" cannot be const?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
> > it is a poor design. fromStringz > is explicit about this assumption. OK thank you. -- Shriramana Sharma, Penguin #395953

Re: exit(1)?

2015-12-17 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Why should file names intended for executables be valid identifiers?

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
not be a valid identifier no? -- Shriramana Sharma, Penguin #395953

Re: Testing if a file is connected to a terminal

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

exit(1)?

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: No documentation for core.sys?

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

No documentation for core.sys?

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Testing if a file is connected to a terminal

2015-12-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why should file names intended for executables be valid identifiers?

2015-12-14 Thread Shriramana Sharma via Digitalmars-d-learn
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

Inferring an integer literal as ubyte

2015-12-14 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Inferring an integer literal as ubyte

2015-12-14 Thread Shriramana Sharma via Digitalmars-d-learn
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

AliasSeq can contain template identifier too?

2015-12-12 Thread Shriramana Sharma via Digitalmars-d-learn
... -- Shriramana Sharma, Penguin #395953

isTemplate and isValue?

2015-12-12 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: %s not producing string representation of enum?

2015-12-11 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Using std.math: FloatingPointControl.enableExceptions

2015-12-11 Thread Shriramana Sharma via Digitalmars-d-learn
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

Using std.math: FloatingPointControl.enableExceptions

2015-12-10 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: %s not producing string representation of enum?

2015-12-10 Thread Shriramana Sharma via Digitalmars-d-learn
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

%s not producing string representation of enum?

2015-12-10 Thread Shriramana Sharma via Digitalmars-d-learn
uot;, suit); } } But I'm getting 0 1 2 3. Kindly advise. -- Shriramana Sharma, Penguin #395953

Re: D equivalent of Python's try..else

2015-11-21 Thread Shriramana Sharma via Digitalmars-d-learn
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

why --shebang for rdmd?

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
a D equivalent? -- Shriramana Sharma, Penguin #395953

Re: D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
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/

D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
(apart from catch). -- Shriramana Sharma, Penguin #395953

`finally` is redundant?

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

Dhee - tiny app to learn/try out D

2015-11-10 Thread Shriramana Sharma via Digitalmars-d-learn
cross-posted as I thought this is relevant to both announce/learn. -- Shriramana Sharma, Penguin #395953

How to get DMD to stop littering my source dir with .o files?

2015-10-26 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: `clear`ing a dynamic array

2015-10-25 Thread Shriramana Sharma via Digitalmars-d-learn
for deleting them all when it itself is deleted? -- Shriramana Sharma, Penguin #395953

Re: `clear`ing a dynamic array

2015-10-25 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: `clear`ing a dynamic array

2015-10-25 Thread Shriramana Sharma via Digitalmars-d-learn
ect.html#.reserve>. The append > operator is `~=`. Thanks for that clarification. Now submitted a pull request. -- Shriramana Sharma, Penguin #395953

`clear`ing a dynamic array

2015-10-24 Thread Shriramana Sharma via Digitalmars-d-learn
to `a` should also reflect in `b`. -- Shriramana Sharma, Penguin #395953

Re: `clear`ing a dynamic array

2015-10-24 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: D serialization temporary fixup?

2015-10-23 Thread Shriramana Sharma via Digitalmars-d-learn
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

D serialization temporary fixup?

2015-10-22 Thread Shriramana Sharma via Digitalmars-d-learn
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

toString"z"?

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
std.string.toStringz – why the strange name with z instead of toString0 or toCString? -- Shriramana Sharma, Penguin #395953

can't zip a char[5], string[5], real[5]

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
(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

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
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

Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
(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

StopWatch

2015-10-20 Thread Shriramana Sharma via Digitalmars-d-learn
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

Compiling a .d file both as library and executable

2015-10-17 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why can't function expecting immutable arg take mutable input?

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
should replace all occurrences of `string` in arguments and return values of functions by `const(char)[]`? -- Shriramana Sharma, Penguin #395953

Why does File.byLine() return char[] and not string

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Why does File.byLine() return char[] and not string

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
Thanks people, for the replies. That's very clear now. -- Shriramana Sharma, Penguin #395953

Re: Why can't function expecting immutable arg take mutable input?

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
that but that's enough for me now... -- Shriramana Sharma, Penguin #395953

Error in trying to use an inout(char)[] with a regex

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Why can't function expecting immutable arg take mutable input?

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Error in trying to use an inout(char)[] with a regex

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
(is(T: const(char)[])) { import std.regex; static auto inlineRE = ctRegex!`\$\(ta (.*?)\)`; return text.replaceAll!(m => textAttr(m[1]))(inlineRE); } -- Shriramana Sharma, Penguin #395953

Re: Why can't function expecting immutable arg take mutable input?

2015-10-16 Thread Shriramana Sharma via Digitalmars-d-learn
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

Re: Why isn't global operator overloading allowed in D?

2015-10-15 Thread Shriramana Sharma via Digitalmars-d-learn
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!

Re: Why isn't global operator overloading allowed in D?

2015-10-14 Thread Shriramana Sharma via Digitalmars-d-learn
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

Why isn't global operator overloading allowed in D?

2015-10-14 Thread Shriramana Sharma via Digitalmars-d-learn
, so please don't suggest that (like it was suggested in the other thread). Thanks. Shriramana Sharma.

Re: Learning D for a non computer science background person : pre-requisite knowledge?

2014-12-02 Thread Shriramana Sharma via Digitalmars-d-learn
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   2   >