Thanks for your response. This seems to make sense - I will take a look in more depth tomorrow as it’s late here now.
Certainly just forwarding the arguments (which I think is what you have essentially shown here) would be the most simple solution. Almost trivial, I suppose.
Just coming back to this this morning. How does this work?
You have defined an outer constructor here, if I understand correctly?
And your outer constructor function is a function ConfigStruct(args...; kwargs...) which “maps” to the function DataFrame(args...; kwargs...), meaning that it just calls this function instead.
I may be asking a slightly different question here, but what happens with that (implicit) return value?
The call to DataFrame(args, kwargs) returns a DataFrame, and presumably that is used to set the value in the struct df. But the name df has not been used.
What would you have to do instead if the struct was this:
struct ConfigStruct
df::DataFrame
df2::DataFrame
some_other_stuff::String
end
I ask about this more general case, because I think without understanding this it’s difficult to understand the first case.
To go back to the function you defined, it may be useful to point out that
You guess correctly, but it’s better not to guess at all. Julia’s Manual covers function syntax. Many of your follow-up questions here would be resolved by studying the type system and its role in method signatures as well. Eyeballing parallels to other languages (“template parameters” are not a Julia concept) and scattered discourse questions are just no substitute for studying the language’s or a library’s broad fundamentals, and that amount of information goes into documentation, not comment threads.
If you didn’t understand what Eben60 wrote, then it’s premature to cast blame on them for not providing an explanation. I certainly saw one about properly using the type system to allow your type constructor to accept your attempted input and other reasonable alternatives. I understand the frustration of not understanding code, but there are more productive ways to learn than to blame your incomprehension entirely on people trying to help you.
Might be a typo here? I’d expect the resulting DataFrame to also be passed into another likely default ConfigStruct constructor, given it’s a type constructor method.
I have read through these things. As I said before, simply providing a link to the documentation, implying that I didn’t bother to read it, it unhelpful. I would not be asking these questions unless I had already read all of the relevant documentation pages.
I am asking because despite having read those pages I still do not understand exactly what is wrong with my attempt or why.
There’s a bigger problem than that. He wrote in English sentences, but it looks like they were written by ChatGPT - incomprehensible.
Nobody did anything of the sort. In fact, how many times you’ve read the documentation is irrelevant because…
Considering the questions you are asking, it is worth reviewing the material with the benefit of better experience. To this day, I learn new things by rereading the documentation, especially when it’s updated by version. Your reaction to people highlighting the relevant sections is clearly skewed by frustration, and venting that frustration on much smaller comments for failing to reword the documentation to your satisfaction won’t help you understand anything better. Reviewing the material might not only clear up some questions, it could help you clarify questions for more targeted topics; trying to fill too many knowledge gaps in one problem is a recipe for frustration.
Venting like so. I offer a gentle reminder that unproductive insults go against community standards, and it’s not uncommon for such comments to be flagged for moderators. I’ll leave that decision up to the people involved.
How many times should I read it? If I told you that I have read these particular pages at least 3 times in the last 4 weeks would you say that’s probably enough times to have read something before asking for further help?
I can assure you I am not frustrated. Nor am I venting. I don’t know why you have perceived that from what I have written.
I would suggest it is more likely the case that you have anticipated a frustrated response from the other posts in this thread, which speaks volumes.
Nothing I have said here is insulting. I simply pointed out that I can’t read what he’s written because it’s incomprehensible.
By the way I realized there was a minor error in one of my earlier code examples. (The one with the struct with multiple fields.) I’ve now edited it so that it does make sense, but since no one picked up on this I don’t think it makes any difference to the rest of the thread.
I’ve lost count how many times I read it, and I don’t believe the number is at all important for understanding. The difference comes from rereading with improved experience or a different perspective. If you lost faith in rereading the material, then demanding people communicate the same material to you here won’t make a difference.
Again, the unwarranted blame over your own incomprehension and the unflattering comparisons to generative AI toward people who put time and effort into helping you. You’re entitled to pretend those aren’t insults, but nobody else will. I won’t dispute your claim this is casual behavior for you, but it’s not justified or acceptable here. I hope you recognize this is constructive criticism; your obvious passion for learning Julia shouldn’t be wasted like this.
And yet you didn’t earlier. Perhaps it’s because the only typos are the missing using DataFrames and a terminating ), and the simplest fixes ran your code example without errors, so you were more interested in understanding how it worked then. Considering you admitted to minor errors of your own, let’s not stoop to nitpicking.
I did not do this. I asked a separate question which was entirely unrelated to the information in the documentation, FAQs, etc.
Again, where have I done this?
It’s not an insult. It does look suspiciously Chat-GPT like. These days you cannot tell who might just be plugging their forum accounts into a gen AI tool.
Lol… This just shows what a low opinion you appear to have of me. You must think I’m really stupid, or someone who has absolutely no idea what they are doing.
Look, I get it, you accused me of a bunch of things I didn’t do because you perceived the situation not as it is. You then made the situation worse and doubled-down on your mistake. You’re now trying to lawyer me as if this is a courtroom.
The reality is we just don’t agree.
You think this is a trivial problem
I don’t know how to solve it so I asked for help
Maybe I have some fundamental misunderstanding as to how Julia language works. Completely possible, but I’m not going to figure that out be repeatedly reading the same documentation pages over and over again.
You have to ask questions and get answers. Not just read the docs, stupid person.
This is the question that is entirely related to the information in the linked FAQ and documentation:
Right here.
People do listen to what you say and take you seriously. It’s why we’re responding to you this way.
It is counterproductive to imagine that people are looking down on you to excuse unwarranted insults, when they in actuality demonstrated a willingness to help. Considering that I am involved this time, I’ll flag this comment and overall thread for moderators to decide how it should be handled.
Ah, sorry about that. Brain fart. I didn’t actually test that code. It should be this instead:
using DataFrames
struct ConfigStruct
df::DataFrame
end
function ConfigStruct(args...; kwargs...)
ConfigStruct(DataFrame(args...; kwargs...))
end
So, in this case I define an outer constructor that passes the arguments to DataFrame to create a dataframe, and then wraps the dataframe in a ConfigStruct (using the default constructor). And this time I did test it:
julia> using DataFrames
julia> struct ConfigStruct
df::DataFrame
end
julia> function ConfigStruct(args...; kwargs...)
ConfigStruct(DataFrame(args...; kwargs...))
end
ConfigStruct
julia> ConfigStruct(a=[1, 2, 3], b=[4, 5, 6])
ConfigStruct(3×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 4
2 │ 2 5
3 │ 3 6)
Thanks for your reply. I appreciate you are trying to be helpful but I’ve asked for a moderator to step in and delete this thread as it’s degraded into noise.
If you really believe so, you are welcome to flag the comments you find offensive and let a moderator handle this. I for one welcome any suggestions on how I communicate.
Though I would suggest reconsidering your judgement if you perceive insults in reading suggestions but claim not to see it in this:
I believe there’s nothing else we have to say to each other.
As a moderator I’m locking this thread because it doesn’t bring anything positive to anyone involved.
@anon91151494, the way I see it, everyone who interacted with you in this thread was legitimately trying to help. The fact that their answers may not have been useful for you does not mean that they are bots. I regularly delete full ChatGPT answers from this forum and block their creators, and they look completely different.
As for your feeling of being insulted, people who answer on this forum often make assumptions about the nature of your misunderstanding. This is very useful especially for beginner questions, to quickly zero in on the source of the problem when we’ve seen such problems before. And in such cases, pointing out a specific section of the documentation is often the right answer.
In your case, it didn’t seem to have worked. Part of the issue might have been that @CameronBieganek’s link was accidentally broken: the section he actually meant to point you towards was https://docs.julialang.org/en/v1/manual/faq/#Why-doesn’t-it-work-to-declare-foo(bar::Vector{Real})-42-and-then-call-foo([1])?. It wasn’t a generic “read the docs, stupid” kind of answer, it was helpful and focused on a precise part of the FAQ.
In fact, I don’t remember seeing the word “stupid” on this forum to refer to a person before today. That should tell you the level of good will and politeness you can expect from other people here. I suggest you keep this in mind for future interactions (which I hope will be many since you’re obviously passionate about the language).