# A kind of "two language problem" in Julia Ecosystem

**URL:** <https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445>\
**Category:** General Usage\
**Created:** [June 16, 2023, 11:56am UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445 "2023-06-16T11:56:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 16, 2023, 11:56am UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/1 "2023-06-16T11:56:25Z")

</div>

I am learning a lot these days by reading the source code of various Julia packages. There are certain scenarios where I see certain things achieved in some packages - things that don’t seem to be documented anywhere.

It is always expected to have a knowledge gap between those who are familiarized with Julia’s internals and those who are learning the language “from outside” - using the documentation (like myself): but I feel this is especially true for Julia.

When reading some source code and comparing it with the code I write, I feel like we are using two different languages (and I understand that the “type” of code written for a package can differ greatly from the regular “application” code - but still).

A thing that I find exciting about reading the source code is the discovery of “unknown unknowns”: those nice surprises where you learn something that you didn’t even think was possible (and was never your purpose in searching for those). However, I think I would really like to have these “unknown unknowns” documented instead of having to stumble upon them by accident (because it makes me wonder how many hidden things are still there, and I will never find them).

Is this only my subjective experience? Or is there a real gap between the documentation and frequently used idioms in various packages?

I think my subjective experience is warranted if the following is true: “There is actually code written in such a way that somebody relying on the documentation alone would not be able to write.”

How do other people feel about this? Are there certain tips that you can offer so I can narrow this perceived gap?

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [June 16, 2023, 12:03pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/2 "2023-06-16T12:03:02Z")

</div>

Can you give some examples of package code that could not be written based on just the manual?

There are some packages that rely on Base internals, but that should generally be discouraged, since the package code can be broken by a minor version or patch version update to Julia.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 16, 2023, 12:13pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/3 "2023-06-16T12:13:33Z")

</div>

