-
Notifications
You must be signed in to change notification settings - Fork 7
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
How to find out keyword arguments to (make <Type> ...)? #118
Comments
You're mixing up constructors. For the record, it's been a while since I last used the |
I think this question was answered, but, just in case someone else runs across it in future and wants more info... The docs https://docs.gtk.org/gio/class.MenuItem.html show that MenuItem has no properties. If MenuItem had properties, they'd be in a properties section in the docs. That is why using the The doc that you referenced at https://docs.gtk.org/gio/ctor.MenuItem.new.html is for a constructor function. guile-gi's translation will create the function Note that the C docs say that the For an example of an object that has properties, check out https://docs.gtk.org/gtk4/class.Button.html . Button has properties like |
Also, for the sake of comedy I guess, here's a script that'd do what you were asking specifically. This script prints out all of the properties for
|
Hi! Sorry I am slow to reply and only saw the replies yesterday. I have some questions now:
So this means, that if there is (I have not really any idea about how Gio works internally and what those flags are, except for the general idea of a flag being some kind of boolean being set somewhere. No deeper Gio knowledge here.)
The page https://docs.gtk.org/gio/property.Application.application-id.html does have a "Declaration" section, while the one you linked https://docs.gtk.org/gio/class.MenuItem.html does not have such a section. So generally flags would appear in a "Declaration" section, if there are any. If there is no "Declaration" section, it implies already, that there are no flags. Correct?
I fell victim of finding the wrong documentation page =( I am not really sure what the difference between a "constructor" (the usual term) and a "constructor function" is in this context. Is there any? Should I be using the words "constructor function", as it is a function creating some struct, instead of an object, because it is C code underneath? Regarding:
OK thanks!
There seems to be a difference between flags and properties. Flags simply being some boolean indicator of something existing and properties, which can be specified using keyword argument in Is this correct?
I think the idea is then, that it would be easier to browse the correct docs and extract the knowledge from there, instead of running the code to inspect properties of a thing? Nevertheless thanks for that code. Hope to be able to try soon! Best regards, |
@ZelphirKaltstahl are you a C or C++ guy? Imagine you have a struct
Using
While a constructor function is a procedure that returns a new instance
This isn't valid, but, I hope you know what I mean. |
I have used C and C++ only once or twice for assignments at university, but not really after that. My knowledge of C is very limited. I know what a constructor is in some other languages (Java, Python, probably others). I think with the help of your example I understand: "constructor function" is simply a function acting as a replacement for a constructor. Since there are no classes and objects in C, "constructor function" refers to a function, that does the job, which usually a "constructor" would do, if there was one. The wording "constructor function" made me think, that maybe there is a concept I do not know about, that is distinct from normal constructors. Perhaps even specific to
Here the arguments
And
Which would be using a normal "constructor", but which does not exist in C. |
Calling a procedure a "constructor" in an OOP language is just a way of making yourself sound smarter while omitting important details to everyoe who wants to actually learn things. All constructors, regardless of language, are if not by definition then at least by implementation procedures. In GObject, there are two acceptable ways of constructing an object. The first is calling a procedure named In Guile-GI,
Yes, |
I would like to know a way to find out the names of keyword arguments of a call like:
Not for that one specifically, but a general method to find out about the arguments. For example I tried to create a
GMenuItem
instance:But none of those works. I always get the error about
ERROR: In procedure %make-gobject: In procedure %make-gobject: unknown object parameter
. Even though https://docs.gtk.org/gio/ctor.MenuItem.new.html would seem to indicate, that the keyword argument should be#:label
.What is a good general method for finding out what I need to and what I can specify as keyword arguments?
The text was updated successfully, but these errors were encountered: