On Sat, Mar 29, 2014 at 01:37:42AM +0100, Artur Skawina wrote:
[...]
> D is statically typed -- there is no way for one function to return
> different types that are selected by a runtime condition.
> The fact that the produced elements have the same type is irrelevant.
>
> You can wrap the range
On 03/28/14 23:10, H. S. Teoh wrote:
> On Fri, Mar 28, 2014 at 10:44:11PM +0100, Artur Skawina wrote:
>> On 03/28/14 20:00, H. S. Teoh wrote:
>>> Today I ran into an interesting situation where I have a function f
>>> that needs to return ranges of different types (but identical
>>> element types):
On Friday, 28 March 2014 at 20:47:39 UTC, JR wrote:
On Friday, 28 March 2014 at 13:42:43 UTC, w0rp wrote:
size_t dotIndex = qualName.retro.countUntil('.');
if (dotIndex < 0) {
size_t is unsigned. :3
(So ptrdiff_t -- or simply auto.)
Oh yes, that is a bug. There's always at least one
On Friday, 28 March 2014 at 22:12:02 UTC, H. S. Teoh wrote:
On Fri, Mar 28, 2014 at 10:44:11PM +0100, Artur Skawina wrote:
eg
auto f(A...)(A args) {
...
return cartesianProduct(x, y)
.joiner
.filter!(a=>somec
On Friday, 28 March 2014 at 19:03:22 UTC, Marc Schütz wrote:
That is, destruction happens in reverse lexical order of
declaration, and arrays are destroyed from back to front.
Is this behaviour guaranteed?
Yes. It's guaranteed by spec.
On Fri, Mar 28, 2014 at 10:44:11PM +0100, Artur Skawina wrote:
> On 03/28/14 20:00, H. S. Teoh wrote:
> > Today I ran into an interesting situation where I have a function f
> > that needs to return ranges of different types (but identical
> > element types):
> >
> > auto f(A...)(A args) {
> >
On 03/28/14 20:00, H. S. Teoh wrote:
> Today I ran into an interesting situation where I have a function f that
> needs to return ranges of different types (but identical element types):
>
> auto f(A...)(A args) {
> ...
> if (someCondition)
>
void main(){
import std.stdio,std.range,std.algorithm,std.conv;
auto m=10.iota.map!(_=>readln.split.to!(int[]));
m.map!sum.chain(m.transposed.map!sum).reduce!max.write;
}
It used to work, but with the latest changes I think I have
broken it.
Bye,
bearophile
On 03/28/2014 12:03 PM, "Marc Schütz" " wrote:
> destruction happens in reverse lexical order of declaration,
> and arrays are destroyed from back to front.
>
> Is this behaviour guaranteed?
It must be that way because later objects can hold references to earlier
objects.
Ali
On 03/28/2014 01:46 PM, bearophile wrote:
H. S. Teoh:
So how would I implement something like this?
One option is to wrap those ranges in classes. See std.range for the
adapters. (I have not used them yet).
Link:
http://dlang.org/phobos/std_range.html#.inputRangeObject
Short examples he
On 03/28/2014 11:43 AM, Sharad Gupta wrote:
> But this is another spawned process. How can I tell this second process
> to wait on the first one.
std.concurrency is based on message passing. Normally, the second
process would send a message either to its owner or to another thread
that was pre
On Friday, 28 March 2014 at 13:42:43 UTC, w0rp wrote:
size_t dotIndex = qualName.retro.countUntil('.');
if (dotIndex < 0) {
size_t is unsigned. :3
(So ptrdiff_t -- or simply auto.)
H. S. Teoh:
So how would I implement something like this?
One option is to wrap those ranges in classes. See std.range for
the adapters. (I have not used them yet).
Bye,
bearophile
On Friday, 28 March 2014 at 19:02:48 UTC, H. S. Teoh wrote:
Today I ran into an interesting situation where I have a
function f that
needs to return ranges of different types (but identical
element types):
auto f(A...)(A args) {
...
if (someCondition)
struct MyStruct {
string name;
~this() {
import std.stdio;
writeln("destroying ", name);
}
}
void main() {
auto a = MyStruct("a"), b = MyStruct("b");
{
auto e = MyStruct("scoped e");
}
auto c = MyStruct("c");
MyStruct[3] f = [MyStruct("1"),
Today I ran into an interesting situation where I have a function f that
needs to return ranges of different types (but identical element types):
auto f(A...)(A args) {
...
if (someCondition)
return cartesianProduct(x, y)
If you start the worker with spawnLinked then you will receive
a LinkTerminated message.
import std.stdio;
import std.concurrency;
import core.thread;
void main()
{
auto worker = spawnLinked(&workerFunc);
// Wait for worker to terminate
bool terminated = false;
while (!termin
On Friday, 28 March 2014 at 15:39:48 UTC, monarch_dodra wrote:
On Friday, 28 March 2014 at 14:42:54 UTC, Colin Grogan wrote:
Im trying to parse command line args and then build a struct
that will, at run-time, hold the data the user passed in via
command line args.
Very similar to Pythons docop
On Friday, 28 March 2014 at 15:33:32 UTC, Gary Miller wrote:
If I need to examine a byte in string for a specific ASCII
value like
string MyString;
MyString = "Hello World"
and I want to check a position in the string for a certain
unprintable ASCII value like the ASCII Block 219 what is the
I am trying to make a Utility which spwans=>pipeShell off
multiple processes on user choice.
On of the issues is that some process need to wait for other
processes to finish. Now I could implement it using messages but
that doesn't seem very nice solution. I could also wait for the
pipeShell
On Friday, 28 March 2014 at 14:42:54 UTC, Colin Grogan wrote:
Im trying to parse command line args and then build a struct
that will, at run-time, hold the data the user passed in via
command line args.
Very similar to Pythons docopt utility ->
https://github.com/docopt/docopt
Up till now, I'
On Friday, 28 March 2014 at 13:49:59 UTC, Dicebot wrote:
On Friday, 28 March 2014 at 11:59:47 UTC, Colin Grogan wrote:
I'm interested to hear peoples methods for getting around the
lack of foreach loops while using CTFE?
Currently, I've been using a lot of recursive templates, but
its beginni
On Friday, 28 March 2014 at 13:28:00 UTC, Matt wrote:
I haven't tried with deeper derived trees, but this seems to
suggest that the .stringof property provides the class name,
WITHOUT the full qualification.
Those can't be really compared.
.stringof provides string representation of anything a
On 03/28/2014 10:19 AM, Sharad Gupta wrote:
On Friday, 28 March 2014 at 16:37:00 UTC, Vladimir Panteleev wrote:
On Friday, 28 March 2014 at 15:52:17 UTC, Sharad Gupta wrote:
I am trying to make a Utility which spwans=>pipeShell off multiple
processes on user choice.
On of the issues is that so
On Friday, 28 March 2014 at 16:37:00 UTC, Vladimir Panteleev
wrote:
On Friday, 28 March 2014 at 15:52:17 UTC, Sharad Gupta wrote:
I am trying to make a Utility which spwans=>pipeShell off
multiple processes on user choice.
On of the issues is that some process need to wait for other
processes
On Friday, 28 March 2014 at 11:59:47 UTC, Colin Grogan wrote:
I'm interested to hear peoples methods for getting around the
lack of foreach loops while using CTFE?
What, exactly are you trying to do? foreach does work in CTFE,
though it will need to be wrapped in helper function that returns
On Friday, 28 March 2014 at 15:52:17 UTC, Sharad Gupta wrote:
I am trying to make a Utility which spwans=>pipeShell off
multiple processes on user choice.
On of the issues is that some process need to wait for other
processes to finish. Now I could implement it using messages
but that doesn't
Gary Miller:
if (MyString[0..1])== ???(219)) writeln("ASCII Block found")
enum char block = 219;
...
if (myString[i] == block)
"ASCII Block found".writeln;
Note that variable/function names in D start with a lower case.
Bye,
bearophile
If I need to examine a byte in string for a specific ASCII value
like
string MyString;
MyString = "Hello World"
and I want to check a position in the string for a certain
unprintable ASCII value like the ASCII Block 219 what is the
recommended method for doing so
if (MyString[0..1])== ???(
On Thu, 27 Mar 2014 22:23:40 -, Anh Nhan wrote:
Hey guys,
I want to iterate over an array, while adding new entries, and have
those in the iteration loop.
See here: https://gist.github.com/AnhNhan/9820226
The problem is that the foreach loop seemingly only iterates over the
original
You could do the following.
class Klass {
static class SubKlass {
}
}
string baseName(ClassInfo classinfo) {
import std.array;
import std.algorithm : countUntil;
import std.range : retro;
string qualName = classinfo.name;
size_t dotIndex = qualName.retro.countUntil(
On Friday, 28 March 2014 at 11:59:47 UTC, Colin Grogan wrote:
I'm interested to hear peoples methods for getting around the
lack of foreach loops while using CTFE?
Currently, I've been using a lot of recursive templates, but
its beginning to give me a headache and I'd like to see if
there's b
On Friday, 28 March 2014 at 11:28:09 UTC, JR wrote:
On Thursday, 27 March 2014 at 17:41:14 UTC, Jeremy DeHaan wrote:
typeof(this) gives its fully qualified name though. I was
looking for a way to get just the name of the class alone.
I guess I'm confused about what 'fully qualified name' entai
Colin Grogan:
Currently, I've been using a lot of recursive templates, but
its beginning to give me a headache and I'd like to see if
there's better ways around it.
That's a good strategy.
In some cases you can use Iota:
https://d.puremagic.com/issues/show_bug.cgi?id=4085
On a related note
Kagamin:
The phobos code is precompiled, so the compiler doesn't
diagnose it.
Right. So only allocations of templaes of Phobos can be detected.
Bye,
bearophile
On Wednesday, 26 March 2014 at 16:13:15 UTC, Russel Winder wrote:
Is it the case that the Dub recommended project structure is in
fact the
canonical D project structure?
The Dub recommended structure doesn't mention test code as
opposed to
application/library source code, is it the case that t
The phobos code is precompiled, so the compiler doesn't diagnose
it.
I'm interested to hear peoples methods for getting around the
lack of foreach loops while using CTFE?
Currently, I've been using a lot of recursive templates, but its
beginning to give me a headache and I'd like to see if there's
better ways around it.
On a related note, is there plans to ad
On 3/27/14, Atila Neves wrote:
> Why the (inout int = 0) instead of an empty parameter list?
Try removing it and compile std.range with -unittest. Here's what happens:
std\range.d(546): Error: static assert (isInputRange!(inout(int)[])) is false
The reason it's false is because the code wouldn
On Thursday, 27 March 2014 at 17:41:14 UTC, Jeremy DeHaan wrote:
typeof(this) gives its fully qualified name though. I was
looking for a way to get just the name of the class alone.
I guess I'm confused about what 'fully qualified name' entails.
For a class Foo, is "Foo" not just the name of t
On Friday, 28 March 2014 at 11:17:10 UTC, Atila Neves wrote:
Seriously, nobody? I'd've thought this was quite important.
On Thursday, 27 March 2014 at 05:27:50 UTC, Atila Neves wrote:
Why the (inout int = 0) instead of an empty parameter list? I
checkout how isInputRange was implemented and I c
Seriously, nobody? I'd've thought this was quite important.
On Thursday, 27 March 2014 at 05:27:50 UTC, Atila Neves wrote:
Why the (inout int = 0) instead of an empty parameter list? I
checkout how isInputRange was implemented and I copied the
idiom,
but I'd like to know why it's like that inst
Anh Nhan:
Ah, that the foreach caches the entries would make sense.
What does it mean "foreach caches the entries" for you? Foreach
does very little. It is light syntax sugar over a normal for loop.
Bye,
bearophile
On Thursday, 27 March 2014 at 22:23:41 UTC, Anh Nhan wrote:
Hey guys,
I want to iterate over an array, while adding new entries, and
have those in the iteration loop.
See here: https://gist.github.com/AnhNhan/9820226
The problem is that the foreach loop seemingly only iterates
over the orig
44 matches
Mail list logo