-
-
Notifications
You must be signed in to change notification settings - Fork 742
Issue 6224 - Add ownerTid() property. #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/** | ||
* Thrown when $(D ownerTid) doesn't find an owner thread. | ||
*/ | ||
class OwnerTidMissing : Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, we append Error
or Exception
to exception classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that convention seems to be only partially followed, e.g. MessageMismatch
, OwnerTerminated
, LinkTerminated
, PriorityMessageException
, MailboxFull
.
But why are we using some form of Hungarian notation in a statically typed language?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is common convention for many, many languages, regardless of static or dynamic typing. It's helpful because you don't have to go and look at the class definition to figure out what a PriorityMessage
might be. The Exception
lets you know immediately. It also avoids conflating exception types with the general type 'namespace'.
I don't know why half of the types in this module don't follow the convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that is very helpful (to me), is knowing whether the object thrown is an Exception or an Error. The fact that it is in the name keeps things self documented.
I've renamed it to |
Whilst we're adding exceptions, how about a Just throwing it out there. |
@@ -303,6 +303,19 @@ class MailboxFull : Exception | |||
} | |||
|
|||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if maybe this should be an Error
? Isn't it a logical error to try to get a Tid when none is present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say for sure, but I think a thread which spawned another one could exit while the child thread is still running. In that case ownerTid would likely be empty. I'll cc Sean about it: @complexmath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@complexmath ping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not add to Error
s without good reason. Let's keep this an exception.
Issue 6224 - Add ownerTid() property.
http://d.puremagic.com/issues/show_bug.cgi?id=6224
Nothing too controversial. But since the returned type is a struct I figure it's better to throw an exception rather than the user getting a segfault when they try to call
ownerTid.send()
.Additionally I've removed
Tid.send
, it was duplicated code but isn't required anymore since UFCS can take its place.