Bug or feature?

2013-05-26 Thread mimi
import std.stdio; struct S { int bigUglyName; void foo( S s ) { alias bigUglyName local; alias s.bigUglyName b; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } } void main() { S s1; S s2; s1.bigUglyName = 1; s2.bigUglyName = 2;

Bug or feature?

2015-05-10 Thread Jack Applegame via Digitalmars-d-learn
code: class A { void test(int) {} } class B : A { void test() { super.test(1); // compiles test(10); // error } } Error: function B.test () is not callable using argument types (int)

Bug or feature?

2015-06-28 Thread Jack Applegame via Digitalmars-d-learn
I don't see any reason why it should not compile. import std.array; import std.range; import std.algorithm; class Foo { } void main() { auto result = iota(3).map!(i => new immutable Foo).array(); } /usr/include/dmd/phobos/std/conv.d(4028): Error: cannot implicitly convert expression (

Re: Bug or feature?

2013-05-26 Thread Maxim Fomin
On Sunday, 26 May 2013 at 23:35:43 UTC, mimi wrote: import std.stdio; struct S { int bigUglyName; void foo( S s ) { alias bigUglyName local; alias s.bigUglyName b; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } } void main() { S s1; S

Re: Bug or feature?

2013-05-27 Thread mimi
Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times.

Re: Bug or feature?

2013-05-27 Thread Namespace
void foo( S s ) { auto local = this.bigUglyName; auto b = s.bigUglyName; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } :P

Re: Bug or feature?

2013-05-27 Thread mimi
On Monday, 27 May 2013 at 10:17:01 UTC, Namespace wrote: void foo( S s ) { auto local = this.bigUglyName; auto b = s.bigUglyName; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } :P By the way, yes. Thanks for that, I'm stupid today.

Re: Bug or feature?

2013-05-27 Thread Maxim Fomin
On Monday, 27 May 2013 at 10:07:49 UTC, mimi wrote: Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times. By not making the name ugly big.

Re: Bug or feature?

2013-05-27 Thread mimi
On Monday, 27 May 2013 at 11:32:46 UTC, Maxim Fomin wrote: On Monday, 27 May 2013 at 10:07:49 UTC, mimi wrote: Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times. By not making the name ugly big. Other people do. In addition, sometime

Re: Bug or feature?

2015-05-10 Thread Ali Çehreli via Digitalmars-d-learn
On 05/10/2015 10:18 AM, Jack Applegame wrote: code: class A { void test(int) {} } class B : A { void test() { super.test(1); // compiles test(10); // error } } Error: function B.test () is not callable using argument types (int) It is a concept called "name

Re: Bug or feature?

2015-05-10 Thread Manfred Nowak via Digitalmars-d-learn
Jack Applegame wrote: >> test(10); // error One can "import" the declaration by using an alias: class A { void test(int) {} } class B : A { alias test= super.test; void test() { super.test(1); // compiles test(10); // compiles } } -manfred

Re: Bug or feature?

2015-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 10, 2015 10:48:33 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/10/2015 10:18 AM, Jack Applegame wrote: > > code: > > > >> class A { > >> void test(int) {} > >> } > >> > >> class B : A { > >> void test() { > >> super.test(1); // compiles > >> test(10);

Re: Bug or feature?

2015-05-10 Thread Jack Applegame via Digitalmars-d-learn
Ok, it's a feature. Thanks.

Re: Bug or feature?

2015-06-30 Thread Adam D. Ruppe via Digitalmars-d-learn
I'd say bug, I think the array function is trying an optimization it shouldn't be trying for immutable classes.

Re: Bug or feature?

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 28, 2015 11:37:59 Jack Applegame via Digitalmars-d-learn wrote: > I don't see any reason why it should not compile. > > import std.array; > import std.range; > import std.algorithm; > > class Foo { > } > > void main() { > auto result = iota(3).map!(i => new immutable Foo).array();

Re: Bug or feature?

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Monday, 29 June 2015 at 12:04:46 UTC, Jonathan M Davis wrote: You haven't declared an immutable constructor, so you can't construct an immutable Foo. That's not what's happening. Constructing an immutable Foo works just fine.

Re: Bug or feature?

2015-06-30 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 29 Jun 2015 05:04:36 -0700 Jonathan M Davis via Digitalmars-d-learn wrote: > On Sunday, June 28, 2015 11:37:59 Jack Applegame via > Digitalmars-d-learn wrote: > > I don't see any reason why it should not compile. > > > > import std.array; > > import std.range; > > import std.algorithm; >

Re: Bug or feature?

2015-06-30 Thread Jack Applegame via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=14751

Re: Bug or feature?

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 29 June 2015 at 14:28:06 UTC, anonymous wrote: On Monday, 29 June 2015 at 12:04:46 UTC, Jonathan M Davis wrote: You haven't declared an immutable constructor, so you can't construct an immutable Foo. That's not what's happening. Constructing an immutable Foo works just fine. Then

Re: Bug or feature?

2015-08-04 Thread Jack Applegame via Digitalmars-d-learn
fix - https://github.com/D-Programming-Language/phobos/pull/3524

SysTime bug or feature?

2015-10-05 Thread tchaloupka via Digitalmars-d-learn
This code: import std.stdio; import std.datetime; void main() { SysTime t = SysTime.init; writeln(t); } results in segfault with dmd-2.068.2 Is it ok? Backtrace: #0 0x004733f3 in std.datetime.SysTime.adjTime() const () #1 0x004730b9 in std.datetime.SysTime.toSimpleS

Re: SysTime bug or feature?

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 18:12:06 tchaloupka via Digitalmars-d-learn wrote: > This code: > > import std.stdio; > import std.datetime; > > void main() > { > SysTime t = SysTime.init; > writeln(t); > } > > results in segfault with dmd-2.068.2 > > Is it ok? It is by design, albeit undesi

Re: SysTime bug or feature?

2015-10-05 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:54:44 UTC, Jonathan M Davis wrote: It is by design, albeit undesirable. When SysTime was originally written, it was impossible to have a default value for a class reference other than null. So, unless SysTime was going to take the performance hit of constantly c

Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
std.c.stdlib.exit() seems to break RAII. The code below tests this both using a struct destructor and an explicit scope(exit) {}. Is this an intentional feature or a bug? import std.stdio; import std.c.stdlib; void main() { struct SafeExit { ~this() { writeln("Safely exit

Bug or Feature: unsigned integer overflow

2019-12-13 Thread Tobias Pankrath via Digitalmars-d-learn
void main() { auto x = 9223372036854775808; // long.max + 1 } onlineapp.d(3): Error: signed integer overflow According to spec x should be of type ulong and this should compile? It indeed compiles if I add the uL postfix. Is this a bug or indented behaviour?

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jacob Carlborg
On 2011-12-29 18:22, Jakob Ovrum wrote: On Thursday, 29 December 2011 at 16:27:33 UTC, Ashish Myles wrote: std.c.stdlib.exit() seems to break RAII. The code below tests this both using a struct destructor and an explicit scope(exit) {}. Is this an intentional feature or a bug? import std.stdio;

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Andrej Mitrovic
Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(), throwing will take care of RAII stuff.

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
On Thu, Dec 29, 2011 at 12:22 PM, Jakob Ovrum wrote: > On Thursday, 29 December 2011 at 16:27:33 UTC, Ashish Myles wrote: >> >> std.c.stdlib.exit() seems to break RAII. The code below tests this >> both using a struct destructor and an explicit scope(exit) {}.  Is >> this an intentional feature or

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic wrote: > Probably the easiest thing to do is to throw a custom exception and > catch it somewhere in main() to return your status code. Unlike > exit(), throwing will take care of RAII stuff. Thanks, Andrej. That option had occurred to me, but I fi

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jakob Ovrum
On Thursday, 29 December 2011 at 16:27:33 UTC, Ashish Myles wrote: std.c.stdlib.exit() seems to break RAII. The code below tests this both using a struct destructor and an explicit scope(exit) {}. Is this an intentional feature or a bug? import std.stdio; import std.c.stdlib; void main() {

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jakob Ovrum
On Thursday, 29 December 2011 at 17:22:33 UTC, Jakob Ovrum wrote: Calling 'exit' doesn't properly shut down the D runtime either, it's not just constructors. I mean destructors*.

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread AaronP
On 12/29/2011 12:43 PM, Ashish Myles wrote: On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic wrote: Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(), throwing will take care of RAII stuff. Thanks, Andre

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jonathan M Davis
On Thursday, December 29, 2011 13:43:36 Ashish Myles wrote: > On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic > > wrote: > > Probably the easiest thing to do is to throw a custom exception and > > catch it somewhere in main() to return your status code. Unlike > > exit(), throwing will take care

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
On Thu, Dec 29, 2011 at 7:16 PM, Jonathan M Davis wrote: > > A D exit function would have to do essentially the same thing as throw an > exception and catch it in main anyway. The only way that the stack is going to > be unwound properly is if you actually unwind it. The only way in the language >

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-30 Thread Jonathan M Davis
On Thursday, December 29, 2011 23:03:23 Ashish Myles wrote: > Since D > could conceivably implement a very safe exit() without an explicit use > of Exceptions to get around the "catch Exception() {}" problem you > mentioned above, does it make sense to request a safer exit() feature > for D? And h

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-30 Thread Ashish Myles
On Fri, Dec 30, 2011 at 5:43 AM, Jonathan M Davis wrote: > On Thursday, December 29, 2011 23:03:23 Ashish Myles wrote: >> Since D >> could conceivably implement a very safe exit() without an explicit use >> of Exceptions to get around the "catch Exception() {}" problem you >> mentioned above, does

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-30 Thread Jonathan M Davis
On Friday, December 30, 2011 10:45:43 Ashish Myles wrote: > Ok, now there are two issues here: > IMPLEMENTATION: Implementation of a safe_exit() without an explicit > Exception seems to be easy to do at the language level for a > single-threaded program -- you simply have a hidden/system class like

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-30 Thread Ashish Myles
Thanks, Jonathan, for your detailed answer. Ashish On Fri, Dec 30, 2011 at 1:41 PM, Jonathan M Davis wrote: > On Friday, December 30, 2011 10:45:43 Ashish Myles wrote: >> Ok, now there are two issues here: >> IMPLEMENTATION: Implementation of a safe_exit() without an explicit >> Exception seems

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2012-01-06 Thread Stewart Gordon
On 29/12/2011 19:09, Jacob Carlborg wrote: Could druntime hook up on the atexit function to run destructors and similar when the program exits? I'm not sure. Maybe it could be called upon to run static destructors and destruct heap-allocated objects. But in order to call scope guards and R

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2012-01-06 Thread Andrej Mitrovic
Just implement your own exception type, e.g. ExitException, and then use: void main() { try { realMain(); } catch (ExitException e) { return 0; } void exit() { throw ExitException(); } where realMain is the actual main function. Then just call exit() whenever you want to.

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2012-01-06 Thread Andrej Mitrovic
That should have been int main.

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2012-01-06 Thread Stewart Gordon
On 06/01/2012 14:44, Andrej Mitrovic wrote: Just implement your own exception type, e.g. ExitException, and then use: That's more or less what people have already said. What's more, Ashish has already suggested a further improvement whereby the custom exception carries an exit code. void m

bug or feature? shared objects and tuples

2013-08-26 Thread Jack Applegame
It is impossible to pack a structure with shared object into tuple. ``` import std.concurrency; import std.typecons; class Foo {} struct A { shared Foo foo; } void main() { auto a = tuple(new shared Foo); // ОК auto b = tuple(A());// Error: static assert "unable

Re: Bug or Feature: unsigned integer overflow

2019-12-13 Thread berni44 via Digitalmars-d-learn
On Saturday, 14 December 2019 at 07:09:30 UTC, Tobias Pankrath wrote: void main() { auto x = 9223372036854775808; // long.max + 1 } You need to tell, that this is an unsigned long literal, else the compiler treats it as an int: void main() { auto x = 9223372036854775808UL; // long.ma

Re: Bug or Feature: unsigned integer overflow

2019-12-14 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 14 December 2019 at 07:44:37 UTC, berni44 wrote: On Saturday, 14 December 2019 at 07:09:30 UTC, Tobias Pankrath wrote: void main() { auto x = 9223372036854775808; // long.max + 1 } You need to tell, that this is an unsigned long literal, else the compiler treats it as an int:

Re: Bug or Feature: unsigned integer overflow

2019-12-14 Thread berni44 via Digitalmars-d-learn
On Saturday, 14 December 2019 at 09:33:13 UTC, Tobias Pankrath wrote: See: https://dlang.org/spec/lex.html#integerliteral What I am aiming at: Is the spec wrong or am I misunderstanding it and did this change recently? You are right. The implementation does not do what the specs tell here. I

Re: Bug or Feature: unsigned integer overflow

2019-12-14 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 14 December 2019 at 10:32:10 UTC, berni44 wrote: On Saturday, 14 December 2019 at 09:33:13 UTC, Tobias Pankrath wrote: See: https://dlang.org/spec/lex.html#integerliteral What I am aiming at: Is the spec wrong or am I misunderstanding it and did this change recently? You are rig

Re: bug or feature? shared objects and tuples

2013-08-26 Thread Andrej Mitrovic
On 8/27/13, Jack Applegame wrote: > It is impossible to pack a structure with shared object into > tuple. Bug. Please file it to bugzilla: http://d.puremagic.com/issues/enter_bug.cgi?product=D Thanks!

Re: bug or feature? shared objects and tuples

2013-08-26 Thread Jack Applegame
On Monday, 26 August 2013 at 23:04:24 UTC, Andrej Mitrovic wrote: Bug. Please file it to bugzilla: http://d.puremagic.com/issues/enter_bug.cgi?product=D Thanks! http://d.puremagic.com/issues/show_bug.cgi?id=10907

Needed return type in static method? bug or feature?

2016-03-08 Thread Antonio Corbi via Digitalmars-d-learn
Hi all! The following code compiles and works, but the static methods do not have a return type. It also compiles and works if the appropiate (or auto) return type is added to them. -8>< import std.stdio; class B { int foo () { return 1; }

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: Needed return type in static method? bug or feature?

2016-03-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 8 March 2016 at 13:40:06 UTC, Antonio Corbi wrote: Is it a feature or a bug? It is allowed because the "auto" keyword doesn't actually required for auto functions (or variables), what you need is any one of the storage classes. Those include static, auto, const, immutable, even

Re: Needed return type in static method? bug or feature?

2016-03-08 Thread Antonio Corbi via Digitalmars-d-learn
On Tuesday, 8 March 2016 at 14:13:17 UTC, Adam D. Ruppe wrote: On Tuesday, 8 March 2016 at 13:40:06 UTC, Antonio Corbi wrote: Is it a feature or a bug? It is allowed because the "auto" keyword doesn't actually required for auto functions (or variables), what you need is any one of the storag

Re: Needed return type in static method? bug or feature?

2016-03-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 08, 2016 14:56:06 Antonio Corbi via Digitalmars-d-learn wrote: > On Tuesday, 8 March 2016 at 14:13:17 UTC, Adam D. Ruppe wrote: > > On Tuesday, 8 March 2016 at 13:40:06 UTC, Antonio Corbi wrote: > >> Is it a feature or a bug? > > > > It is allowed because the "auto" keyword doesn

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

2012-12-05 Thread Ali Çehreli
On 12/05/2012 09:30 AM, ixid wrote: 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) result ~= [a[i]] ~ [b[j]] ~ [a[k]] ~ [b[m]]; return result; }

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.

Create alias of same name in inner scope, bug or feature?

2021-08-13 Thread Tejas via Digitalmars-d-learn
```d import std; auto abc(T)(auto ref T a, auto ref T b){ return a+b; } auto def(T)(auto ref T a, auto ref T b){ return a*b; } alias macro_1 = abc; void main() { writeln(macro_1(15, 20)); alias macro_1 = def;// is this NOT considered variable shadowing? writeln(macro_1(

Can't add ubytes together to make a ubyte... bug or feature?

2016-01-19 Thread Soviet Friend via Digitalmars-d-learn
I just attempted to add one ubyte to another and store the result in a ubyte but apparently ubytes get converted to ints when being added... and converting what becomes an int becomes impossible to store in a ubyte without an explicit cast... ubyte a, b; ubyte c = a + b; // Error: cannot impli

Re: Can't add ubytes together to make a ubyte... bug or feature?

2018-03-17 Thread Jonathan via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 23:36:14 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2016 at 22:12:06 UTC, Soviet Friend wrote: I don't care if my computer needs to do math on a 4 byte basis, I'm not writing assembly. x86 actually doesn't need to do math that way, if you were writing asse

Re: Can't add ubytes together to make a ubyte... bug or feature?

2018-03-17 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Saturday, 17 March 2018 at 18:36:35 UTC, Jonathan wrote: On Tuesday, 19 January 2016 at 23:36:14 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2016 at 22:12:06 UTC, Soviet Friend wrote: I don't care if my computer needs to do math on a 4 byte basis, I'm not writing assembly. x86 actuall

Re: Can't add ubytes together to make a ubyte... bug or feature?

2018-03-17 Thread bauss via Digitalmars-d-learn
On Saturday, 17 March 2018 at 18:56:55 UTC, Dominikus Dittes Scherkl wrote: On Saturday, 17 March 2018 at 18:36:35 UTC, Jonathan wrote: On Tuesday, 19 January 2016 at 23:36:14 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2016 at 22:12:06 UTC, Soviet Friend wrote: I don't care if my computer

Re: Can't add ubytes together to make a ubyte... bug or feature?

2018-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2018 11:36 AM, Jonathan wrote: `(a+b)&0xff` What is this syntax?!  Could you give a link to this in the D documentation? Here is my description of bitwise AND: http://ddili.org/ders/d.en/bit_operations.html#ix_bit_operations.&,%20bitwise%20and The section titled "Masking" on the sa

Re: Create alias of same name in inner scope, bug or feature?

2021-08-13 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 14 August 2021 at 03:47:05 UTC, Tejas wrote: ```d import std; auto abc(T)(auto ref T a, auto ref T b){ return a+b; } auto def(T)(auto ref T a, auto ref T b){ return a*b; } alias macro_1 = abc; void main() { writeln(macro_1(15, 20)); alias macro_1 = def;// is thi

Re: Create alias of same name in inner scope, bug or feature?

2021-08-13 Thread Tejas via Digitalmars-d-learn
On Saturday, 14 August 2021 at 04:01:31 UTC, Mike Parker wrote: On Saturday, 14 August 2021 at 03:47:05 UTC, Tejas wrote: ```d import std; auto abc(T)(auto ref T a, auto ref T b){ return a+b; } auto def(T)(auto ref T a, auto ref T b){ return a*b; } alias macro_1 = abc; void main()

Re: Create alias of same name in inner scope, bug or feature?

2021-08-14 Thread user1234 via Digitalmars-d-learn
On Saturday, 14 August 2021 at 04:09:34 UTC, Tejas wrote: [...] Oh right, the ```.``` operator will reference variable in the _module_ scope, not just the _immediate outer scope_, you can use the module name to disambiguate as well. To extend Mike answer, the general rule is that if you can d

Re: Create alias of same name in inner scope, bug or feature?

2021-08-14 Thread Tejas via Digitalmars-d-learn
On Saturday, 14 August 2021 at 08:23:20 UTC, user1234 wrote: On Saturday, 14 August 2021 at 04:09:34 UTC, Tejas wrote: [...] Oh right, the ```.``` operator will reference variable in the _module_ scope, not just the _immediate outer scope_, you can use the module name to disambiguate as well.

Bug or Feature: `this` necessary to call function with template this parameter

2019-10-30 Thread Q. Schroll via Digitalmars-d-learn
struct Example { private void helper(int i, this X)() { } void funcTempl(T, this X)(T value) { this.helper!0(); // ^ Why do I need this? } } void main() { auto ex = Example(); ex.funcTempl(1); } The question is in the comment in the code. Is that intentio

Re: Can't add ubytes together to make a ubyte... bug or feature?

2016-01-19 Thread Daniel Kozak via Digitalmars-d-learn
Soviet Friend píše v Út 19. 01. 2016 v 22:12 +: > I just attempted to add one ubyte to another and store the result  > in a ubyte but apparently ubytes get converted to ints when being  > added... and converting what becomes an int becomes impossible to  > store in a ubyte without an explicit c

Re: Can't add ubytes together to make a ubyte... bug or feature?

2016-01-19 Thread Ali Çehreli via Digitalmars-d-learn
On 01/19/2016 02:12 PM, Soviet Friend wrote: > ubytes get converted to ints when being added... It's a common feature involving all integral type in languages like C, C++, and D: https://dlang.org/spec/type.html#integer-promotions > On the topic of complaining about casting... array length

Re: Can't add ubytes together to make a ubyte... bug or feature?

2016-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 22:12:06 UTC, Soviet Friend wrote: I don't care if my computer needs to do math on a 4 byte basis, I'm not writing assembly. x86 actually doesn't need to do math that way, if you were writing assembly, it would just work. This is just an annoying rule brought ov

Re: Can't add ubytes together to make a ubyte... bug or feature?

2016-01-19 Thread Chris Wright via Digitalmars-d-learn
On Tue, 19 Jan 2016 23:32:57 +0100, Daniel Kozak wrote: > Soviet Friend píše v Út 19. 01. 2016 v 22:12 +: >> I just attempted to add one ubyte to another and store the result in a >> ubyte but apparently ubytes get converted to ints when being added... >> and converting what becomes an int bec

Bug or feature? iota has different semantics for integer and float arguments

2023-01-06 Thread Arredondo via Digitalmars-d-learn
Consider: ``` import std.range.iota; auto r = iota(5, 0); ``` `r` is an empty range, as it should be. But if you call: ``` auto r = iota(5.0, 0); ``` then you get an exception (incorrect startup parameters). This was unexpected, and a pain to debug. What is the rationale behind iota having d

struct opEquals does not work with parameter of same type - bug or feature?

2011-08-29 Thread Sean Eskapp
I am trying to build a struct with equality testing, using this code: struct Foo { const bool opEquals(Foo f) { return true; } } This gives me the error that the parameter should be of type "ref const Foo". Fine. struct Foo { const bool opEquals(ref const Foo f) {

Re: Bug or Feature: `this` necessary to call function with template this parameter

2019-10-30 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 30 October 2019 at 20:22:25 UTC, Q. Schroll wrote: struct Example { private void helper(int i, this X)() { } void funcTempl(T, this X)(T value) { this.helper!0(); // ^ Why do I need this? } } void main() { auto ex = Example(); ex.funcTempl(1

Re: Bug or feature? iota has different semantics for integer and float arguments

2023-01-06 Thread Ali Çehreli via Digitalmars-d-learn
On 1/6/23 15:23, Arredondo wrote: > then you get an exception (incorrect startup parameters). Although that difference is a bug, iota does have a special floating point implementation to prevent the accumulation of floating point errors. I mention it as item 4 here: https://www.youtube.com

Re: Bug or feature? iota has different semantics for integer and float arguments

2023-01-06 Thread Arredondo via Digitalmars-d-learn
On Saturday, 7 January 2023 at 00:52:20 UTC, Ali Çehreli wrote: Although that difference is a bug, iota does have a special floating point implementation to prevent the accumulation of floating point errors. Thank you for this clarification Ali. I appreciate the fact that there is a specializ

Re: Bug or feature? iota has different semantics for integer and float arguments

2023-01-06 Thread Ali Çehreli via Digitalmars-d-learn
On 1/6/23 17:50, Arredondo wrote: > Would anyone volunteer to file a bug report? Me! Me! :) https://issues.dlang.org/show_bug.cgi?id=23604 Ali

Re: Bug or feature? iota has different semantics for integer and float arguments

2023-01-07 Thread Arredondo via Digitalmars-d-learn
On Saturday, 7 January 2023 at 02:31:14 UTC, Ali Çehreli wrote: On 1/6/23 17:50, Arredondo wrote: > Would anyone volunteer to file a bug report? Me! Me! :) https://issues.dlang.org/show_bug.cgi?id=23604 Ali Thanks a lot :D Arredondo.

Re: struct opEquals does not work with parameter of same type - bug or feature?

2011-08-29 Thread Jonathan M Davis
On Monday, August 29, 2011 22:41:26 Sean Eskapp wrote: > I am trying to build a struct with equality testing, using this code: > > struct Foo > { > const bool opEquals(Foo f) > { > return true; > } > } > > This gives me the error that the parameter should be of type "ref const

Re: struct opEquals does not work with parameter of same type - bug or feature?

2011-08-29 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Monday, August 29, 2011 22:41:26 Sean Eskapp wrote: > > I am trying to build a struct with equality testing, using this code: > > > > struct Foo > > { > > const bool opEquals(Foo f) > > { > > return true; > > }

The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-06 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, No wonder that it works, because it is the legacy C++ (and I like that everything is different from zero is true): if (5) writeln("OK"); // prints OK In the `static if` this condition also works perfectly: static if (5) writeln("OK"); // prints OK Here idiomatic version check in

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-06 Thread sigod via Digitalmars-d-learn
On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: The problem is that the `static if` it does not work: immutable hash = [1 : 3, 5 : 7]; static if (5 in hash) writeln("OK"); // Error: expression &[1:3, 5:7][5] // is not constant or does not evaluate to a bool You have to writ

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-06 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 6 June 2015 at 18:16:28 UTC, sigod wrote: On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: Pulls whether this issue? Or is it normal? http://dlang.org/version.html#staticif: StaticIfCondition: static if ( AssignExpression ) AssignExpression is implicitly conve

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-06 Thread lobo via Digitalmars-d-learn
On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: [snip] `static if(5 in hash) {}` will not work because (5 in hash) returns a pointer to the value or null if the key oesn't exist. bye, lobo

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-06 Thread lobo via Digitalmars-d-learn
On Sunday, 7 June 2015 at 03:01:15 UTC, lobo wrote: On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: [snip] `static if(5 in hash) {}` will not work because (5 in hash) returns a pointer to the value or null if the key oesn't exist. bye, lobo just to be clear, you cannot hav

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-07 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 7 June 2015 at 03:04:38 UTC, lobo wrote: On Sunday, 7 June 2015 at 03:01:15 UTC, lobo wrote: On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: [snip] `static if(5 in hash) {}` will not work because (5 in hash) returns a pointer to the value or null if the key oesn't

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-07 Thread via Digitalmars-d-learn
On Sunday, 7 June 2015 at 03:04:38 UTC, lobo wrote: On Sunday, 7 June 2015 at 03:01:15 UTC, lobo wrote: On Saturday, 6 June 2015 at 17:06:37 UTC, Dennis Ritchie wrote: [snip] `static if(5 in hash) {}` will not work because (5 in hash) returns a pointer to the value or null if the key oesn't

Re: The problem with the value that is returned from the condition in `static if`. Bug or feature?

2015-06-07 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 7 June 2015 at 11:33:56 UTC, Marc Schütz wrote: Not true: immutable y = 1; enum x = &y; You can even do pointer arithmetics: auto foo() { auto x = [1,2,3,4]; auto y = &x[1]; return y[2]; } pragma(msg, foo()); Then I do not see any proble