June 08, 2005
On Wed, 8 Jun 2005 16:06:27 -0700, Walter wrote:

> "Derek Parnell" <derek@psych.ward> wrote in message news:1t9a2kjsrkjbi.6xdppe5dta9d.dlg@40tude.net...
>> Exactly! But in the meantime, do I just wait upon othes to all catch up. Today we only have two compilers, but soon we could have many compilers?
>>
>> I really, really, really, really, would like a cost-effective solution to this very real problem. This is not a stupid request.
>>
>> The -d switch is a *workaround*. And it only effects certain changes in syntax and not all possible changes.
> 
> I agree that -d is a workaround, and a transitional tool. But waiting for the change to GDC should hopefully be a short one,

quote: "hopefully"  - but we don't know that do we?

> and then -d won't be
> needed, so a transitional workaround is acceptable. I think it is practical
> to live with this for now, since we are pre-1.0 and there are only two
> compilers out there. Post 1.0, and when there are more compilers with
> varying update schedules, the use of predefined version identifiers will
> become necessary.

How could version identifiers solved the introduction of the '$' token?

> BTW, the !is problem can also be worked around by using !(a is b).

LOL.  Now that is spin!


-- 
Derek
Melbourne, Australia
9/06/2005 9:24:04 AM
June 08, 2005
In article <d87tom$2sap$2@digitaldaemon.com>, Walter says...
>
>
>"David L. Davis" <SpottedTiger@yahoo.com> wrote in message news:d87sok$2rff$1@digitaldaemon.com...
>> In the dmd v0.126 changlog it states: "delete aa[key] is now deprecated,
>use
>> aa.remove(key) instead."
>>
>> It's a little thing, but the D compiler doesn't throw a "deprecated"
>message for
>> code that's using the "delete aa[key]" as it should when the "-d" switch
>is not
>> being used. Just thought you should know.
>
>I thought it did, and in fact it has on my usages of delete aa[key].
>
>

Ok, "the proof is in the pudding." Here's the code I test compiled without an error message... so either I misunderstood the changlog, or the version of dmd v0.126 I've downloaded is different from yours. <g>

# // assocarray.d
# // Updated to changes done in D v0.126:
# // "delete aa[key] is now deprecated, use aa.remove(key) instead"
# private import std.stdio;
#
# alias char[] string;
#
#  void main()
#  {
#      string[ string ] arr;
#
#      // before adding "key"
#      writefln( "With the associative array empty, does \"key\" exist? %s",
#                ( isset( arr, "key" ) ? "yes" : "no" ) );
#      writefln();
#
#      writefln( "Now adding entries \"key\" and \"key2\"" );
#      arr[ "key"  ] = "added a key";
#      arr[ "key2" ] = "added another key";
#      writefln();
#
#      writefln( "The associative array now has %d entries listed below.",
#                 arr.length );
#      displayEntries( arr );
#      writefln();
#
#      // after adding "keys"
#      writefln( "After adding the keys, does \"key\" exist? %s",
#                ( isset( arr, "key" ) ? "yes" : "no" ) );
#      writefln();
#
#      writefln( "Now removing \"key2\"..." );
#      remove( arr, "key2" );
#      // after removing "key2"
#      writefln( "After removing, does \"key2\" now exist? %s",
#                ( isset( arr, "key2" ) ? "yes" : "no" ) );
#      writefln( "The associative array now has %d entries.", arr.length );
#      writefln();
#
#      writefln( "Before ending display all remaining keys..." );
#      displayEntries( arr );
#
# } // end void main()
#
# bool isset( in string[ string ] arr, in char[] sKey )
# {
#     if ( ( sKey in arr ) != null )
#         return true;
#     else
#         return false;
# }
#
# void remove( inout string[ string ] arr, in char[] sKey )
# {
#     delete arr[ sKey ];
#     //arr.remove( sKey );
# }
#
# void removeall( inout string[ string ] arr )
# {
#     foreach( char[] sKey; arr.keys )
#         delete arr[ sKey ];
#         //arr.remove( sKey );
# }
#
# void displayEntries( in string[ string ] arr )
# {
#     foreach( char[] sKey, char[] sValue; arr )
#         writefln( "sKey=\"%s\", sValue=\"%s\"", sKey, sValue );
# }

