Are the words Element and Sequence reserved in Swift? - swift

In my (chemistry related) project, I'd like to use the words Elementand Sequence for data structures. Will there be a conflict with the same names that are already used in Swift, should I rename them to MyElement and MySequence to be safe?
UPDATE:
I'm editing the question to hopefully make it more clear as was requested. The following quote is from the Generics section of Apple's Swift documentation:
Element defines a placeholder name for “some type Element” to be
provided later on. This future type can be referred to as “Element”
anywhere within the structure’s definition. In this case, Element is
used as a placeholder in three places
So, my question was if I can use the word Element for a structure without conflicting. The same for Sequence which I have seen used as well in sample code - although I cannot find it anymore. The accepted answer below explains this.

Those are not reserved words in Swift. The identifier Element is used as an associated type inside some generic types in the standard library, but you can also use it for your own type if you want, although it might become confusing. The identifier Sequence is not currently used by the standard library.

Related

What are the function-call/procedure-call pairs in GAP?

By function-call/procedure-call pairs, I mean pairs of functions that do the same thing, except one returns it's result whereas the other alters it's argument(s) to be the result. For example the pair List/Apply.
List(list, func) Returns the list resulting from applying the function func to every value of list.
Apply(list, func) Applies the function func to every value of a mutable list list, changing list.
I've become annoyed of writing my own functions to find that GAP already had a built in version I should be using, so it'd help to know these pairs. Like, does Filtered have a procedural counterpart I don't know about? Or do I need to write my own? If a function does have a counterpart will it necessarily be listed in the documentation for that function? The only other such pair that I can think of right now is Concatenation/Append. What are other such pairs of functions/procedures in GAP?
Although this may be of little help, as Alexander Hulpke explained in https://math.stackexchange.com/questions/3704518, "The general language convention is that verbs do something to an object, while nouns create a new object with the desired characteristics." GAP naming conventions are described in the GAP Reference Manual here.
So, a counterpart to Filtered would likely be called Filter - but there is no such function (and Filter has another meaning in GAP). We do try to mention counterparts in corresponding manual sections - if you find them missing, then please suggest improvements to the GAP documentation, preferably at the GAP repository on GitHub.

What is #tfop in Swift Tensorflow and where is it defined?

I'm browsing the swift tensorflow code, and stumbled upon instances of
var result = #tfop("Mul", a, b)
#tfop is well explained in the doc here, in the sense of 'what it does' but I'm also interested in what is actually is from a language standpoint, or as a function implementation.
What does #tfop represent, beside a handle to the computation graph? why the '#'? Where can I find tfop implementation if I want to? (I browsed the code, but no luck, although I can't guarantee that I didn't miss anything).
per Chris Lattner:
#tfop is a “well known” representation used for tensor operations.
It is an internal implementation detail of our stack that isn’t meant
to be user visible, and is likely to change over time.
In Swift, "#foo(bar: 42)” is the general syntax used for “macro like”
and “compiler magic” operations. For example C things like FILE
are spelled as #file in swift:
https://github.com/apple/swift-evolution/blob/master/proposals/0034-disambiguating-line.md
And the “#line 42” syntax used by the C preprocesser is represented
with arguments like this: #sourceLocation(file: "foo", line: 42)
In the case of #tfop specifically, this is represented in the Swift
AST as an ObjectLiteralExpr, which is the normal AST node for this
sort of thing:
https://github.com/google/swift/blob/tensorflow/include/swift/AST/Expr.h#L1097
We use special lowering magic to turn it into a SIL builtin
instruction in SILGen, which are prefixed with "__tfop_"
https://github.com/google/swift/blob/tensorflow/lib/SILGen/SILGenExpr.cpp#L3009
I’d like to move away from using builtin instructions for this, and
introduce a first-class sil instruction instead, that’s tracked by:
https://github.com/google/swift/issues/16
These instructions are specially recognized by the partitioning pass
of GPE:
https://github.com/google/swift/blob/tensorflow/lib/SILOptimizer/Mandatory/TFUtilities.cpp#L715
source here

