Jump to page: 1 211  
Page
Thread overview
food for thought - swift 5 released - bottom types, string interpolation, and stuff.
Apr 09, 2019
aliak
Apr 10, 2019
Walter Bright
Apr 11, 2019
mate
Apr 11, 2019
Dennis
Apr 11, 2019
Julian
Apr 11, 2019
Walter Bright
Apr 11, 2019
Mike Franklin
Apr 12, 2019
Walter Bright
Apr 12, 2019
matheus
Apr 12, 2019
aliak
Apr 12, 2019
Mike Franklin
Apr 12, 2019
Mike Franklin
Apr 12, 2019
Walter Bright
Apr 12, 2019
Mike Franklin
Apr 12, 2019
Julian
Apr 14, 2019
Laeeth Isharc
Apr 12, 2019
Walter Bright
Apr 12, 2019
Dennis
Apr 12, 2019
Nicholas Wilson
Apr 13, 2019
Walter Bright
Apr 14, 2019
mate
Apr 16, 2019
Julian
Apr 13, 2019
Walter Bright
Apr 13, 2019
Julian
Apr 13, 2019
Andre Pany
Apr 13, 2019
aliak
Apr 13, 2019
Abdulhaq
Apr 13, 2019
Basile B.
Apr 13, 2019
Julian
Apr 13, 2019
Basile B.
Apr 13, 2019
H. S. Teoh
Apr 13, 2019
Walter Bright
Apr 13, 2019
Julian
Apr 13, 2019
Julian
Apr 13, 2019
Julian
Apr 13, 2019
Patrick Schluter
Apr 13, 2019
Abdulhaq
Apr 17, 2019
Walter Bright
Apr 17, 2019
aliak
Apr 14, 2019
Timon Gehr
Apr 12, 2019
Nicholas Wilson
Apr 25, 2019
Terry Arkson
Apr 25, 2019
H. S. Teoh
Apr 26, 2019
aberba
Apr 27, 2019
Jürgen Reichmann
Apr 12, 2019
Timon Gehr
Apr 12, 2019
Walter Bright
Apr 12, 2019
aliak
Apr 12, 2019
Patrick Schluter
Apr 12, 2019
jmh530
Apr 12, 2019
Walter Bright
Apr 13, 2019
aliak
Apr 12, 2019
Walter Bright
Apr 12, 2019
Timon Gehr
Apr 12, 2019
Walter Bright
Apr 14, 2019
Timon Gehr
Apr 14, 2019
mate
Apr 14, 2019
Timon Gehr
Apr 14, 2019
Walter Bright
Apr 14, 2019
Timon Gehr
Apr 15, 2019
Walter Bright
Apr 15, 2019
Timon Gehr
Apr 15, 2019
Walter Bright
Apr 15, 2019
H. S. Teoh
Apr 16, 2019
mate
Apr 14, 2019
Walter Bright
Apr 14, 2019
Timon Gehr
Apr 15, 2019
Walter Bright
Apr 15, 2019
Timon Gehr
Apr 14, 2019
lithium iodate
Apr 14, 2019
Adam D. Ruppe
Apr 14, 2019
lithium iodate
Apr 14, 2019
Julian
Apr 14, 2019
lithium iodate
Apr 11, 2019
Alex
Apr 11, 2019
Alex
Apr 11, 2019
aliak
Apr 11, 2019
Dennis
Apr 11, 2019
Guillaume Piolat
Apr 11, 2019
Tony
Apr 12, 2019
aliak
Apr 12, 2019
Paulo Pinto
Apr 12, 2019
aliak
Apr 12, 2019
Walter Bright
Apr 14, 2019
Timon Gehr
Apr 15, 2019
H. S. Teoh
Apr 15, 2019
rikki cattermole
Apr 16, 2019
H. S. Teoh
Apr 16, 2019
JN
April 09, 2019
I personally love swift as a language because it's just a pleasure to write _and_ read. Swift 5 was released recently [0] and has a few interesting additions, particularly the additions they've added to string interpolation [1] so that you could do things like

let a: MyType = "this is an \(type: .interpolated) string"

The "this is a" part is parsed separately by 'a' and the interpolated part "\(min: 1) is parsed as a type that is expected by your StringInterpolation implementation

// member function that implements string interpolation
mutating func appendInterpolation(min: Int) {
  //...
}

And then as is usual with swift, they try and make it as readable as easy to reason with as possible, so they added things like isOdd, isEven, and isMultiple(of:) [2] so that you don' t have to mentally parse something like "% x == 0" or any bit operation magic that tries to be too clever to do the same thing.

