www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is the world coming to an end?

reply Andrej Mitrovic <none none.none> writes:
https://github.com/D-Programming-Language/phobos/commit/83f99df573c089cc186ef370cb691c2f8a25c873
https://github.com/D-Programming-Language/phobos/commit/88904f7795a94b23e750e10a2addc90783089de7

If I didn't know it better I would think it's still April 1st. :D
Apr 02 2011
next sibling parent =?UTF-8?B?QWxla3NhbmRhciBSdcW+acSNacSH?= <ruzicic.aleksandar gmail.com> writes:
Nice to see awkward octal literal syntax being removed from Phobos! :)

On Sat, Apr 2, 2011 at 10:16 PM, Andrej Mitrovic <none none.none> wrote:
 https://github.com/D-Programming-Language/phobos/commit/83f99df573c089cc186ef370cb691c2f8a25c873
 https://github.com/D-Programming-Language/phobos/commit/88904f7795a94b23e750e10a2addc90783089de7

 If I didn't know it better I would think it's still April 1st. :D

Apr 02 2011
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Andrej Mitrovic:

 If I didn't know it better I would think it's still April 1st. :D

I don't like the "octal!" a lot, I prefer a syntax like the Python3 one, but Walter never stops moving himself forward :-) Bye, bearophile
Apr 02 2011
next sibling parent Mafi <mafi example.org> writes:
Am 02.04.2011 23:38, schrieb bearophile:
 Andrej Mitrovic:

 If I didn't know it better I would think it's still April 1st. :D

I don't like the "octal!" a lot, I prefer a syntax like the Python3 one, but Walter never stops moving himself forward :-) Bye, bearophile

No ofence, but I sometimes get the opinion that you think something is better just because there's "Python" written on it. But sure, syntaxes are a matter of taste and people shouldn't dispute about tastes. Mafi PS I don't want to say every of Python's decisions is wrong. Many of them are great (but defenitely not significant intendation).
Apr 02 2011
prev sibling next sibling parent reply Daniel Gibson <metalcaedes gmail.com> writes:
Am 02.04.2011 23:38, schrieb bearophile:
 Andrej Mitrovic:
 
 If I didn't know it better I would think it's still April 1st. :D

I don't like the "octal!" a lot, I prefer a syntax like the Python3 one,

Come on: the C-style octal syntax is bad (see [1]) and can lead to strange bugs, so it's a huge win that it's finally killed, even if you don't like the new syntax :-) In general octal numbers are rarely needed (I guess), so the somehow clumsy octal!123 syntax doesn't matter. Also it's more readable (self-documenting) for someone not used to octal numbers than Python3's 0o123. Also congratulations to spir, I guess his "0nnn octal notation considered harmful" thread[1] was a good argument for this step :-) Cheers, - Daniel [1] http://www.digitalmars.com/d/archives/digitalmars/D/0nnn_octal_notation_considered_harmful_129416.html
Apr 02 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Daniel Gibson:

 In general octal numbers are rarely needed (I guess), so the somehow clumsy
 octal!123 syntax doesn't matter. Also it's more readable (self-documenting) for
 someone not used to octal numbers than Python3's 0o123.

I agree. Bye, bearophile
Apr 02 2011
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/2/2011 2:38 PM, bearophile wrote:
 Andrej Mitrovic:

 If I didn't know it better I would think it's still April 1st. :D

I don't like the "octal!" a lot, I prefer a syntax like the Python3 one

The point is that "octal!" is not a syntax. It's completely a library construction.
Apr 02 2011
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Walter:

 The point is that "octal!" is not a syntax. It's completely a library
construction.

It seems I use the word "syntax" in a different way, for me it means any way to express a semantics. I will be more careful with my wording. Bye, bearophile
Apr 02 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/3/2011 12:00 AM, Russel Winder wrote:
 On Sat, 2011-04-02 at 16:47 -0700, Walter Bright wrote:

 The point is that "octal!" is not a syntax. It's completely a library
construction.

So remove 0b... and 0x... as well such that the compiler only knows about decimal. The point here is not the removal of the C-style octal notation, everyone agrees that it was and remains a bad idea, the problem is the inconsistency of treatment of binary and hexadecimal compared to octal.

The 0x notation is heavily used, and so justifies a custom syntax for it. Octal is pretty much never used outside of setting file permission masks. Much as I like PDP-10's and PDP-11's, they are dead and gone. <sob>
Apr 03 2011
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/3/11 4:39 AM, Ulrik Mikaelsson wrote:
 2011/4/3 Walter Bright<newshound2 digitalmars.com>:
 The 0x notation is heavily used, and so justifies a custom syntax for it.
 Octal is pretty much never used outside of setting file permission masks.

The thing is, since you already have 0x and 0b, 0o would not be much of a "custom syntax". It would simply be an "extrapolation of the rule". It follows the already set pattern for non 10-base literals.

It is a custom syntax nevertheless. Worse, that custom syntax does nothing for other cases of literals (e.g. lat/long, degrees and minutes etc). The best thing about std.conv.octal is that is serves as a template (in the general sense of the word) for any custom literals. It offers the proverbial fishing rod as opposed to '0o' being the proverbial fish.
 Regarding the "but it's so uncommon"-argument, there are 23 characters
 left for the "0<base-char>"-notation, there isn't exactly an
 allocation-problem.

 A feature that can be handled adequately by the library should not be part of
the core language.

easily be otherwise solved, go ahead and remove asm instead. I'll guess it's about as uncommon as octal literals (or maybe even more), have simple other solution (just compile it separately and link), and has much greater impact on the language and the compiler. I simply don't buy the "uncommon" argument, when it's such a minuscule thing in the language, following an already established framework/pattern.
 The phrase "discriminating against people" has a lot of emotional baggage
associated with it that is irrelevant to this.

please don't dismiss peoples feelings like this. It will only hinder D longevity and growth. I realize the discussion is over, and the feature has been implemented. Bitching and moaning now won't change anybodys mind, but for the record, I think this is a bad design-move, breaking established patterns. I agree it minuscule and seldom used, so I'm not going to continue the discussion.

On the contrary, I think it's a very good and significant move in the right direction. If it breaks anything, it breaks an inferior approach to literals. Andrei
Apr 03 2011
prev sibling next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
Ulrik Mikaelsson wrote:
 If you're looking for uncommonly used language-features that could
 easily be otherwise solved, go ahead and remove asm instead. I'll
 guess it's about as uncommon as octal literals (or maybe even more),
 have simple other solution (just compile it separately and link),
 and has much greater impact on the language and the compiler.

Actually, inline asm can't be replaced. If you link it separately, it won't be inlined... There's also a huge difficulty change. 010 -> octal!10 is a simple change. It'd be enormous effort to de-inline assembly, even if it were actually possible in the first place! Consider asm in version statements.... Also, unlike octal literals, it couldn't be replaced by templates either; inline asm enables things that are otherwise impossible. There's simply no way for the language to express many of the instructions available to you in asm. It's a foundational building block. This leads into the commonness too. I don't think I've *ever* wanted an octal literal. But, assembly is useful in 3/5 of my programs. Heck, even more, if you count library functions that use it. (though lib functions could in theory be linked separately)
Apr 03 2011
parent reply KennyTM~ <kennytm gmail.com> writes:
On Apr 4, 11 00:49, Adam D. Ruppe wrote:
 Ulrik Mikaelsson wrote:
 If you're looking for uncommonly used language-features that could
 easily be otherwise solved, go ahead and remove asm instead. I'll
 guess it's about as uncommon as octal literals (or maybe even more),
 have simple other solution (just compile it separately and link),
 and has much greater impact on the language and the compiler.

Actually, inline asm can't be replaced. If you link it separately, it won't be inlined...

Talking of asm, would the following be expected to work? ------- import std.conv; void main() { asm { di octal!777; mov EAX, octal!777; } } -------
Apr 03 2011
parent Adam D. Ruppe <destructionator gmail.com> writes:
KennyTM~ wrote:
 Talking of asm, would the following be expected to work?

Maybe. Part of me says "yes, it should be the same as a literal*" but part of me says no because it's weird to drop a template in an asm block. * For example: enum a = octal!777; asm { mov EAX, a; } does indeed work. But, all in all, I don't think octal! itself in asm should work. It's not literally a literal.
Apr 03 2011
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/3/2011 2:39 AM, Ulrik Mikaelsson wrote:
 If you're looking for uncommonly used language-features that could
 easily be otherwise solved, go ahead and remove asm instead. I'll
 guess it's about as uncommon as octal literals (or maybe even more),
 have simple other solution (just compile it separately and link), and
 has much greater impact on the language and the compiler.

I've done assembler the old fashioned way - a separate .asm file assembled with masm and linked in - for years. Having the inline assembler is an ENORMOUS productivity improvement. Just a few off the top of my head: 1. MASM's syntax changes unpredictably from version to version. I'd get a lot of grief from customers with "this doesn't assemble with *my* version of MASM", or "I don't have MASM". 2. Different assemblers have utterly different syntax - see MASM and GAS. 3. MASM can't read struct declarations, meaning you now have parallel declarations that manually must be synced. 4. MASM doesn't understand C++ or D name mangling. 5. Can't mix MASM files and D code in the same function. 6. Can't access D manifest constants from MASM. 7. D takes care of local variable stack addressing modes for you. 8. I can't fix MASM bugs. 9. And Adam's comments.
Apr 03 2011
prev sibling next sibling parent Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2011-04-02 at 16:47 -0700, Walter Bright wrote:

 The point is that "octal!" is not a syntax. It's completely a library con=

So remove 0b... and 0x... as well such that the compiler only knows about decimal. The point here is not the removal of the C-style octal notation, everyone agrees that it was and remains a bad idea, the problem is the inconsistency of treatment of binary and hexadecimal compared to octal. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 03 2011
prev sibling parent Ulrik Mikaelsson <ulrik.mikaelsson gmail.com> writes:
2011/4/3 Walter Bright <newshound2 digitalmars.com>:
 The 0x notation is heavily used, and so justifies a custom syntax for it.
 Octal is pretty much never used outside of setting file permission masks.

The thing is, since you already have 0x and 0b, 0o would not be much of a "custom syntax". It would simply be an "extrapolation of the rule". It follows the already set pattern for non 10-base literals. Regarding the "but it's so uncommon"-argument, there are 23 characters left for the "0<base-char>"-notation, there isn't exactly an allocation-problem.
 A feature that can be handled adequately by the library should not be part of
the core language.

easily be otherwise solved, go ahead and remove asm instead. I'll guess it's about as uncommon as octal literals (or maybe even more), have simple other solution (just compile it separately and link), and has much greater impact on the language and the compiler. I simply don't buy the "uncommon" argument, when it's such a minuscule thing in the language, following an already established framework/pattern.
 The phrase "discriminating against people" has a lot of emotional baggage
associated with it that is irrelevant to this.

please don't dismiss peoples feelings like this. It will only hinder D longevity and growth. I realize the discussion is over, and the feature has been implemented. Bitching and moaning now won't change anybodys mind, but for the record, I think this is a bad design-move, breaking established patterns. I agree it minuscule and seldom used, so I'm not going to continue the discussion.
Apr 03 2011
prev sibling next sibling parent Russel Winder <russel russel.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2011-04-02 at 18:36 -0700, Walter Bright wrote:

 Yes, except for something else - the rarity of need for octal literals. T=

 modern usage I've seen of it is for file permissions.

What is the use for binary literals or hexadecimal literals, I can't think of one. Except perhaps specification of register save masks and control status work literals -- which is of course where the octal stuff came from in the first place in C and when the VAX replaced PDP, hexadecimal was rapidly introduced. (*) I would suggest that rather than discriminating against people who like octal instead of decimal or hexadecimal, the solution of introducing 0o... in harmony with 0b... and 0x... -- and of course removing the leading 0 octal literal convention -- is obviously the right solution. It ticks all the boxes. (*) For anyone not immediately in the know here PDP had 8 registers and VAX 16 so octal and hexadecimal were the natural bases for specifying masks. The 68000 also played a part. The use of octal on the PDP actually goes a lot deeper than this, cf. Unibus, but it is all ancient history now. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 03 2011
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Andrej Mitrovic" <none none.none> wrote in message 
news:in8060$lt3$1 digitalmars.com...
 https://github.com/D-Programming-Language/phobos/commit/83f99df573c089cc186ef370cb691c2f8a25c873
 https://github.com/D-Programming-Language/phobos/commit/88904f7795a94b23e750e10a2addc90783089de7

 If I didn't know it better I would think it's still April 1st. :D

Yea! I stumbled onto that, too. IIRC, I let out a rather audible "Whoohoo!" :)
Apr 03 2011
parent Don <nospam nospam.com> writes:
Nick Sabalausky wrote:
 "Andrej Mitrovic" <none none.none> wrote in message 
 news:in8060$lt3$1 digitalmars.com...
 https://github.com/D-Programming-Language/phobos/commit/83f99df573c089cc186ef370cb691c2f8a25c873
 https://github.com/D-Programming-Language/phobos/commit/88904f7795a94b23e750e10a2addc90783089de7

 If I didn't know it better I would think it's still April 1st. :D

Yea! I stumbled onto that, too. IIRC, I let out a rather audible "Whoohoo!" :)

Apr 04 2011
prev sibling next sibling parent spir <denis.spir gmail.com> writes:
On 04/03/2011 07:19 PM, Adam D. Ruppe wrote:
 KennyTM~ wrote:
 Talking of asm, would the following be expected to work?

Maybe. Part of me says "yes, it should be the same as a literal*" but part of me says no because it's weird to drop a template in an asm block. * For example: enum a = octal!777; asm { mov EAX, a; } does indeed work. But, all in all, I don't think octal! itself in asm should work. It's not literally a literal.

The whole is that, precisely, it is not (no more) a literal. Octals have no more syntactic existence ;-) Denis -- _________________ vita es estrany spir.wikidot.com
Apr 03 2011
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/3/11, Nick Sabalausky <a a.a> wrote:
 I've always thought that we should be able to do something like this:

 template foo(int val)
 {
     enum foo = val.meta.argString;
 }
 static assert(foo!(2+3) == "2+3");

I wish we had some introspection to get the lines of code inside of a function. But it's still pretty cool that you can pass expressions to functions and automatically construct delegates. See here: import std.stdio; void main() { int x; foo(false, x = 5); assert(x != 5); foo(true, x = 5); assert(x == 5); } void foo(bool doit, int delegate()[] dgs ...) { if (doit) dgs[0](); } I wonder how many people know about this feature. I just bumped into it a few days ago while looking through the docs.
Apr 03 2011
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Sun, 03 Apr 2011 15:40:18 -0400, Nick Sabalausky <a a.a> wrote:

 "Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote in message
 news:mailman.3093.1301858962.4748.digitalmars-d puremagic.com...
 On 4/3/11, Nick Sabalausky <a a.a> wrote:
 I've always thought that we should be able to do something like this:

 template foo(int val)
 {
     enum foo = val.meta.argString;
 }
 static assert(foo!(2+3) == "2+3");

I wish we had some introspection to get the lines of code inside of a function. But it's still pretty cool that you can pass expressions to functions and automatically construct delegates. See here: import std.stdio; void main() { int x; foo(false, x = 5); assert(x != 5); foo(true, x = 5); assert(x == 5); } void foo(bool doit, int delegate()[] dgs ...) { if (doit) dgs[0](); } I wonder how many people know about this feature. I just bumped into it a few days ago while looking through the docs.

I didn't know that. I think I remember the idea of it being discussed, but I didn't know it was in.

It's been there forever (at least since I first learned D). It's even in D1: http://www.digitalmars.com/d/1.0/function.html Look for "Lazy variadic functions" I think what you were thinking of is the replacement of lazy with simply a delegate (which this example is not). -Steve
Apr 04 2011
prev sibling next sibling parent spir <denis.spir gmail.com> writes:
On 04/08/2011 03:55 PM, Michel Fortin wrote:
 On 2011-04-08 07:03:23 -0400, spir <denis.spir gmail.com> said:

 On 04/08/2011 07:25 AM, Nick Sabalausky wrote:
 I want base PI literals :)

 Yum.

I want base 1 literals Denis

Like this? assert(0i == 0) assert(0i0 == 1) assert(0i00 == 2) assert(0i000 == 3) assert(0i0000000000_0000000000_0000000000_00 == 32)

Yop! You just reinvented the definition of natural numbers via set theory ;-) Denis -- _________________ vita es estrany spir.wikidot.com
Apr 08 2011
prev sibling next sibling parent spir <denis.spir gmail.com> writes:
On 04/08/2011 10:01 PM, Nick Sabalausky wrote:
 "Michel Fortin"<michel.fortin michelf.com>  wrote in message
 news:inn4bp$57s$1 digitalmars.com...
 On 2011-04-08 07:03:23 -0400, spir<denis.spir gmail.com>  said:

 On 04/08/2011 07:25 AM, Nick Sabalausky wrote:
 I want base PI literals :)

 Yum.

I want base 1 literals Denis

Like this? assert(0i == 0) assert(0i0 == 1) assert(0i00 == 2) assert(0i000 == 3) assert(0i0000000000_0000000000_0000000000_00 == 32)

Pardon my geekdom, but it would probably have to be: assert(0i == 0) assert(0i1 == 1) assert(0i11 == 2) assert(0i111 == 3) assert(0i1111111111_1111111111_1111111111_11 == 32) In general, number bases work like this: Assuming i=0 is the right-most digit: (digits.length (SIGMA) i=0) digit[i] * (base^^i) Or in less mathy notation: uint[] digits = [...blah...]; // digits[0] is the right-most digit auto finalValue = 0; foreach(i; 0..digits.length) finalValue += digits[i] * (base^^i); So using 0 as the only digit in base 1 would result in all numbers being equal to 0. But using 1 as the only digit would work.

True, for using the same algorithm to compute the numeric value. But you're missing the point in base 1 there cannot be '1' digits, as per definition ;-) If I correctly understand Michel's meaning, he just provided a notation mapping natural numbers to sets (actually sequences): Number n maps to n whatever-symbol. Could have been: assert(0i$$$ == 3); but since '0's are available in base 1... Denis -- _________________ vita es estrany spir.wikidot.com
Apr 08 2011
prev sibling parent spir <denis.spir gmail.com> writes:
On 04/09/2011 11:07 AM, Caligo wrote:
 There is no such thing as base 1 number system.  Stop wasting your time.

lol! -- _________________ vita es estrany spir.wikidot.com
Apr 09 2011