> [@algunion](#):
>
> learning a lot these days by reading the source code of various Julia packages

That’s a great way to learn Julia.

Nevertheless, keep in mind that if you are new to a language, then learning the best way(s) to use it takes time. You may be experiencing that.

It is hard give a more specific response without concrete examples.

---

<div class="post-metadata">

**Author:** ![caleb-allen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/caleb-allen/32/14054_2.png) [@caleb-allen](https://discourse.julialang.org/u/caleb-allen)\
**Post date:** [June 16, 2023, 12:16pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/4 "2023-06-16T12:16:13Z")

</div>

One example that comes to mind is index-access behavior without a numbered index, such as the way `Ref` uses `getindex` and `setindex!`:

```julia
# refvalue.jl
getindex(b::RefValue) = b.x
setindex!(b::RefValue, x) = (b.x = x; b)

```

Which allows the following:

```julia
julia> a = Ref{Int}(10)
Base.RefValue{Int64}(10)

julia> show(a[])
10

```

Seeing `a[] = ...` is somewhat surprising as a new user, and isn’t explained in the [Interfaces/Indexing section](https://docs.julialang.org/en/v1/manual/interfaces/#Indexing) of the manual

I really like how index style access is used hack additional functionality into assignment like in Observables.jl

```julia
julia> using Observables

julia> observable = Observable(0)
Observable(0)

julia> observable[]
0

julia> obs_func = on(observable) do val
           println("Got an update: ", val)
       end
ObserverFunction defined at none:2 operating on Observable(0)

julia> observable[] = 42
Got an update: 42
42

```

But it took me quite a while to discover the actual mechanism used here; it wasn’t clear to me if it was the same syntax as indexing, or if it was another unrelated piece of syntax.

I should say that this is a pretty niche problem, and I don’t particularly think the manual is lacking for such a specific issue - I did in fact learn the mechanism by reading through source. But I thought this might be the type of example that @algunion is talking about?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 16, 2023, 12:17pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/5 "2023-06-16T12:17:45Z")

</div>

> [@algunion](#):
>
> How do other people feel about this? Are there certain tips that you can offer so I can narrow this perceived gap?

I think that’s fairly true. There is code written in packages and in base Julia which is hard to understand (sometimes even if the syntax itself is familiar). Many times this results from the fact that the library code has to deal with a lot of possibilities (error handling, generic types, exceptions, etc) that obfuscate the simple rationale of the function.

Personally, I find hard to learn these things without having myself a problem to solve, and if one wants to be actually do stuff, I think the best to do is just start implementing stuff and progressively deal with the possibility that the language offers.

I can help giving one example:

If I had to implement a sum of two vectors (assuming that `x + y` didn’t work already, of course), I would do:

```julia
function sum_vecs(x::AbstractVector,y::AbstractVector)
    z = similar(x)
    for i in eachindex(x,y)
        z[i] = x[i] + y[i]
    end
    return z
end

```

Yet, we have this when we `@edit rand(10) + rand(10)`:

```julia
function +(A::Array, Bs::Array...)
    for B in Bs
        promote_shape(A, B) # check size compatibility
    end
    broadcast_preserving_zero_d(+, A, Bs...)
end

```

Which of course is from the start more complicated, deals with more cases, check shapes, and then calls a function which is somewhat optimizing something related to zero dimensions. Yes, that’s more complicated, but the simple code is not wrong or particularly bad. It will be correct and performant, if I had to use it in a package.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 16, 2023, 1:03pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/6 "2023-06-16T13:03:16Z")

</div>

> [@caleb-allen](#):
>
> Seeing `a[] = ...` is somewhat surprising as a new user, and isn’t explained in the [Interfaces/Indexing section](https://docs.julialang.org/en/v1/manual/interfaces/#Indexing) of the manual

It is however used 3 times in the documentation for `Ref`, and also indicated in the docstring for `getindex` (since `inds...` means zero or more things)

```julia
  getindex(A, inds...)

  Return a subset of array A as specified by inds, where each ind may be, for example, an Int, an AbstractRange, or a Vector. See the manual section on array indexing for details.

```

Having said that, this sounds like a good opportunity for someone who finds this part of the documentation lacking to open a PR 🙂

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 16, 2023, 1:41pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/7 "2023-06-16T13:41:05Z")

</div>

Thanks a lot. This way of viewing things helps.

Recently I delved into [Cobweb.jl](https://github.com/JuliaComputing/Cobweb.jl/blob/main/src/Cobweb.jl) - where they have a function `h` that can be used with appended dot notation - with out-of-the-box intellisense (e.g. `h.div`, `h.p` - etc.).

I am not saying that I am the only guy who managed to review ALL of Julia’s documentation (I certainly didn’t).

But from what I read, I never encountered the following possibility (and I am very pleased by this finding).

Now this might be something naive and not a big deal for most of the experienced Julia programmers - but for me, it was an _aha_ moment, especially because I could do this on a function.

```julia
function myh(a)
	"you called myh using property with value $a"
end

Base.getproperty(::typeof(myh), tag::Symbol) = myh(string(tag))
Base.propertynames(::typeof(myh)) = [:x, :y, :z]

myh.z # outputs: "you called myh using property with value z"

```

And now I can have intellisense for my `myh` function (e.g. `myh.x`, `myh.y`).

While we have this documentation for [propertynames](https://docs.julialang.org/en/v1/base/base/#Base.propertynames), it wasn’t clear to me that the above feat was even possible - somewhat that doesn’t follow from the documentation (or maybe there is another relevant material that I missed).

Now, when the “unknown unknown” became “known known,” it is somehow easy to look back and give the explanation: this is the power of multiple dispatch at work. But my brain wasn’t able to travel the other way around: and this confirms what you said (these kinds of solutions have a better chance to present themselves when actually trying to achieve/solve something).

Anyway - thanks for your time and explanations.

I’ll keep up the exciting activity of reading source code - I never thought it might be so rewarding.

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 16, 2023, 1:55pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/8 "2023-06-16T13:55:07Z")

</div>

The thing with the documentation is that once you get familiar enough to get programming, you only use it to fill some gaps (or when you encounter new challenges that require acquiring some new info from docs).

Please take a look at my example from [here](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/7). I can look at the documentation, and it is still opaque that in Julia I can have “a property of a function call the same function with a certain input.” And even more: you can call the property of the function as a function that will, in turn, call the original function (see Cobweb.jl main functionality).

Again, this might be something pretty lame for the veterans around here - but I have written code in Julia for a few years now (and full-time in the last two years). The good part is that you can do a lot with what is transparent in the language without ever encountering things like “property calling” on a function - I get that it is just syntactic sugar, and you don’t actually need it to get things done.

Anyway - I am intrigued by these findings in Julia packages source code - but mostly excited and motivated to dig deeper.

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 16, 2023, 2:10pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/9 "2023-06-16T14:10:50Z")

</div>

@CameronBieganek, I would differentiate between two kinds of levels of “could not be written.”

1. Factually impossible to be written by someone having full knowledge of the documentation.
2. Practically impossible / very improbable (as in “it would not be able to pull it off”). This is to say that relying upon the documentation alone might not have transpired as a possibility to the language user.

I was referring to the latter. Also, please check the example from here [here](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/7).

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [June 16, 2023, 2:14pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/10 "2023-06-16T14:14:48Z")

</div>

> [@algunion](#):
>
> I can look at the documentation, and it is still opaque that in Julia I can have “a property of a function call the same function with a certain input.”

I think of syntax as a set of Lego pieces. Give a bucket of pieces to different people, and they’ll build different things. Some will build things (combining the pieces in a certain way) that you could never have imagined possible.

As you’ve found out, a good way to learn new piece combinations is to look at what other people have done. But there’s also some value in keeping things [simple](https://www.laws-of-software.com/laws/kernighan/).

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 16, 2023, 2:28pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/11 "2023-06-16T14:28:54Z")

</div>

This notion of “unknown unknowns” resonates strongly with me, and not just on the level of syntax or optimization tricks. My main unknown unknown was the set of all tools that make package writing easier, which (for the most part) you can’t even discover by reading the code because they were used locally by the developers.  
I’m trying to address this here:

> [@\[Seeking feedback\] Blog post about "Modern Julia workflows"?](https://discourse.julialang.org/t/seeking-feedback-blog-post-about-modern-julia-workflows/100324):
>
> Hi everyone, After watching a [nice video](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298) by @jacobusmmsmit yesterday, I sat down and thought about all the lore that experienced Julia users keep in their heads. How to write and share code properly, which packages to use and when, etc. This accumulated knowledge makes our development experience very pleasant, but it is long to acquire and beginners don’t always know where to look. The official documentation is only part of the story: best practices involve a flurry of external packages, whic…

Reading this discourse is a great way to keep discovering by the way, it is full of extremely knowledgeable people giving answers to questions you never even knew you had. So keep up the good work!

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [June 16, 2023, 3:08pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/12 "2023-06-16T15:08:59Z")

</div>

> [@algunion](#):
>
> I would differentiate between two kinds of levels of “count not be written.”
> 
> 1. Factually impossible to be written by someone having full knowledge of the documentation.
> 2. Practically impossible / very improbable (as in “it would not be able to pull it off”). This is to say that relying upon the documentation alone might not have transpired as a possibility to the language user.
> 
> I was referring to the latter. Also, please check the example from here [here](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/7).

I was not doubting your premise, I was just asking for specific examples. 🙂

The `getproperty` overloading for functions is a good example. I was aware of `getproperty` overloading for structs, but it never occurred to me to overload property access for functions.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 16, 2023, 5:32pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/13 "2023-06-16T17:32:07Z")

</div>

> [@algunion](#):
>
> I can look at the documentation, and it is still opaque that in Julia I can have “a property of a function call the same function with a certain input.” And even more: you can call the property of the function as a function that will, in turn, call the original function (see Cobweb.jl main functionality).

But I don’t think stuff like that _belongs_ in the documentation. Because it’s not actually a _feature_ of the language, but an application of other, more generic features.

Julia (like all languages) has a limited and enumerable number of features. But those features can be (like in other languages) used and combined in an _unlimited_ number of ways (like the Lego bricks mentioned by @mbaz). It is impossible and not really desirable to list all conceivable uses of those features (in a way, that is what Github is for, showing as many different usecases as possible.)

It is a sign of that you have a powerful set of features when people are able to use and combine them in ways that were not considered or predicted at all by those who designed those features.

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 16, 2023, 7:56pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/14 "2023-06-16T19:56:36Z")

</div>

I really like the Lego pieces analogy.

Others commented that I should not expect the documentation to present the full possible combinations of things that can be achieved by using the language features - and I could not agree more since such an unthinkable request would imply something similar to the [Library of Babel](https://libraryofbabel.info/) (but in valid Julia code).

To clarify - I do not expect the documentation to contain actual programs. To keep the discourse in the Lego analogy space, it seems to me that some of us know more about singular Lego blocks than others (while having access to the same documentation).

Take, for example, the [`propertynames`](https://docs.julialang.org/en/v1/base/base/#Base.propertynames) function: because the wording in the documentation differentiates between the type and the instance of that type, it somewhat transmitted to me that the functions are excluded. To be fair, the documentation mentions “the properties of an object” (and functions are also objects) - but the latter addition about instances somehow directs the meaning towards structs. At least this is how I read it.

I cannot underline enough that my initial post and everything that followed is not meant to critique - I am just amazed at the work (and productivity) of some Julia developers/builders, and sometimes I feel like we have two parallel worlds: the gods and the mere mortals (and for some reason, I see Tim Holy as “the” god).

Also, I added my post after doing some work in the area of “source code reading” and arrived at some conclusions (or impressions, at least). I hope there is no room to interpret this in any other way than a constructive approach: take this as a call for help from somebody who wants to get more intimate with the language and wants to pick the brain of more experienced people.

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [June 16, 2023, 8:33pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/15 "2023-06-16T20:33:12Z")

</div>

[https://documentation.divio.com/](https://documentation.divio.com/) has been shared numerous times in this community, I think you may find it interesting. I think what you’re getting at is that the core documentation is lacking in one or more of those quadrants on some pretty fundamental functionality. Were there to be a unified “Explanation” or “How-to guide” covering the `*property` and `*field` methods could’ve helped address your example. It might not be sufficient to get to that aha moment right away (defining `getproperty` on a function type is pretty obscure as Julia code goes), but it would make that moment come faster.

---

<div class="post-metadata">

**Author:** ![joaquinpelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquinpelle/32/49163_2.png) [@joaquinpelle](https://discourse.julialang.org/u/joaquinpelle)\
**Post date:** [June 16, 2023, 9:53pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/16 "2023-06-16T21:53:02Z")

</div>

> [@algunion](#):
>
> Is this only my subjective experience? Or is there a real gap between the documentation and frequently used idioms in various packages?

I had a similar thought recently. This same thing happened to me while skimming through the source code of DataInterpolations, where I encountered this

```julia
(interp::AbstractInterpolation)(t::Number) = _interpolate(interp, t)
(interp::AbstractInterpolation)(t::Number, i::Integer) = _interpolate(interp, t, i)
(interp::AbstractInterpolation)(t::AbstractVector) = interp(similar(t, eltype(interp)), t)

```

So I learned by chance that it’s possible to define `()` call methods for custom types and thus assign function-like behavior to any object. It’s a neat feature that I was surprised I hadn’t come across before in the manual or other resources.

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [June 16, 2023, 10:07pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/17 "2023-06-16T22:07:27Z")

</div>

In that case, function-like objects are described in [Methods · The Julia Language](https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects)

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [June 16, 2023, 10:29pm UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/18 "2023-06-16T22:29:15Z")

</div>

> [@DNF](#):
>
> But I don’t think stuff like that _belongs_ in the documentation. Because it’s not actually a _feature_ of the language, but an application of other, more generic features.

I think the documentation can be more transparent about a generic function being an instance of a singleton `Function` subtype, just with special syntax that makes the function name `const` in the global scope and printed in the REPL. Look what happens when I don’t use function syntax:

```julia
julia> struct Foo end; Foo()
Foo()

julia> struct Bar<:Function end; Bar()
(::Bar) (generic function with 0 methods)

```

This is somewhat alluded to in the sections on functors, but since functors aren’t used frequently across the documentation, much less than regular functions, people take some time to grasp this fundamental that functions are a value with a type that can be dispatched on, and that calls `f(x)` dispatch on the type of `f` (with some common sense restrictions) in addition to the arguments. The docs do say that functions are first-class objects that can be inputs or outputs, but because there’s special syntax for them, many people don’t really get exactly how functions are like any other instance.

Here’s something cool the functor docs don’t explain. When your type is singleton, you can define the methods with a `const` name of the singleton instance instead. Works for generic functions too.

```julia
julia> struct Foo end; const foo = Foo() # singleton, const needed for this
Foo()

julia> (::Foo)() = 0

julia> foo(x) = 1
Foo()

julia> methods(foo)
# 2 methods for callable object:
[1] (::Foo)() in Main at REPL[2]:1
[2] (::Foo)(x) in Main at REPL[4]:1

julia> function f end; const g = f
f (generic function with 0 methods)

julia> g() = 0
f (generic function with 1 method)

julia> methods(g)
# 1 method for generic function "f":
[1] f() in Main at REPL[8]:1

```

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [June 17, 2023, 2:00am UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/19 "2023-06-17T02:00:40Z")

</div>

Another “unknown unknown” was that the property of an object could even be a string.

An expression like `o."world"("!")()` is actually standard Julia code (no macros involved here). The same for `o."world"(".")."How"."are"."you"("doing")()`. Let’s ignore the readability of the examples I provided (e.g. these are to exemplify “what is possible” and nothing more).

```julia
struct CrazyObject
	x::String
end

(c::CrazyObject)() = getfield(c, :x)
(c::CrazyObject)(x::String) = CrazyObject(c.x * " " * x)
Base.getproperty(c::CrazyObject, x::String) = c(x)

o = CrazyObject("Hello")
o."world"("!")() # output: "Hello world !"
o."world"(".")."How"."are"."you"("doing")() # output: "Hello world . How are you doing"

```

However, trying to use an integer as a property will cause a “cannot document the following expression” (I can define the method, but I got the error when using the property - not sure what that is about yet).

The next snippet is unrelated to the one above:

```julia
append(x::String, y::String) = x * " " * y
Base.getproperty(::typeof(append), x::String) = y -> append(x, y)

append."Hello"("world!") # output: "Hello world!"

```

Ignore for a moment that this is totally useless, and everybody would try to murder the author if such code were deployed in a serious production environment. The point is that this is standard Julia code (and yes, I can think about more complex situations where this kind of dot-driven chaining can make more sense).

I am like a small kid getting new toys here.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [June 17, 2023, 2:38am UTC](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445/20 "2023-06-17T02:38:27Z")

</div>

> [@algunion](#):
>
> The point is that this is standard Julia code

Is it? `getproperty(::T, s::String)` is not documented anywhere so it just seems to be a lapse in limiting dot syntax to symbols, and there’s no promise future versions would still allow this. If they wanted to allow properties to be more things then they wouldn’t have made `f.(x+y, z)` a broadcasting call syntax.

[Next page](https://discourse.julialang.org/t/a-kind-of-two-language-problem-in-julia-ecosystem/100445.md?page=2)
