ave Sweeris
>
>> On Aug 2, 2016, at 6:22 PM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> I'm trying to define a protocol that has a read-only, immutable member
>> "uuid" that can be set in the init() method, but I'm havin
I'm trying to define a protocol that has a read-only, immutable member "uuid"
that can be set in the init() method, but I'm having trouble. I have this:
protocol
Element
{
var uuid : { get }
}
extension
Element
{
init(...)
{
self.uuid = ...
}
}
I can't make it let,
> On Aug 2, 2016, at 13:07 , Dave Abrahams via swift-users
> wrote:
>
>
> on Mon Aug 01 2016, Rick Mann wrote:
>
>>> On Aug 1, 2016, at 19:18 , Jack Lawrence wrote:
>>>
>>> Jens: Why? There are significant benefits to value semantics for
>>> this
header = parsedHeader
>> }
>> }
>
> Then, if you want to provide a nicer interface, do it with an extension:
>
>> protocol Element {
>> var uuid : UUID{ get }
>> var name : String? { get, set }
>> }
>>
>> extension PartIn
d to see that change.
I don't think I get to take advantage of value semantics, and it makes me
wonder if any typical, non-trivial model's object graph really has no reference
semantics.
>
> Jack
>> On Aug 1, 2016, at 4:32 PM, Jens Alfke via swift-users
>> <swift-users@swift.or
It sure seems natural.
Is there some reason the language can't allow a sub-struct to add member
variables, such that the whole is treated like a contiguous set of members?
In my case, I have a rect-like value type, but I'd rather it inherit from
CGRect, rather than contain a CGRect. That makes
> On Aug 1, 2016, at 16:32 , Jens Alfke <j...@mooseyard.com> wrote:
>
>
>> On Aug 1, 2016, at 1:19 AM, Rick Mann via swift-users
>> <swift-users@swift.org> wrote:
>>
>> It seems like reference semantics are more appropriate here.
>
> Yes,
In my schematic capture app, I had a class hierarchy that started with Element.
From that I derived PartDefinition and PartInstance. Element has an immutable
UUID, name, and description. Element knows how to encode itself as XML by
conforming to an XMLCoding protocol.
Now I'm trying to make
> On Aug 1, 2016, at 02:25 , Rimantas Liubertas wrote:
>
>
> I did. That's one of the two talks I mentioned.
>
> Well, so they did cover this, didn't they? You move item, you get the new
> struct with the new position. And if you save the old one, you have a cheap
> way
> On Aug 1, 2016, at 02:14 , Rimantas Liubertas wrote:
>
>
> Similarly, in the diagramming example from the WWDC videos, how would that
> app handle the user editing existing Drawables in the Diagram? Let's say you
> allow the user to click on a Drawable and drag it to
I watched the WWDC 2015 video about protocol-oriented programming and value
semantics. Both of them use the example of a diagramming app, where the user
can make a diagram of circles and polygons. They make a protocol for Drawable
(makes sense), and then make Circle and Polygon structs.
I'm
On Thu, Jul 28, 2016 at 2:55 PM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I often call methods that return an optional collection. I then iterate over
> it. The problem is, it's a bit cumbersome to write:
>
> if let container = someOptio
I often call methods that return an optional collection. I then iterate over
it. The problem is, it's a bit cumbersome to write:
if let container = someOptionalContainer
{
for item in container
{
}
}
I wish I could just write
for item in
> On Jul 10, 2016, at 11:44 , Saagar Jha via swift-users
> wrote:
>
> Well, what if you wanted to create a String with one character? There’s no
> way to differentiate.
That hardly seems like the justification. In that case, you'd specify the type:
let s: String =
self."
To me, for an instance, foo an foo.self should be equivalent in all respects
(shouldn't it?).
>
> Best,
> Austin
>
>
> On Fri, Jul 8, 2016 at 9:38 AM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I just saw a question which brough
I just saw a question which brought up something I didn't know about.
Apparently sometimes you have to call object.self in a place that looks like
you should just use "object." What does this usage mean?
for subclassObject in objects {
switch subclassObject.self {<--- Here, why not
> Karen Stone wrote:
>> I believe there’s real value in being explicit about referencing class
>> members. It helps both the reader of the code and it makes writing code
>> with typical IDE conveniences like code completion less cluttered and more
>> informative. Unfamiliar class methods
sure seems like Swift could easily check for
Unsafe Pointers with value == 0.
>
> Dan
>
> On Fri, Jul 1, 2016 at 2:59 AM, Rick Mann via swift-users
> <swift-users@swift.org> wrote:
> I have some Swift code (in Xcode 7.3) that's calling a C function in the GDAL
&g
I have some Swift code (in Xcode 7.3) that's calling a C function in the GDAL
library. It's declared like this:
typedef void *GDALDatasetH;
GDALDatasetH CPL_DLL CPL_STDCALL
GDALOpen( const char *pszFilename, GDALAccess eAccess ) CPL_WARN_UNUSED_RESULT;
I'm calling it with code like this:
class
Why can my instance methods not call class methods without the class specifier?
class MyClass
{
func
foo()
{
classMethod()
}
class
func
classMethod()
{
}
}
Why do I have to call MyClass.classMethod()? Just a choice made by the language
designers to distinguish
101 - 120 of 120 matches
Mail list logo