March 08, 2010 dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Lots of meat and potatoes here, and a cookie! (spelling checker for error messages) http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.057.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.041.zip Thanks to the many people who contributed to this update! |
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Thanks! A pleasant surprise to see interface contracts. |
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
>
>
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
>
> Thanks to the many people who contributed to this update!
This is great, thank you! I'm especially looking forward to playing with the new operator overloading method. :)
-Lars
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright <newshound1@digitalmars.com> wrote: > Lots of meat and potatoes here, and a cookie! (spelling checker for error messages) > > http://www.digitalmars.com/d/1.0/changelog.html > http://ftp.digitalmars.com/dmd.1.057.zip > > > http://www.digitalmars.com/d/2.0/changelog.html > http://ftp.digitalmars.com/dmd.2.041.zip > > Thanks to the many people who contributed to this update! I don't know what to find more awesome with this update - possibly the operator overloading. Thanks a bunch, guys! -- Simen |
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | Simen kjaeraas wrote:
> Walter Bright <newshound1@digitalmars.com> wrote:
>
>> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>>
>> http://www.digitalmars.com/d/1.0/changelog.html
>> http://ftp.digitalmars.com/dmd.1.057.zip
>>
>>
>> http://www.digitalmars.com/d/2.0/changelog.html
>> http://ftp.digitalmars.com/dmd.2.041.zip
>>
>> Thanks to the many people who contributed to this update!
>
> I don't know what to find more awesome with this update - possibly
> the operator overloading. Thanks a bunch, guys!
I just noticed that Steven Schveighoffer's array append patch made it into this release. That ranks pretty high on the awesome scale too. :)
-Lars
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
>
>
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
>
> Thanks to the many people who contributed to this update!
It seems array literals have become dynamic arrays, but I can't find any mention of that in the change log.
pragma(msg, typeof([1,2,3]).stringof);
// Prints "int[3u]" with DMD 2.040
// Prints "int[]" with DMD 2.041
-Lars
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 08 Mar 2010 09:54:12 +0300, Walter Bright <newshound1@digitalmars.com> wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
>
>
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
>
> Thanks to the many people who contributed to this update!
Thank! BTW, 2.0 changelog page is messed up again
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | On Mon, 08 Mar 2010 03:45:21 -0500, Lars T. Kyllingstad <public@kyllingen.nospamnet> wrote:
> Simen kjaeraas wrote:
>> Walter Bright <newshound1@digitalmars.com> wrote:
>>
>>> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>>>
>>> http://www.digitalmars.com/d/1.0/changelog.html
>>> http://ftp.digitalmars.com/dmd.1.057.zip
>>>
>>>
>>> http://www.digitalmars.com/d/2.0/changelog.html
>>> http://ftp.digitalmars.com/dmd.2.041.zip
>>>
>>> Thanks to the many people who contributed to this update!
>> I don't know what to find more awesome with this update - possibly
>> the operator overloading. Thanks a bunch, guys!
>
> I just noticed that Steven Schveighoffer's array append patch made it into this release. That ranks pretty high on the awesome scale too. :)
Thanks :)
One note that was not mentioned on the changelog, there are three new runtime functions for arrays. They are in object.di (and the docs are there too):
* setCapacity(T[] arr, int newcapacity): preallocate at least newcapacity elements. This is intended to replace the "set length to zero" trick.
* @property capacity(T[] arr): get the capacity (yes, it's a property, ddoc does not propogate the @property attribute)
* shrinkToFit(T[] arr): This one is a bit tricky and technically unsafe. It reduces the size of the "allocated" length to fit the length of the array. The allocated length is the length that the runtime assumes is being used of the memory block. This is what aids in preventing stomping, so use with care. You can achieve stomping if you use shrinkToFit on a slice, but still have references to the trimmed data. Example:
string s = "12345".idup;
string slice = s[0..2];
slice.shrinkToFit(); // tells the runtime that you will no longer use any data beyond the slice
slice ~= "00"; // appends in place, overwriting immutable data referenced in s!
Using s after such usage results in undefined behavior (probably should be noted in the docs).
The use case is when you want to reuse a buffer when you know you will not use the trimmed area again. You can consider the trimmed off data unallocated.
The shrinkToFit name is not my favorite, anyone care to submit a better name? minimize is out because it has connotations of math already.
setCapacity will be changed in the next release to reserve() (could not squeeze that change in), since it was pointed out that you are requesting a capacity, not setting it.
-Steve
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
>
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
>
>
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
>
> Thanks to the many people who contributed to this update!
bearophile must be very happy :-)
- Add !in operator.
- opCast(bool) and implicit call in if
But I don't like this: "This only happens, however, for instances of structs. Class references are converted to bool by checking to see if the class reference is null or not."
When I do:
if (x) {
}
I'm normally interested to enter the if branch if x is not null and it has an interesting value. For example, if I implement a String class I would implement it as not being empty. But I think the biggest problem is making a different semantic for this to structs and classes. You'll have programmers wondering why the if branch was entered even if my class implemented opBool not to enter it. But time will tell.
For opCast maybe it would be better to have some examples, like:
T opCast(T)() if (is(T == bool)) {
}
T opCast(T)() if (is(T == int)) {
}
(it's not very intuitive that I have to do that to implement opCast, it's different from the other operator overloading that rely on strings)
But very cool that opCast to many different types is implemented! :-)
|
March 08, 2010 Re: dmd 1.057 and 2.041 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright Wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for error messages)
Thank you for the cookie too :-)
I will need some more time to try all the new things.
In the meantime I have already two small questions:
1) What does "Implemented attributes for constructors" in the changelog means?
2) What's the best way to translate this to the new operator regime?
T foo(T)(T s) if (__traits(hasMember, T, "opAdd")) {
return s + s;
}
I will probably write something more later,
bye and thank you,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation