# Internals & Design

**URL:** https://discourse.julialang.org/c/dev/5.md?no_subcategories=false&page=17

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 18

---

## [Singleton Types](https://discourse.julialang.org/t/singleton-types/96817)

<div class="topic-metadata">

**Author:** [@olynch](https://discourse.julialang.org/u/olynch)\
**Replies:** 6\
**Last updated:** [March 30, 2023, 1:02pm UTC](https://discourse.julialang.org/t/singleton-types/96817 "2023-03-30T13:02:43Z")

</div>

Often I want to use zero-sized structs for dispatch purposes, and it’s kind of annoying to have to make up a name for both the struct and the unique instance of that struct. In Scala, they have object as a primitive, wh…

---

## [Middle(x,y) for DateTime, Char, and others](https://discourse.julialang.org/t/middle-x-y-for-datetime-char-and-others/96220)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 3\
**Last updated:** [March 28, 2023, 9:50am UTC](https://discourse.julialang.org/t/middle-x-y-for-datetime-char-and-others/96220 "2023-03-28T09:50:01Z")

</div>

Should these methods exist? middle(x, y) Compute the middle of two numbers x and y, which is equivalent in both value and type to computing their mean ((x + y) / 2). julia\> middle(now(), now()) ERROR: MethodErr…

---

## [Weird interaction between generated function and inlining](https://discourse.julialang.org/t/weird-interaction-between-generated-function-and-inlining/96459)

<div class="topic-metadata">

**Author:** [@mhinsch](https://discourse.julialang.org/u/mhinsch)\
**Replies:** 5\
**Last updated:** [March 27, 2023, 3:50pm UTC](https://discourse.julialang.org/t/weird-interaction-between-generated-function-and-inlining/96459 "2023-03-27T15:50:11Z")

</div>

I am currently working on a way to memoise functions using fully typed containers (see this discussion for the general concept). I have a working implementation (sorry, still very barebone ATM), that seems to largely do …

---

## [Memory usage and performance differences in 1.9-rc1 vs. 1.8.5](https://discourse.julialang.org/t/memory-usage-and-performance-differences-in-1-9-rc1-vs-1-8-5/96209)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 12\
**Last updated:** [March 27, 2023, 4:12am UTC](https://discourse.julialang.org/t/memory-usage-and-performance-differences-in-1-9-rc1-vs-1-8-5/96209 "2023-03-27T04:12:42Z")

</div>

I have some memory- and CPU-intensive multithreaded image analysis code. In 1.8.5, on an AWS Linux system with 64 GB of RAM and 8 vCPUs, the code will run in cycles, spiking up to (for one example) 23 GB of allocated RA…

---

## [Support for urlsafe alphabets in Base64?](https://discourse.julialang.org/t/support-for-urlsafe-alphabets-in-base64/4065)

<div class="topic-metadata">

**Author:** [@krm01](https://discourse.julialang.org/u/krm01)\
**Replies:** 3\
**Last updated:** [March 26, 2023, 5:11pm UTC](https://discourse.julialang.org/t/support-for-urlsafe-alphabets-in-base64/4065 "2023-03-26T17:11:10Z")

</div>

the Base64 module seems to be hardcoded to use the standard alphabet - I need to consume data encoded with the urlsafe alphabet (-,\_ instead of +,/). As a workaround I’m translating the source string into the urlsafe equ…

---

## [Why are generated functions (maybe) impossible to statically compile?](https://discourse.julialang.org/t/why-are-generated-functions-maybe-impossible-to-statically-compile/96366)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 18\
**Last updated:** [March 25, 2023, 10:27pm UTC](https://discourse.julialang.org/t/why-are-generated-functions-maybe-impossible-to-statically-compile/96366 "2023-03-25T22:27:04Z")

</div>

I’m finally getting around to understanding generated functions, and the first paragraph under Optionally-generated functions raises a couple questions for me. I’ll repost the text here as it’s not too long: Generated …

---

## [On the arbitrariness of truth(iness)](https://discourse.julialang.org/t/on-the-arbitrariness-of-truth-iness/81381)

<div class="topic-metadata">

**Author:** [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Replies:** 49\
**Last updated:** [March 25, 2023, 7:04am UTC](https://discourse.julialang.org/t/on-the-arbitrariness-of-truth-iness/81381 "2023-03-25T07:04:13Z")

</div>

Occasionally someone will be annoyed that Julia requires an actual true or false value in conditionals, whereas many dynamic languages (including Lisps) allow arbitrary values in conditions and have rules about what coun…

---

## [Release notes of Julia 1.8 misses multidimensional array initialisation of any object](https://discourse.julialang.org/t/release-notes-of-julia-1-8-misses-multidimensional-array-initialisation-of-any-object/96332)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [March 20, 2023, 10:00am UTC](https://discourse.julialang.org/t/release-notes-of-julia-1-8-misses-multidimensional-array-initialisation-of-any-object/96332 "2023-03-20T10:00:21Z")

</div>

Julia 1.7 added the capacity to use the multiple semicolon syntax to initialise hard-coded arrays: " Repeated semicolons can now be used inside array concatenation expressions to separate dimensions of an array, with th…

---

## [Indexin takes a collection](https://discourse.julialang.org/t/indexin-takes-a-collection/96315)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [March 19, 2023, 7:48pm UTC](https://discourse.julialang.org/t/indexin-takes-a-collection/96315 "2023-03-19T19:48:57Z")

</div>

indexin takes a collection for both arguments, but since broadcasting is available most functions take a scalar. Why does this one take a collection for a?

---

## [Treating Union as multiple types](https://discourse.julialang.org/t/treating-union-as-multiple-types/96241)

<div class="topic-metadata">

**Author:** [@putianyi888](https://discourse.julialang.org/u/putianyi888)\
**Replies:** 9\
**Last updated:** [March 17, 2023, 8:27pm UTC](https://discourse.julialang.org/t/treating-union-as-multiple-types/96241 "2023-03-17T20:27:47Z")

</div>

This can happen quite often. f(a::AbstractVecOrMat, b::Number) = 1 f(a::AbstractVector, b::Any) = 2 julia\> f(\[1\],1) ERROR: MethodError: f(::Vector{Int64}, ::Int64) is ambiguous. Candidates: f(a::AbstractVecOrMat, b::…

---

## [Reverse view of an array](https://discourse.julialang.org/t/reverse-view-of-an-array/9657)

<div class="topic-metadata">

**Author:** [@kevin.squire](https://discourse.julialang.org/u/kevin.squire)\
**Replies:** 8\
**Last updated:** [March 16, 2023, 12:12am UTC](https://discourse.julialang.org/t/reverse-view-of-an-array/9657 "2023-03-16T00:12:03Z")

</div>

While reviewing a recent pull request in Images.jl, I ran across this line: cum\_pmf\_sq\_2 = reverse!(cumsum(reverse!(prob\_mass\_function\_sq))) Using reverse! is better than reverse here, but writing out the loops man…

---

## [Allowing the object.method(args...) syntax as an alias for method(object, args ...)](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 215\
**Last updated:** [March 14, 2023, 7:04am UTC](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051 "2023-03-14T07:04:49Z")

</div>

I started exploring Julia very recently and I like it. I’ve been chatting about it with colleagues. Many people coming from OOP languages (Python…) like the syntax object.method(a,b,c…). Since you can get a preview of …

---

## [Detecting presence of kwdef defaults](https://discourse.julialang.org/t/detecting-presence-of-kwdef-defaults/95991)

<div class="topic-metadata">

**Author:** [@lwabeke](https://discourse.julialang.org/u/lwabeke)\
**Replies:** 1\
**Last updated:** [March 13, 2023, 10:27pm UTC](https://discourse.julialang.org/t/detecting-presence-of-kwdef-defaults/95991 "2023-03-13T22:27:01Z")

</div>

For a while I have struggled with trying to figure out how to properly allow the Unmarshal.jl package to play with kwdef fields, in particular default fields. The logic typically was given a struct type T that I want to…

---

## [Why does julia have slots, rather than go full SSA?](https://discourse.julialang.org/t/why-does-julia-have-slots-rather-than-go-full-ssa/95649)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 7\
**Last updated:** [March 8, 2023, 4:10am UTC](https://discourse.julialang.org/t/why-does-julia-have-slots-rather-than-go-full-ssa/95649 "2023-03-08T04:10:46Z")

</div>

More a question of history. though, it seems like going full SSA would remove some sources of within function type-instability. Since it would be impossible to assign different types to same variable, since you actuall…

---

## [Is it possible for package precompilation fail quickly if some dependency fails to precompile because of an error?](https://discourse.julialang.org/t/is-it-possible-for-package-precompilation-fail-quickly-if-some-dependency-fails-to-precompile-because-of-an-error/95613)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [March 7, 2023, 10:52pm UTC](https://discourse.julialang.org/t/is-it-possible-for-package-precompilation-fail-quickly-if-some-dependency-fails-to-precompile-because-of-an-error/95613 "2023-03-07T22:52:35Z")

</div>

I often come across scenarios where package A depends on B, and making a change to B causes both B and A to precompile. Now, assume that there’s an error in B, and the precompilation fails for it. The precompilation atte…

---

## [Internal Design of a Julia Runtime in C#](https://discourse.julialang.org/t/internal-design-of-a-julia-runtime-in-c/95646)

<div class="topic-metadata">

**Author:** [@HyperSphereStudio](https://discourse.julialang.org/u/HyperSphereStudio)\
**Replies:** 1\
**Last updated:** [March 7, 2023, 5:02am UTC](https://discourse.julialang.org/t/internal-design-of-a-julia-runtime-in-c/95646 "2023-03-07T05:02:55Z")

</div>

I have been working hard recently on developing a runtime for Julia from the ground up written purely in C# (GitHub - HyperSphereStudio/Spinor: Spinor Programming Language. Dynamically Typed Extension of Julia written an…

---

## [Speculations about the default environment (or a new draft environment)](https://discourse.julialang.org/t/speculations-about-the-default-environment-or-a-new-draft-environment/78967)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 97\
**Last updated:** [March 6, 2023, 8:33am UTC](https://discourse.julialang.org/t/speculations-about-the-default-environment-or-a-new-draft-environment/78967 "2023-03-06T08:33:35Z")

</div>

The way the default environment works is somewhat confusing and, I think, unsatisfactory. Most users, except package developers well versed in development workflows, will always use packages by installing them in the def…

---

## [If Julia was static typed, how multiple dispatch would work?](https://discourse.julialang.org/t/if-julia-was-static-typed-how-multiple-dispatch-would-work/95529)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 3\
**Last updated:** [March 5, 2023, 1:52am UTC](https://discourse.julialang.org/t/if-julia-was-static-typed-how-multiple-dispatch-would-work/95529 "2023-03-05T01:52:03Z")

</div>

If Julia was a static typed language instead of dynamic typed, how would multiple dispatch work? It would be simple function overloading or something different? Instead of compiling the functions that are called during r…

---

## [Is \`reduce\` safe?](https://discourse.julialang.org/t/is-reduce-safe/95525)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 7\
**Last updated:** [March 4, 2023, 3:20pm UTC](https://discourse.julialang.org/t/is-reduce-safe/95525 "2023-03-04T15:20:32Z")

</div>

reduce (without init keyword) is much faster than foldl and foldr: julia\> v = rand(Int, 2^16); w = @view v\[2:2:end\]; julia\> @btime reduce(+, $w); 12.154 μs (0 allocations: 0 bytes) julia\> @btime foldl(+, $w); 190.20…

---

## [Rationale behind excluding some unicode characters from identifiers](https://discourse.julialang.org/t/rationale-behind-excluding-some-unicode-characters-from-identifiers/95509)

<div class="topic-metadata">

**Author:** [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Replies:** 10\
**Last updated:** [March 3, 2023, 6:52pm UTC](https://discourse.julialang.org/t/rationale-behind-excluding-some-unicode-characters-from-identifiers/95509 "2023-03-03T18:52:13Z")

</div>

I’m wondering why some Unicode punctuation characters (Open Punctuation Ps, and Close Punctuation Pe) were excluded from variables names (identifiers) in this PR. julia\> ❘u❘ = abs(u) # allowed, e.g. denote an absolute …

---

## [Why no \`sin(x::Eigen)\`?](https://discourse.julialang.org/t/why-no-sin-x-eigen/95492)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 2\
**Last updated:** [March 3, 2023, 12:06pm UTC](https://discourse.julialang.org/t/why-no-sin-x-eigen/95492 "2023-03-03T12:06:32Z")

</div>

I noticed that LinearAlgebra defines inv(A::Eigen), but only few other functions that that accept Eigen as inputs. It seems like it would be easy and sensible enough to define for f in (:exp, :cis, :log, :sqrt, …

---

## [Pkg.upgrade\_manifest errors if the manifest doesn't need upgrading](https://discourse.julialang.org/t/pkg-upgrade-manifest-errors-if-the-manifest-doesnt-need-upgrading/83320)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 2\
**Last updated:** [March 1, 2023, 5:51am UTC](https://discourse.julialang.org/t/pkg-upgrade-manifest-errors-if-the-manifest-doesnt-need-upgrading/83320 "2023-03-01T05:51:47Z")

</div>

Why is this an error rather than a no-op or warning? Pkg.upgrade\_manifest()' ERROR: Format of manifest file at \`C:\\Users\\Mark Nahabedian\\NahaJuliaLib.jl\\Manifest.toml\` already up to date: manifest\_format == 2.0.0 Stackt…

---

## [Getproperty for a Task is type unstable?](https://discourse.julialang.org/t/getproperty-for-a-task-is-type-unstable/95345)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [February 28, 2023, 5:50pm UTC](https://discourse.julialang.org/t/getproperty-for-a-task-is-type-unstable/95345 "2023-02-28T17:50:32Z")

</div>

julia\> a() = sum(i for i in 1:1000); julia\> b = Task(a); julia\> @descend\_code\_warntype (b -\> b.queue)(b) (::var"#87#88")(b) @ Main REPL\[64\]:1 Body::Any 1 ─ nothing …

---

## [Accessing abstract array struct field allocates memory?](https://discourse.julialang.org/t/accessing-abstract-array-struct-field-allocates-memory/95313)

<div class="topic-metadata">

**Author:** [@Kirby\_Zhang](https://discourse.julialang.org/u/Kirby_Zhang)\
**Replies:** 3\
**Last updated:** [February 28, 2023, 8:07am UTC](https://discourse.julialang.org/t/accessing-abstract-array-struct-field-allocates-memory/95313 "2023-02-28T08:07:04Z")

</div>

The following code uses AbstractVector as a struct field, and it results in memory being allocated: struct S1 A::AbstractVector{Int} end function f(s::S1) s.A\[end\] end s = S1(\[1,2,3\]) f(s) @code\_warntype f(s)…

---

## [Add varargs methods of \`any\`, \`all\`, and \`count\`](https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072)

<div class="topic-metadata">

**Author:** [@uniment](https://discourse.julialang.org/u/uniment)\
**Replies:** 26\
**Last updated:** [February 26, 2023, 7:10am UTC](https://discourse.julialang.org/t/add-varargs-methods-of-any-all-and-count/95072 "2023-02-26T07:10:26Z")

</div>

It would be helpful to have variable-length methods of any, all, and count for comparing collections, so that e.g. you could write this: all(≡, \[1,2,3\], \[1,2,3\]) # true count(≥, (3,2,1), 1:3) # 2 Proof of concept: Bas…

---

## [Convenience type for assembling sparse matrices](https://discourse.julialang.org/t/convenience-type-for-assembling-sparse-matrices/15262)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 5\
**Last updated:** [February 21, 2023, 11:36pm UTC](https://discourse.julialang.org/t/convenience-type-for-assembling-sparse-matrices/15262 "2023-02-21T23:36:00Z")

</div>

I find the IJV-approach to assembling sparse matrices quite cumbersome as it forces me to write three lines to set a single entry A\[i,j\] = v: push!(I,i) push!(J,j) push!(V,v) The situation becomes even worse if instead…

---

## [Why is \`Test\` so meta-programming heavy?](https://discourse.julialang.org/t/why-is-test-so-meta-programming-heavy/94619)

<div class="topic-metadata">

**Author:** [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Replies:** 29\
**Last updated:** [February 20, 2023, 8:14pm UTC](https://discourse.julialang.org/t/why-is-test-so-meta-programming-heavy/94619 "2023-02-20T20:14:33Z")

</div>

I am quite puzzled by the design choices of Julia’s Test - so I thought I should write my current understanding so that people can tell me what they think, or if I am misunderstanding something. As I understand it, Juli…

---

## [Triu and tril on Matrix](https://discourse.julialang.org/t/triu-and-tril-on-matrix/94917)

<div class="topic-metadata">

**Author:** [@putianyi888](https://discourse.julialang.org/u/putianyi888)\
**Replies:** 1\
**Last updated:** [February 20, 2023, 4:15pm UTC](https://discourse.julialang.org/t/triu-and-tril-on-matrix/94917 "2023-02-20T16:15:39Z")

</div>

The current codes are # dense.jl triu(M::Matrix, k::Integer) = triu!(copy(M), k) tril(M::Matrix, k::Integer) = tril!(copy(M), k) # generic.jl triu(M::AbstractMatrix,k::Integer) = triu!(copy(M),k) tril(M::AbstractMatrix…

---

## [Allocations in a convoluted setting](https://discourse.julialang.org/t/allocations-in-a-convoluted-setting/94905)

<div class="topic-metadata">

**Author:** [@maltesie](https://discourse.julialang.org/u/maltesie)\
**Replies:** 6\
**Last updated:** [February 20, 2023, 10:51am UTC](https://discourse.julialang.org/t/allocations-in-a-convoluted-setting/94905 "2023-02-20T10:51:01Z")

</div>

Hi all, I stumbled upon a combination of factors that lead julia to allocate memory where I dont think it should. I guess its an odd case and maybe this has a reason. If so, I would be happy if someone could explain it …

---

## [N-bit Integers in Julia](https://discourse.julialang.org/t/n-bit-integers-in-julia/94861)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 10\
**Last updated:** [February 19, 2023, 6:03pm UTC](https://discourse.julialang.org/t/n-bit-integers-in-julia/94861 "2023-02-19T18:03:03Z")

</div>

After getting some updated pointers from Rust dev Jubilee Young and encouragement from C standard project editor JeanHeyd Meneide on the arbitrary bitwidth integers (also known n-bit integers from the C23 draft standard)…

[Previous page](https://discourse.julialang.org/c/dev/5.md?no_subcategories=false&page=16)

[Next page](https://discourse.julialang.org/c/dev/5.md?no_subcategories=false&page=18)