Duplicate properties/methods of an array?

I am a bit confused as to why this is happening. Here is the screenshot below:
As you can see, there are a few properties/methods that appear twice as I type(count, append(), underestimatedCount). This does not affect the outcome of the code, but I am wondering if this is a bug in Swift?
I was typing my array name, then .count:
shareUsers.count
And as I was typing the first two letters of count, the screenshot happened.
If you look at the Swift header, you'll see that count really is declared twice for Array — once in the "Default implementations of core requirements" extension, and once in the extension that adopts RangeReplaceableCollection. Similarly, append(contentsOf:) is declared twice, once the base declaration of Array, and once in the extension that adopts RangeReplaceableCollection. And so on.
I suspect that the Xcode code completion engine is simply reporting this as it sees it. It's just listing the declarations it finds in the headers.
You could reasonably file a bug report about Xcode's behavior in this regard, I think. The Swift header itself is not unreasonable but there's no good reason why the code completion engine needs to reflect the repeated declarations.

Naming methods in Swift versus Objective-C

All:
In Objective-C, the name is constructed by concatenating the signature keywords, e.g., application:didFinishLaunchingWithOptions:
How do people refer to the equivalent method in Swift, when discussing it with other programmers (including students)? For example, would you refer to verbally as application(), or application(_ didFinishLaunchingWithOptions:)?
Thanks,
Michael
Apple's style is to include all the parts of the declaration that make its unique function signature (and omit things that matter only to the implementor, like local parameter names). If you set the view on one of Apple's reference pages to Swift-only, you'll see this style in the method listings:
application(_:willFinishLaunchingWithOptions:)
application(_:didFinishLaunchingWithOptions:)
applicationDidBecomeActive(_:)
applicationWillResignActive(_:)
Obviously, when speaking aloud one can omit the punctuation and people will still know what you're talking about.
(Notice you can't call either of the first two just application(), because there are two distinct methods with that base name and different external parameter labels.)

ASN.1 SET type restrictions

I'm confused about the limitations on the ASN.1 SET type. In general, I realize that a SET type is basically the same as a SEQUENCE, except the order of the components doesn't matter.
The seminal book on ASN.1, "ASN.1 — Communication Between Heterogeneous Systems" by Olivier Dubuisson, has this to say about SETs:
If the component order of the SEQUENCE type does not matter, the key-
word SET is used for modeling such a non-ordered structure:
Description ::= SET {
surname IA5String,
first-name IA5String,
age INTEGER }
In this case, the application can provide the components to the
encoder in the best order for it.
What I immediately notice here is that in Dubuisson's example, the SET has two IA5String types in it. This seems to contradict what I've read here in this tutorial, which explicitly says that:
The type and value notations for SET are similar to SEQUENCE,
except that the type of each component must be distinct from all
others and the values can be in any order.
So how can a SET legally have two IA5String types? I'm inclined to trust Olivier Dubuisson's book over some random Internet tutorial, however, it doesn't make any sense that a SET type could have multiple components of the same type. The reason is that, in ASN.1, type identifiers aren't encoded, (at least for most common encodings like BER) so the decoder would have no way of knowing which component the IA5String applies to - is it surname or firstname? There's no way to tell if the ordering doesn't matter.
So did Olivier Dubuisson make a huge mistake here? (He also doesn't mention anywhere in his lengthy description of SET types anything about the fact that a SET can't have more than one of each type.)
The standard (X.680, 27.3) requires that the types of the components of a SET type all have different tags.
The "Description" type in the example violates this requirement if the enclosing ASN.1 module has IMPLICIT TAGS or EXPLICIT TAGS (because the types of the components surname and first-name have the same tag "universal 22"), but it is legal if the enclosing ASN.1 module has AUTOMATIC TAGS (because the types of those components now have different tags--"context-specific 0" and "context-specific 1", respectively--automatically assigned to them in replacement of the "universal 22" tags).
If there are two components with the same type in a SET, they can indeed not be distinguished. The example can still be correct provided it appears in a module with automatic tagging.