Output:
---------
C:\dmd>dmd
Digital Mars D Compiler v0.126
Copyright (c) 1999-2005 by Digital Mars written by Walter Bright
Documentation: www.digitalmars.com/d/index.html
Usage:
dmd files.d ... { -switch }

files.d        D source files
-c             do not link
-d             allow deprecated features
-debug         compile in debug code
-debug=level   compile in debug code <= level
-debug=ident   compile in debug code identified by ident
-g             add symbolic debug info
-Ipath         where to look for imports
-inline        do function inlining
-Llinkerflag   pass linkerflag to link
-O             optimize
-odobjdir      write object files to directory objdir
-offilename    name output file to filename
-op            do not strip paths from source file
-profile       profile runtime performance of generated code
-quiet         suppress unnecessary messages
-release       compile release version
-unittest      compile in unit tests
-v             verbose
-version=level compile in version code >= level
-version=ident compile in version code identified by ident
-w             enable warnings

C:\dmd>dmd assocarray.d
C:\dmd\bin\..\..\dm\bin\link.exe assocarray,,,user32+kernel32/noi;

C:\dmd>assocarray
With the associative array empty, does "key" exist? no

Now adding entries "key" and "key2"

The associative array now has 2 entries listed below.
sKey="key", sValue="added a key"
sKey="key2", sValue="added another key"

After adding the keys, does "key" exist? yes

Now removing "key2"...
After removing, does "key2" now exist? no
The associative array now has 1 entries.

Before ending display all remaining keys...
sKey="key", sValue="added a key"

C:\dmd>

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
June 08, 2005
On Thu, 09 Jun 2005 00:31:30 +0200, Anders F Björklund wrote:

> Derek Parnell wrote:
> 
>>>These issues will go away once GDC is up to date and/or D reaches 1.0, so why worry and code work-arounds when you can just relax and wait it out?
>> 
>> I'm thinking about the general case, and not specifically the "!is" issue.
>> 
>> Yes, one day in the indeterminate future, GDC will catch up with DigitalMars, and even more unknown is when v1.0 is going to happen, but what do I do in the meantime? Are you seriously asking me to never use any new feature of D until both those events happen? I didn't think so.
> 
> And what about the 2.0 features ? Won't they suffer the same fate, once they start trickling down in the 1.1 versions of the language ?
> 
> I agree/sympathize with Derek, sounds like it's preprocessor time.

I hate to say this, but I suspect this is beyond Walter's abilities to fix the situation. Its too late. The introduction of any new thing that solves this will naturally be incompatible with earlier versions of DMD or other brands of compilers.

The only thing I can come up with so far (and I haven't explored this too far) is to change the behaviour of the version statement when its in the form of 'version(id) { . . . }', such that it literally ignores the characters in between the matching braces when the version identifier doesn't apply. This would have the same effect as it does now, except that it will not try to see if the stuff inside the braces is valid D syntax. That would solve my problem *and* enable a new way of inserting non-D code into a D source file - e.g. documentation.

But I'd still have to wait for GDC to catch up on that idea too ;-)

-- 
Derek
Melbourne, Australia
9/06/2005 9:33:09 AM
June 08, 2005
It would still have to count curly braces, at the least, because a literal reading of your suggestion means:

version (asdf)
{
  if (true)
  {
     writef("only shown for version=asdf!");
  }

  writef("shown always.");
} // <-- error.

-[Unknown]


> On Thu, 09 Jun 2005 00:31:30 +0200, Anders F Björklund wrote:
> 
> 
>>Derek Parnell wrote:
>>
>>
>>>>These issues will go away once GDC is up to date and/or D reaches 1.0, so why worry and code work-arounds when you can just relax and wait it out?
>>>
>>>I'm thinking about the general case, and not specifically the "!is" issue.
>>>
>>>Yes, one day in the indeterminate future, GDC will catch up with
>>>DigitalMars, and even more unknown is when v1.0 is going to happen, but
>>>what do I do in the meantime? Are you seriously asking me to never use any
>>>new feature of D until both those events happen? I didn't think so.
>>
>>And what about the 2.0 features ? Won't they suffer the same fate,
>>once they start trickling down in the 1.1 versions of the language ?
>>
>>I agree/sympathize with Derek, sounds like it's preprocessor time.
> 
> 
> I hate to say this, but I suspect this is beyond Walter's abilities to fix
> the situation. Its too late. The introduction of any new thing that solves
> this will naturally be incompatible with earlier versions of DMD or other
> brands of compilers.
> 
> The only thing I can come up with so far (and I haven't explored this too
> far) is to change the behaviour of the version statement when its in the
> form of 'version(id) { . . . }', such that it literally ignores the
> characters in between the matching braces when the version identifier
> doesn't apply. This would have the same effect as it does now, except that
> it will not try to see if the stuff inside the braces is valid D syntax.
> That would solve my problem *and* enable a new way of inserting non-D code
> into a D source file - e.g. documentation.
> 
> But I'd still have to wait for GDC to catch up on that idea too ;-)
> 
June 08, 2005
In article <d8803s$2u7s$1@digitaldaemon.com>, Unknown W. Brackets says...
>
>It would still have to count curly braces, at the least, because a literal reading of your suggestion means:

Right. And it'd also need to keep track of openning and closing quotation marks
in string literals so that
version(id)
{
char[] s = "}";
}
wouldn't mess it up.

jcc7
June 09, 2005
Walter wrote:
> Added inner classes.
> 
> http://www.digitalmars.com/d/changelog.html
> 
> 
> 

<quote>
Now throws an ArrayBoundsError if accessing an associative array with a key that is not already in the array. Previously, the key would be added to the array.
</quote>
Execuse my n00bness, but how do you add keys to the associative array then?
June 09, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:d87tgq$2s36$1@digitaldaemon.com...
>
> "Andrew Fedoniouk" <news@terrainformatica.com> wrote in message news:d87q98$2pam$1@digitaldaemon.com...
>> > No, what I plan to do is put string literals into a read-only section
>> > of
>> > memory. Attempting to change it will result in a runtime fault.
>>
>> I see. So
>>
>> char[] s = "Hello";
>>      s[0] = 0;
>>
>> will compile fine, but will raise AV in runtime.....
>>
>> Will it be possible to determine in runtime is it read-only array or not without Access Violation Error?
>
> You could by looking at the s.ptr value and seeing if it is within the
> span
> of a read-only section of data. One way of doing this is to put a
> try..catch
> around an attempt to change it, and catch the AV.
>
>

Thanks. Clear enough.

(And I'll be on my own to discover read-only adress ranges, right? Rhetoric question. Don't need to answer.)

Andrew.




June 09, 2005
On Wed, 08 Jun 2005 18:00:15 -0600, Hasan Aljudy wrote:

> Walter wrote:
>> Added inner classes.
>> 
>> http://www.digitalmars.com/d/changelog.html
>> 
> 
> <quote>
> Now throws an ArrayBoundsError if accessing an associative array with a
> key that is not already in the array. Previously, the key would be added
> to the array.
> </quote>
> Execuse my n00bness, but how do you add keys to the associative array then?

int[char[]] arr;

  arr["these"] = 1;
  arr["are"] = 3;
  arr["new"] = 6;
  arr["keys"] = 2;

In previous versions, the line below would have automatically added the key "not here" to the array  ...

  if (arr["not here"]) { . . .}


-- 
Derek
Melbourne, Australia
9/06/2005 10:27:10 AM
June 09, 2005
On Wed, 08 Jun 2005 16:48:14 -0700, Unknown W. Brackets wrote:

> It would still have to count curly braces, at the least, because a literal reading of your suggestion means:
> 
> version (asdf)
> {
>    if (true)
>    {
>       writef("only shown for version=asdf!");
>    }
> 
>    writef("shown always.");
> } // <-- error.

I said the stuff in between the braces, that is the version statement's braces would be ignored. Thus your example above is equivalent to ...

  version (asdf)
  {
     Any text at all can go here (except unmatched braces)
  }

I think you were trying to say ...

 version (asdf)
 {
    writef("only shown for version=asdf!");
 }
 writef("shown always.");

I know its not perfect but it could be a starting point for discussion and thought. Though I believe its a hopeless situation now.

Anyhow, I'd better go back to porting my macro processor to D ;-)

-- 
Derek
Melbourne, Australia
9/06/2005 10:29:53 AM
June 09, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:d85vju$so2$1@digitaldaemon.com...
> Added inner classes.
>
> http://www.digitalmars.com/d/changelog.html

This is the single most amazing patch I've seen since I found D!

Woot!