Why is REPL unable to locate only one of my files?

I’m just a newbie to Julia and am trying out simple stuff inside the Atom IDE. I created two small functions Eucl.jl and TriaMap.jl and tried executing these in the REPL window. The first one, Eucl.jl gets executed but REPL is unable to execute TriaMap.jl, like it does not know what TriaMap is.

I set (under the Juno Tab in Atom), both Working Directory as well as Working Environment to the current Project Folder. Still the above issue.

Is REPL unable to locate only TriaMap.jl ? If so, why and what’s to be done?

Thanks in advance.

I can’t see any include("Eucl.jl") or include("TriaMap.jl"). Unless there is some automatism in Juno/Atom, which I don’t use, you need to include the files.
See Modules · The Julia Language (ignore the modules stuff for now, but you want it later).

And welcome to this community, don’t hesitate to ask if you experience more difficulties.

1 Like

There is no automatism - this is not MATLAB where having an .m file on your path imports whatever code is in that file.

OP I assume you maybe executed the function definition of Eucl at some point but didn’t do the same for TriaMap?

As a bit of general advice, uppercase in Julia is generally reserved for types (like Int64, String etc. or in your case Coeffs) while function names are lowercase.

Also type definitions generally shouldn’t be inside functions - Coeffs should be created outside of a function, and then you define functions that operate on Coeffs objects.

1 Like

BTW, how is Atom/Juno working these days? Since Atom was deprecated, and Juno development stopped, I presumed that people would stop using it, but there still seems to be a certain user base. Is it still working okay?

1 Like

Thanks for the info. I found the include helped to atleast let REPL know about the function. But there were other errors I’m now working on.

2 Likes

Thanks for the info. You noted it right- MATLAB’s ways don’t work here.

As I don’t know of any other IDE, I’m using Atom. Seems okay so far for the rather small scripts I write. Do let me know if you have any other IDE in mind. Thanks.

I was thinking of Julia for VS Code

I mean, on the Juno homepage itself, this is the top banner on the page :person_shrugging:

Still, some people do prefer Atom/Juno, so I was wondering why,

Thanks, @DNF for the info on VS for Julia. Have installed it and begun using it (of course, as a newbie with Julia).

Could I get to know what’s happening in the REPL window here, that is, why Julia is not able to assign a value to the field a0, while on the other hand, it knows its type and name:

Thanks in advance.

Coeffs is just the name of a type, not an object of that type. fieldnames operates on the type of a variable, not it’s value:

julia> mutable struct MyStruct
           a::Int64
       end

julia> x = MyStruct(1)
MyStruct(1)

julia> fieldnames(x)
ERROR: MethodError: no method matching fieldnames(::MyStruct)
Closest candidates are:
  fieldnames(::Core.TypeofBottom) at reflection.jl:188
  fieldnames(::Type{<:Tuple}) at reflection.jl:190
  fieldnames(::DataType) at reflection.jl:185
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> fieldnames(typeof(x))
(:a,)

As a general comment it’s probably not helpful to continue this thread which was about Atom not being able to find a function definition, a problem that as far as I can see is solved. I would recommend you start going through the Julia manual to learn the basics of the language (such as the difference between a type and an instance of a type) and start new threads when you run into issues.


Oh, got it. I’d forgotten to create an instance of Coeffs, particularly one that’s ‘mutable’. Coming from other languages, there is bound to be some confusion like I had. Indeed, I find it odd that only when mutable can field values change, when the structure’s fields make up a tree of variables.

Thanks for that quick info.

https://docs.julialang.org/en/v1/search/?q=noteworthy

1 Like