And another cool thing was they took their bottom type and made it conform to a hashable and equatable type [3]. It would be the equivalent if D had an Expect(SuccessType, ErrorType) type and if either success or error type could never happen, could be replaced by Bottom:

alias NeverError(SuccessType) = Expect!(SuccessType, bottom_t);
alias NeverSuccess(ErrorType) = Expect!(bottom_t, ErrorType);

[0] https://swift.org/blog/swift-5-released/
[1] https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md
[2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
[3] https://github.com/apple/swift-evolution/blob/master/proposals/0215-conform-never-to-hashable-and-equatable.md

Cheers,
- Ali
April 10, 2019
On 4/8/2019 11:23 PM, aliak wrote:
> [2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md 


"Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views"

Huh.
April 11, 2019
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
> I personally love swift as a language because it's just a pleasure to write _and_ read.
>

I understand this is subjective. Still this is _not_ pleasure to read. Feels like C++ syntax reborn.

// Bool.swift in apple/swift
public static func random<T: RandomNumberGenerator>(using generator: inout T) -> Bool {
    return (generator.next() >> 17) & 1 == 0
}
April 11, 2019
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
> I personally love swift as a language because it's just a pleasure to write _and_ read. Swift 5 was released recently [0] and has a few interesting additions, particularly the additions they've added to string interpolation [1] so that you could do things like
>
> let a: MyType = "this is an \(type: .interpolated) string"

This should've been:

let a: MyType = "this is an \(min: 1) string"

April 11, 2019
On 4/9/19 2:23 AM, aliak wrote:
> [2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md

Wow. And here I was thinking we have clowny things in the standard library...
April 11, 2019
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
> I personally love swift


It's important to not that Apple has a vested interest into breaking your code often and later, and it will happen eventually when Swift is deprecated and the next Apple langage is out.

This is because Apple sells hardware and breaking software often makes up reasons for software providers to be incompatible with older hardware, which leads to hardware selling more.


April 11, 2019
On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright wrote:
> On 4/8/2019 11:23 PM, aliak wrote:
>> [2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
>
>
> "Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views"
>
> Huh.

Shocking indeed.
April 11, 2019
On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
> On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright wrote:
>> On 4/8/2019 11:23 PM, aliak wrote:
>>> [2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
>>
>>
>> "Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views"
>>
>> Huh.
>
> Shocking indeed.

I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?
April 11, 2019
On Thursday, 11 April 2019 at 17:52:41 UTC, Andrei Alexandrescu wrote:
> Wow. And here I was thinking we have clowny things in the standard library...

I don't get what's clowny about it, it gives a clear name for a common function and it hides unnecessary implementation details. Do you think properties like int.min are clowny too and that people should just write (1 << (int.sizeof*8-1)) or use a D equivalent of limits.h?
April 11, 2019
On Thursday, 11 April 2019 at 21:21:16 UTC, Dennis wrote:
> On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
>> On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright
>> wrote:
>>> On 4/8/2019 11:23 PM, aliak wrote:
>>>> [2]
>>>> https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
>>>
>>>
>>> "Stack Overflow questions: c - How do I check if an integer
>>> is even or odd? 300,000+ views java - Check whether number is
>>> even or odd 350,000+ views Check if a number is odd or even
>>> in python 140,000+ views"
>>>
>>> Huh.
>>
>> Shocking indeed.
>
> I don't get it. What's shocking about it, that people often
> need to know the parity of a number or that people aren't born
> with the knowledge that the % operator can be used for that?

The perspective of the shocked is: these people are asking if a
value has a particular property. Rather than *thinking* about the
property and the tools at hand, and connecting them to arrive at a
solution, they're just groping for a language valueHasProperty
feature--and are given it, when it's lacking. This obviously can't
scale to real software, though. There's no expectation that Swift
learners will put Applications.Games.SimilarTo(Games.AngryBirds,
0.95); in a file and compile that and then ship the result.

And it seems to be obvious that no thought at all happened, because
oddness is a really easy property of a number to test. Geez, it's
not like we're expecting people to have memorized their hex and
octal digits.

But, I'd say that's not so obvious. On the simplest stuff
especially, people are not satisfied with only coming up with a
solution. They want a solution that can't be criticized. Suppose
someone was learning D, and when they couldn't remember writeln
offhand hand, they wrote something like

  foreach (char; str) {
      asm {
          // hardcoded Linux write() syscall of single character
      }
  }

Would you reaction to this code be:

a) Wow! It's great how you filled your D library gap with so much
other knowledge, to arrive at a functional solution.

b) Criticism #1: this will be obnoxiously slow.
   ...
   Criticism #40: I hate you.

If a language *does* have a valueHasProperty built-in, people want
to know so that they can use it.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11