Re: Simple casting?

2019-11-27 Thread ixid via Digitalmars-d-learn
On Wednesday, 27 November 2019 at 14:40:56 UTC, Timon Gehr wrote: On 27.11.19 11:43, ixid wrote: On Tuesday, 26 November 2019 at 16:33:06 UTC, Timon Gehr wrote: import std; void main(){     int[] x=[1,1,2,3,4,4];     int[][] y=x.chunkBy!((a,b)=>a==b).map!array.array;     writel

Re: Simple casting?

2019-11-27 Thread ixid via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 16:33:06 UTC, Timon Gehr wrote: import std; void main(){ int[] x=[1,1,2,3,4,4]; int[][] y=x.chunkBy!((a,b)=>a==b).map!array.array; writeln(y); } This stuff is a nightmare for less experienced users like myself, I wish there were a single function

Re: No UFCS with nested functions?

2019-11-05 Thread ixid via Digitalmars-d-learn
On Monday, 4 November 2019 at 20:46:41 UTC, H. S. Teoh wrote: On Mon, Nov 04, 2019 at 07:51:26PM +, Tobias Pankrath via Digitalmars-d-learn wrote: Why does the following not work? It works, if I move the 'prop' out of 'foo'. UFCS is only supported for module-level functions, as far as I

Re: Accuracy of floating point calculations

2019-10-29 Thread ixid via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 16:11:45 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: If you use gdc or ldc you will get same results as c++, or you can use C log directly: import std.stdio; import std.math : pow; import core.stdc.math; void main() {

Re: Enum and CTFE function call

2018-08-14 Thread ixid via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 13:38:16 UTC, Everlast wrote: etc Thanks all for the comprehensive responses. I was not clearly separating CTFE and the compilation of the function in thinking about it. Much clearer now.

Re: Enum and CTFE function call

2018-08-14 Thread ixid via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote: This will not compile as it says n is not known at compile time... This does work if 'value' is changed to immutable and fun to accept it. So it still seems like a missed opportunity as enum shouldn't be able to change either.

Enum and CTFE function call

2018-08-14 Thread ixid via Digitalmars-d-learn
This will not compile as it says n is not known at compile time: auto fun(int n) { static foreach(i;0..n) mixin(i.to!string ~ ".writeln;"); return; } enum value = 2; void main() { fun(value); } But making it a template parameter fun(int n)() and

Re: Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 14:33:06 UTC, Adam D. Ruppe wrote: On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote: Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? Not really. The function call needs

Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? OUT fun(IN, OUT)(IN value) { return value.to!OUT; } void main() { float a = 5.0; int b = fun(a); }

Re: See docs compiler message

2018-03-06 Thread ixid via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 14:50:05 UTC, ixid wrote: On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote: Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed -Steve

Re: See docs compiler message

2018-03-06 Thread ixid via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote: Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed -Steve Thanks, I had found that but that is not an explanation

See docs compiler message

2018-03-06 Thread ixid via Digitalmars-d-learn
/opt/compilers/dmd2/include/std/algorithm/iteration.d(663): Deprecation: function `std.range.Transposed!(string[], cast(TransverseOptions)0).Transposed.save` is deprecated - This function is incorrect and will be removed November 2018. See the docs for more details. If it's going to say 'See

Re: short s, t; t = -s: no (longer) works: Deprecation: integral promotion not done for -s, use

2018-02-24 Thread ixid via Digitalmars-d-learn
On Saturday, 24 February 2018 at 20:07:04 UTC, kdevel wrote: I don't get the point of the deprecation message: --- intprom.d import std.stdio; void main () { short s, t; t = -s; } --- $ dmd intprom.d intprom.d(6): Deprecation: integral promotion not done for -s, use

Re: How to instantiate a template struct with a template constructor without relying on auto deduction?

2018-02-21 Thread ixid via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 14:42:56 UTC, Simen Kjærås wrote: On Wednesday, 21 February 2018 at 14:29:38 UTC, ixid wrote: I do not understand what is happening here, I tried to wrote what I thought would be the answer. If someone could explain that would be great. I wrote this code

Re: How to instantiate a template struct with a template constructor without relying on auto deduction?

2018-02-21 Thread ixid via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter wrote: struct Foo(T) { T bar; this(S)(S s) { bar = convert(s); } } auto foo = Foo!int(some_float); this works because S is deduced as typeof(some_float), but how would I instantiate the struct without relying on auto

Re: import strangeness with std.stdio.write

2018-02-13 Thread ixid via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: write exists in both, writeln exists only in std.stdio. Use named imports to pick which write you want. It does seem a little silly to have a name clash with such a commonly used function. Would it not be better to rename

Re: alias and UFCS

2017-01-24 Thread ixid via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 20:51:49 UTC, Stefan Koch wrote: On Tuesday, 24 January 2017 at 16:41:12 UTC, ixid wrote: On Tuesday, 24 January 2017 at 16:27:50 UTC, ixid wrote: On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote: On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote

Re: alias and UFCS

2017-01-24 Thread ixid via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 16:27:50 UTC, ixid wrote: On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote: On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote: This code: T tFunc(alias F, T)(T n) { n.F; return n; } Produces this error: Error: no property 'F

Re: alias and UFCS

2017-01-24 Thread ixid via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote: On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote: This code: T tFunc(alias F, T)(T n) { n.F; return n; } Produces this error: Error: no property 'F' for type 'int[]' (or whatever type I use). The alias rules

Re: Why D isn't the next "big thing" already

2016-07-27 Thread ixid via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 00:52:30 UTC, Gorge Jingale wrote: So, you can see D as a sort of dried up waste land desert with a few nice palm trees growing here and there and a few scorpions. C++, say, is a very lush forest with many tree dwelling monkeys. Which environment would you rather

Re: Operator overloading through UFCS doesn't work

2016-05-31 Thread ixid via Digitalmars-d-learn
On Sunday, 29 May 2016 at 07:18:10 UTC, Jonathan M Davis wrote: And the fact that allowing free functions to overload operators via UFCS sends us into that territory just highlights the fact that they're a horrible idea. - Jonathan M Davis Do you have any examples of UFCS doing bad things?

Re: OpenGL with D tutorials

2016-05-22 Thread ixid via Digitalmars-d-learn
On Sunday, 22 May 2016 at 12:55:47 UTC, Guillaume Piolat wrote: On Sunday, 22 May 2016 at 12:13:07 UTC, ixid wrote: What is the best OpenGL tutorial with D to use? I've tried to use d-gamedev-intro and opengl-tutorials and seem to get errors, files that are no longer included are needed (dgl

OpenGL with D tutorials

2016-05-22 Thread ixid via Digitalmars-d-learn
What is the best OpenGL tutorial with D to use? I've tried to use d-gamedev-intro and opengl-tutorials and seem to get errors, files that are no longer included are needed (dgl)? and deprecation messages.

Re: foreach UFCS

2016-03-31 Thread ixid via Digitalmars-d-learn
On Thursday, 31 March 2016 at 13:48:27 UTC, Adam D. Ruppe wrote: It is trying to look up a name i in global scope, and calling writeln on it. This is why the .name syntax exists: so you can bypass local variables with the same name when trying to access a global. It would compile if you put

foreach UFCS

2016-03-31 Thread ixid via Digitalmars-d-learn
What is going on with UFCS and foreach? foreach(i;0..5).writeln; This prints five line breaks. foreach(i;0..5).i.writeln; This will not compile. foreach(i;0..5).writeln(i); This writes out 1 to 4 on separate lines. Is this supposed to work? I thought a.b would be rewritten to b(a) with

Re: Simple performance question from a newcomer

2016-02-23 Thread ixid via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 14:07:22 UTC, Marc Schütz wrote: On Tuesday, 23 February 2016 at 11:10:40 UTC, ixid wrote: We really need to standard algorithms to be fast and perhaps have separate ones for perfect technical accuracy. While I agree with most of what you're saying, I don't

Re: Simple performance question from a newcomer

2016-02-23 Thread ixid via Digitalmars-d-learn
On Monday, 22 February 2016 at 15:43:23 UTC, dextorious wrote: I do have to wonder, however, about the default settings of dub in this case. Having gone through its documentation, I might still not have guessed to try the compiler options you provided, thereby losing out on a 2-3x performance

Re: print function

2016-02-05 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 22:13:36 UTC, Ola Fosheim Grøstad wrote: Well, it is probably not the best point in time to have absolute beginners use D anyway. That is a ridiculous thing to say and a great way of ensuring a language dies. Good starting resources help everyone.

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 11:04:23 UTC, cym13 wrote: On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: Do you think your knowledge and experience is a good model for how a new user who hasn't done much if any programming before would approach this? A design choice had

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis wrote: I would normally expect someone to do that with writefln, which would be cleaner. e.g. writefln("%s %s %s %s", a, b, c, d); Personally, I've never felt the need for a function like you're describing. - Jonathan M Davis

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote: On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. There are many implementations

Re: print function

2016-02-04 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote: On 02/04/16 16:32, Artur Skawina wrote: but that seems too expensive, when the use is just in toy programs and debugging. I hadn't really considered the relative cost-benefit, it's just a habit to try to hardcode things at

print function

2016-02-03 Thread ixid via Digitalmars-d-learn
It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print.

Re: print function

2016-02-03 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:30:03 UTC, cym13 wrote: On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. Sounds way too redundant to me. Normally

foreach change for multi-dimensional data

2016-01-28 Thread ixid via Digitalmars-d-learn
This is an idle thought hence putting it on the Learn-level forum. An idea struck me for foreach to make working with more complicated data types or heavily nested data easier. uint[][] a = [[1,2,3],[4,5,6]]; foreach(uint[] b; a) b.writeln; At

Re: foreach change for multi-dimensional data

2016-01-28 Thread ixid via Digitalmars-d-learn
On Thursday, 28 January 2016 at 15:38:20 UTC, Ali Çehreli wrote: On 01/28/2016 05:33 AM, ixid wrote: > This is an idle thought hence putting it on the Learn-level forum. An > idea struck me for foreach to make working with more complicated data > types or heavily nested da

Re: Collapsing n-dimensional array to linear (1 dimensional)

2016-01-25 Thread ixid via Digitalmars-d-learn
On Monday, 25 January 2016 at 08:31:14 UTC, abad wrote: On Monday, 25 January 2016 at 02:27:57 UTC, Solomon E wrote: On Saturday, 23 January 2016 at 07:57:55 UTC, Ali Çehreli Ruby's Array class includes this sort method for flattening and for me it was surprisingly useful, for instance when it

Re: Preventing implicit conversion

2015-11-05 Thread ixid via Digitalmars-d-learn
On Thursday, 5 November 2015 at 05:41:46 UTC, Jonathan M Davis wrote: On Wednesday, November 04, 2015 21:22:02 ixid via Digitalmars-d-learn wrote: On Wednesday, 4 November 2015 at 19:09:42 UTC, Maxim Fomin wrote: > On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wr

Operator implicit conversion difference

2015-11-05 Thread ixid via Digitalmars-d-learn
This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max, b = ushort.max; a += b; // Compiles fine a = a + b; // Error: cannot implicitly

Re: Preventing implicit conversion

2015-11-04 Thread ixid via Digitalmars-d-learn
On Wednesday, 4 November 2015 at 19:09:42 UTC, Maxim Fomin wrote: On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wrote: Is there an elegant way of avoiding implicit conversion to int when you're using shorter types? Only with library solution. Implicit conversions are built

Re: Preventing implicit conversion

2015-11-04 Thread ixid via Digitalmars-d-learn
On Wednesday, 4 November 2015 at 14:27:49 UTC, ixid wrote: Is there an elegant way of avoiding implicit conversion to int when you're using shorter types? Also does this not seem inconsistent: ushort a = ushort.max, b = ushort.max; a += b; // Compiles fine a = a + b; // Error

Preventing implicit conversion

2015-11-04 Thread ixid via Digitalmars-d-learn
Is there an elegant way of avoiding implicit conversion to int when you're using shorter types?

Re: foreach loop

2015-11-04 Thread ixid via Digitalmars-d-learn
On Tuesday, 3 November 2015 at 15:06:00 UTC, Namal wrote: Can you help me out please. Thx. reduce!((x, y) => x + !y)(0, arr).writeln; This would probably be the preferred way, that uses a lambda function (x, y) => x + !y which adds the inverse of the next array value (y) to the total so far

Re: Preventing implicit conversion

2015-11-04 Thread ixid via Digitalmars-d-learn
On Wednesday, 4 November 2015 at 17:26:04 UTC, Daniel Kozak wrote: V Wed, 04 Nov 2015 14:27:45 + ixid via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: Is there an elegant way of avoiding implicit conversion to int when you're using shorter types? http://dla

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-12 Thread ixid via Digitalmars-d-learn
On Saturday, 10 October 2015 at 16:19:53 UTC, Nordlöw wrote: Is there an algorithm somewhere in Phobos which performs when possible a replacement/substitution based on a variadic definition of replacements using hash-table search similar to string replaceWhole(string a) { switch (x) {

Lazy sort

2015-09-11 Thread ixid via Digitalmars-d-learn
Does sort have to be eager or would it be possible to have a lazy version? It's messy to always have to use array and leap in and out of lazy operations within a UFCS chain. Surely as many functions as possible should be optionally lazy.

Re: Lazy sort

2015-09-11 Thread ixid via Digitalmars-d-learn
On Friday, 11 September 2015 at 11:08:29 UTC, Ola Fosheim Grøstad wrote: On Friday, 11 September 2015 at 10:41:16 UTC, ixid wrote: Does sort have to be eager or would it be possible to have a lazy version? It's messy to always have to use array and leap in and out of lazy operations within

Re: foreach multiple loop sugar

2015-08-18 Thread ixid via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 16:02:42 UTC, cym13 wrote: On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote: Though sugar seems to be somewhat looked down upon I thought I'd suggest this- having seen the cartesianProduct function from std.algorithm in another thread I thought it would

foreach multiple loop sugar

2015-08-18 Thread ixid via Digitalmars-d-learn
Though sugar seems to be somewhat looked down upon I thought I'd suggest this- having seen the cartesianProduct function from std.algorithm in another thread I thought it would be an excellent piece of sugar in the language. It's not an earth shattering change but it makes something very

std.array: array, ulong and Win32

2015-08-09 Thread ixid via Digitalmars-d-learn
This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert Argument types in (ulong) are not all convertible to size_t: (ulong) C:\D\dmd2\src\phobos\std\array.d 516 And while I'm here why do

Re: std.array: array, ulong and Win32

2015-08-09 Thread ixid via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:33:10 UTC, anonymous wrote: On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote: Yup, bug. Please file an issue at http://issues.dlang.org/. It seems like bearophile beat me to it. Good to see he's still alive. https://issues.dlang.org/show_bug.cgi?id

Array operations, dynamic arrays and length

2015-06-30 Thread ixid via Digitalmars-d-learn
int[] a = [1,1,1,1]; int[] b = [1,1,1,1]; int[] c; c[] = a[] - b[]; c.writeln; This outputs []. This feels wrong, it feels like something that should have exploded or set the length to 4. If the lengths of a and b are mismatched it throws an exception.

Re: for ranges

2015-01-23 Thread ixid via Digitalmars-d-learn
On Thursday, 22 January 2015 at 16:41:49 UTC, Russel Winder wrote: Playing with factorial implementations, as you do. I had a D implementation using ulong. Not sensible obviously since overflow is a bit of a problem. But the code worked, as did the tests. Now converting to BigInt and… The

Re: import std.random fails

2015-01-07 Thread ixid via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 20:49:34 UTC, Rene Zwanenburg wrote: On Tuesday, 6 January 2015 at 20:26:25 UTC, ixid wrote: Dmd latest non-beta, with the latest VisualD. Debug build. Debug build and no additional or non default settings. Hmm.. Did you verify that the D installation directory

Re: import std.random fails

2015-01-06 Thread ixid via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 18:37:25 UTC, Rene Zwanenburg wrote: On Monday, 5 January 2015 at 15:59:17 UTC, ixid wrote: On Friday, 31 August 2012 at 22:52:13 UTC, Jonathan M Davis wrote: On Saturday, September 01, 2012 00:40:25 deed wrote: import std.random void main() {} --- results

Re: import std.random fails

2015-01-05 Thread ixid via Digitalmars-d-learn
On Friday, 31 August 2012 at 22:52:13 UTC, Jonathan M Davis wrote: On Saturday, September 01, 2012 00:40:25 deed wrote: import std.random void main() {} --- results in: Error 42: Symbol Undefined _D4core6memory2GC6qallocFkkZS4core6memory8BLkInfo_ Error 42: Symbol Undefined

Template function type inference with default arguments

2015-01-03 Thread ixid via Digitalmars-d-learn
Why don't templates take a type from the default argument if nothing else is supplied? It would be useful to be able to use an enum to set a default. enum MAX = 1_000; auto sieve(T)(T max = MAX) { import std.bitmanip : BitArray; BitArray n; n.length = max; T[]

Type name shadowing

2014-10-25 Thread ixid via Digitalmars-d-learn
T shadow(T = int)(T a) { alias T = string; T b = hi; T c = 1; // Error writeln(typeof(a).stringof); // int writeln(typeof(b).stringof); // string return a; } Are there uses for this shadowing of type names? It seems a little dangerous, for

Re: Changing elements during foreach

2013-10-21 Thread ixid
On Monday, 21 October 2013 at 19:37:47 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 21:16:00 qznc wrote: On Monday, 21 October 2013 at 16:22:29 UTC, Krzysztof Ciebiera wrote: I understand slices now and I don't find it consistent with no shoot in the foot by default statement.

Re: UFCS in template function

2013-08-29 Thread ixid
On Thursday, 29 August 2013 at 06:23:32 UTC, Jacob Carlborg wrote: UFCS only works for module level functions. What is the reason for this limitation?

UFCS in template function

2013-08-28 Thread ixid
UFCS does not work in this template where the normal function call syntax will work: template test(alias fun) { auto test(T)(T n) { return n.fun; } } Is this the same as the inability to use UFCS with functions declared in the same scope as the call? Is there

UFCS and function scope

2013-08-15 Thread ixid
Why does UFCS seem to require that functions be defined in a higher (global being the highest) scope than themselves while the normal function syntax works fine? This is OK: int fun1(int n) { return n + 1; } int fun2(int n) { return n.fun1; } This is also OK: int fun3(int n) {

Re: for loop parens

2013-07-13 Thread ixid
I think that Python has syntax evidently and demonstrably superior to D. Why not Python? White spaces with meaning cause hard to find bugs, the Python syntax is not appropriate for large projects and this is well known. That is not the case for the small changes Go has made.

for loop parens

2013-07-12 Thread ixid
Go and Rust seem to have been able to dispense with the parens in for loops, is this something that would be possible to do in D or are there parsing and grammatical reasons not to do this?

Re: for loop parens

2013-07-12 Thread ixid
On Friday, 12 July 2013 at 19:44:43 UTC, bearophile wrote: ixid: Go and Rust seem to have been able to dispense with the parens in for loops, is this something that would be possible to do in D or are there parsing and grammatical reasons not to do this? Go has chosen a different syntax. I

Re: for loop parens

2013-07-12 Thread ixid
On Friday, 12 July 2013 at 20:02:46 UTC, bearophile wrote: ixid: If curly brackets were required where parens were omitted what would prevent such a syntax in D? Maybe nothing, beside lot of programmers that want the freedom to omit curly brackets :-) Bye, bearophile Similarly what

Re: for loop parens

2013-07-12 Thread ixid
On Friday, 12 July 2013 at 20:30:59 UTC, bearophile wrote: ixid: Similarly what are D user's potential issues with Go-like semi-colon rules? And would this be possible as a subset of current D code? Such changes will not happen even in D4. Walter is strongly against the idea of optional

Re: for loop parens

2013-07-12 Thread ixid
They are not issues in Go, but Walter is strongly against optional semicolons, as bearophile said. Me and others (like you) like optional semicolons, but since Walter doesn't and it's his language, that will not change. I personally understand much better the code without semicolons, like in

Re: for loop parens

2013-07-12 Thread ixid
I'm not sure how much of a problem it is, especially given that Go has a strict style guide, but the objection has come up that these two are very different: if i f() { g() } and if i f() { g() } In the second case, a semicolon is inserted on the same line as the

Re: for loop parens

2013-07-12 Thread ixid
As long as the syntax is not *too* ugly (*cough*C++ templates*cough*) isn't the *semantics* more important? A pretty language that has limited expressiveness is useless; a powerful language that's a bit ugly in syntax isn't any less powerful because of it. T What is the cost of

Re: best way to handle UFCS with ambiguous names: using std.typetuple.Alias!

2013-06-11 Thread ixid
On Monday, 10 June 2013 at 02:02:09 UTC, Timothee Cour wrote: UFCS chains are problematic when a symbol is ambiguous (eg after import std.stdio:write;import std.file:write); I previously suggested to add the syntax 'arg1.(std.file.write)(arg2)' (see 'support UFCS with fully qualified function

Re: and/or/not/xor operators

2013-06-04 Thread ixid
On Monday, 3 June 2013 at 09:29:20 UTC, Regan Heath wrote: On Fri, 31 May 2013 21:26:56 +0100, ixid nuacco...@gmail.com wrote: We really don't want D to become a TMTOWTDI language. Ideally there should be 1 right way and no alternatives. That way, anyone who knows D will have a greater

Re: and/or/not/xor operators

2013-05-31 Thread ixid
We really don't want D to become a TMTOWTDI language. Ideally there should be 1 right way and no alternatives. That way, anyone who knows D will have a greater chance of knowing what any given code sample does, and not have to look up alternate syntax etc. R Up to a point I'd certainly

Re: and/or/not/xor operators

2013-05-30 Thread ixid
On Thursday, 30 May 2013 at 16:30:12 UTC, Iain Buclaw wrote: On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I

Re: writeln, UFCS and flip

2013-04-26 Thread ixid
On Friday, 26 April 2013 at 10:52:09 UTC, bearophile wrote: Timon Gehr: I think what you call flip2 should be called flip. Why? Bye, bearophile flip2 is the more general and useful function with new functionality so there's no need for what was flip and we should call the new function

Re: writeln, UFCS and flip

2013-04-25 Thread ixid
Doesn't binaryReverseArgs in std.functional already do this? Flip is a much, much better name though.

Re: writeln, UFCS and flip

2013-04-25 Thread ixid
On Thursday, 25 April 2013 at 16:20:39 UTC, ixid wrote: Doesn't binaryReverseArgs in std.functional already do this? Flip is a much, much better name though. Though I still think write functions passing on the data would be useful, letting you avoid needless temporaries just so you can write

Why are fixed length arrays passed by value while variable are passed by reference?

2013-04-18 Thread ixid
I know this will not be changed, I just want to understand why it is as it is. My naive thought is that consistency is the best scheme and that everything should have been passed by value or everything by reference unless the user specifies otherwise. I have read a comment by Andrei that

Re: Why are fixed length arrays passed by value while variable are passed by reference?

2013-04-18 Thread ixid
An array is represent using a struct with a pointer to the array data and the length, like this: struct Array { void* ptr; size_t length; } The struct is passed by value, but since it contains a pointer to the data it will be passed by reference. Note that if you do: void foo (int[]

Re: Why are fixed length arrays passed by value while variable are passed by reference?

2013-04-18 Thread ixid
I don't consider curent situation with static arrays as incosistent. When correctly understood is isn't as inconsistent, thank you for explaining, this was the knowledge I was after.

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-03 Thread ixid
On Wednesday, 3 April 2013 at 02:28:55 UTC, Chris Cain wrote: On Wednesday, 3 April 2013 at 01:30:19 UTC, ixid wrote: How can you call the new syntax better? You assign arrays' lengths in the opposite to that that you access them. It's a horrible design mistake. Unfortunately, I have

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-02 Thread ixid
On Monday, 1 April 2013 at 09:30:23 UTC, monarch_dodra wrote: On Monday, 1 April 2013 at 08:42:45 UTC, Nicholas Smith wrote: Ali, thanks for the justification. It makes enough sense, and at least int[][](2, 3) matches the order in which you access the elements. I agree with Bearophile though

Re: Two easy pieces

2013-04-01 Thread ixid
On Tuesday, 2 April 2013 at 00:10:45 UTC, bearophile wrote: This is a way to insert an item in a sorted array: import std.stdio: writeln; import std.range: assumeSorted; import std.array: insertInPlace; void main() { int[] arr = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]; int x = 35;

Re: A little of coordination for Rosettacode

2013-03-20 Thread ixid
On Tuesday, 19 March 2013 at 18:53:21 UTC, bearophile wrote: Small changes on your version: http://codepad.org/E9KHKvAi It's now on Rosettacode. I have added more changes to make it able to deal with immutable input. Bye, bearophile Another issue to consider as the question I was

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
I was just looking at the Rosetta code for prime decomposition and it seems bugged to me, wanted to make sure as you seem to be the one coordinating these things: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially return a 1 in the list of primes which is a bug as 1

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
On Tuesday, 19 March 2013 at 16:47:43 UTC, Andrea Fontana wrote: On Tuesday, 19 March 2013 at 15:55:19 UTC, ixid wrote: I was just looking at the Rosetta code for prime decomposition and it seems bugged to me, wanted to make sure as you seem to be the one coordinating these things: http

Re: A little of coordination for Rosettacode

2013-03-19 Thread ixid
On Tuesday, 19 March 2013 at 17:18:01 UTC, bearophile wrote: ixid: http://rosettacode.org/wiki/Prime_decomposition#D This will potentially return a 1 in the list of primes which is a bug as 1 isn't prime. From Python code, hopefully more correct and much faster: http://codepad.org

Why don't underscores in numbers enforce proper formatting?

2013-03-06 Thread ixid
The underscores in values such as 1_000_000 aid readability but DMD doesn't see anything wrong with any placement of underscores as long as they follow a number. Is there any reason to allow uses like 1_00_000, which are typos or exceedingly lazy modifications of value, and not enforce digits

Re: A little of coordination for Rosettacode

2013-02-12 Thread ixid
What other things do you want to discuss about? I mean some level of D community discussion of the language as a whole as to what is an idiomatic style, perhaps after the current issues are settled, not anything specific about your code. There are areas like complex UFCS statements where it

Re: Atomic updates

2013-01-22 Thread ixid
On Monday, 21 January 2013 at 20:35:16 UTC, bearophile wrote: qznc: Code: http://dpaste.dzfl.pl/e6615a53 Any comments or improvements? I have reformatted your code a little, according to the style used in all other D entries of RosettaCode: http://codepad.org/ceDyQ8lE The usage of a

Re: Enhancing foreach

2013-01-09 Thread ixid
I think you're rather a long way away from beginners to see how beginners would think. iota is behaving like the Python range syntax which beginners seem to find quite easy to use. A beginner thinks 'it goes up to that number', the thought process you outlined is that of someone learning their

Re: Enhancing foreach

2013-01-09 Thread ixid
On Wednesday, 9 January 2013 at 23:15:10 UTC, Jonathan M Davis wrote: On Wednesday, January 09, 2013 05:38:16 ixid wrote: A very minor change that would be elegant and easy for beginners: foreach(i;5) //stuff Allowing just a single number to mean the end point and a default starting point

Enhancing foreach

2013-01-08 Thread ixid
A very minor change that would be elegant and easy for beginners: foreach(i;5) //stuff Allowing just a single number to mean the end point and a default starting point of zero is assumed, just as with iota it's possible to write it iota(5) or even 5.iota, it assumes unless otherwise

Re: Templates array detection

2012-12-12 Thread ixid
On Wednesday, 12 December 2012 at 12:34:34 UTC, bearophile wrote: Cube: I'm having a problem getting templates to work correctly. I want to handle arrays differently, but when I try to compile the following example code it says it matches more than 1 template. What is the correct way to do

Re: Templates array detection

2012-12-12 Thread ixid
On Wednesday, 12 December 2012 at 14:21:22 UTC, bearophile wrote: ixid: It's a pity it doesn't see T[] as the best fit and go with it on that basis. It's not a pity, it's a good design. Best fit makes languagecompiler complex, less predictable for the programmer, etc. Bye, bearophile

Re: Appending immutable char implicit cast to int, bug or feature?

2012-12-06 Thread ixid
I don't know where that cast occurs but I wanted to state the obvious: Operator ~ is defined only for arrays. Would having it also work for individual units to make an array be a plausible enhancement request? It would seem like a natural use of the operator.

Appending immutable char implicit cast to int, bug or feature?

2012-12-05 Thread ixid
This is simple code to create all genetic combinations from two organisms. string[] mixGenes(string a, string b) { string[] result; foreach(i;0..2) foreach(j;0..2) foreach(k;2..4) foreach(m;2..4)

Appending immutable char implicit cast to int, bug or feature?

2012-12-05 Thread ixid
This is simple code to create all genetic combinations from two organisms. string[] mixGenes(string a, string b) { string[] result; foreach(i;0..2) foreach(j;0..2) foreach(k;2..4) foreach(m;2..4)

Re: with(a,b,c, ...) blocks..

2012-10-17 Thread ixid
Theoretically legal... void func() //in/out contracts body with (E) { //with replaces normal block } This seems sensible. Multiple with seems like a recipe for confusion and member name clashes.

Re: Splitting a string on multiple tokens

2012-10-10 Thread ixid
On Wednesday, 10 October 2012 at 02:21:05 UTC, jerro wrote: On Wednesday, 10 October 2012 at 00:18:17 UTC, ixid wrote: Is there an effective way of splitting a string with a set of tokens? Splitter feels rather limited and multiple passes gives you an array of arrays of strings rather than

  1   2   >