Skip to content
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

String is not a good example of a mutable struct #29454

Closed
oxinabox opened this issue Oct 1, 2018 · 3 comments
Closed

String is not a good example of a mutable struct #29454

oxinabox opened this issue Oct 1, 2018 · 3 comments
Labels
docs This change adds or pertains to documentation

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Oct 1, 2018

In the docs on mapping julia types to C types,
it gives String as an example of a mutable struct

Which is not really a clear example.

https://github.com/JuliaLang/julia/blob/391f2dd2b5ac67da4a136673b1923d966b606439/doc/src/manual/calling-c-and-fortran-code.md#type-correspondences

@StefanKarpinski
Copy link
Member

Yes, that is really a bad choice for that example.

@JeffBezanson JeffBezanson added the docs This change adds or pertains to documentation label Oct 1, 2018
@oxinabox
Copy link
Contributor Author

oxinabox commented Oct 2, 2018

There are very few good examples in Base,
We use very few mutable structs that are not type parametric,
or otherwise weird.

filter(names(Base)) do name
	T = try
		eval(name)
	catch
		return false
	end
	
	isconcretetype(T) &&
	T.mutable &&
	fieldcount(T) > 0 && # knocks out String
	nameof(T) == name && # Knock-out type-aliases
	!any(F <: Ptr for F in fieldtype.(T, fieldnames(T))) # Nothing Pointer based
end

Gives back:

4-element Array{Symbol,1}:
 :BitSet
 :Condition
 :Pipe
 :ReentrantLock

So it really looks like BitSet is our best option.

don-suth added a commit to don-suth/julia that referenced this issue Oct 2, 2018
Changed `String` to `BitSet` as a `mutable struct` example.
StefanKarpinski pushed a commit that referenced this issue Oct 2, 2018
Changed `String` to `BitSet` as a `mutable struct` example.
@KristofferC
Copy link
Member

#29475

KristofferC pushed a commit that referenced this issue Oct 6, 2018
Changed `String` to `BitSet` as a `mutable struct` example.

(cherry picked from commit dee7d77)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Changed `String` to `BitSet` as a `mutable struct` example.

(cherry picked from commit dee7d77)
KristofferC pushed a commit that referenced this issue Feb 20, 2020
Changed `String` to `BitSet` as a `mutable struct` example.

(cherry picked from commit dee7d77)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

4 participants