Hi, I tested a simple Kotlin program but it does not print out anything. What would be the causes? Thanks.
Kotlin scripts (.kts) don't use a main function. You just put the code directly in the file at the top level. So your code declares an arbitrary function named main but doesn't call it.
Make sure it has .kt extension under src\main\kotlin.
For more information: https://github.com/halilozel1903/KotlinTutorials
Related
I am starting writing my first custom module in Julia.
What I am doing is writing all the files in a folder, then import them in a ModuleName.jl file and eventually writing a test program which executes a precompiled main() function which calls my custom module (I like keeping a modular style of programming).
The problem is that I think I am missing something on the use of using and import keywords. In my test file I have the following lines:
push!(LOAD_PATH,"./ModuleNameFolder")
using ModuleName
I thought that functions of ModuleName if loaded with using could be called without explicit ModuleName.myfunct(), but only through myfunct() while this is not the case. If I omit the ModuleName the compiler throws an UndefVarError.
What am I doing wrong? I would like to bring all the functions of my custom module on the main scope
Welcome to Julia.
What do you mean by precompiled main() function? Tests in Julia are normally set on a specific file that is run automatically at each push of your code on the repository that you use to host the code.
Any how, try include ./ModuleName followed by using .ModuleName (note the dot). And remember to export the objects in ModuleName that you want to make available directly.
Have a look on my tutorial: https://syl1.gitbook.io/julia-language-a-concise-tutorial/language-core/11-developing-julia-packages
I want to make my custom inline function in .kt file using checkRadix function already implemented by Kotlin.
But I cannot import it. How can I import and use it?
I tried
import kotlin.jvm.JvmMultifileClass.*
kotlin.jvm.JvmMultifileClass.checkRadix(radix)
But I can't compile and there is no recommended resolution by IDE.
That function is marked as internal, which means it's only available within that module — i.e. within the Kotlin stdlib, not to your code.
I don't know why it's marked like that; maybe JetBrains consider it an implementation detail. But they clearly don't want it being used by any other code.
(Of course, it wouldn't be hard to reimplement yourself.)
It says in the docs: "In addition, each of these also have a corresponding {file}.meta.js meta file which will be used for reflection and other functionality."
Q1: does this mean we only need to include these files if we are using reflection?
Q2: what is the "other functionality"?
Turns out the docs are wrong. This file is not used for reflection. It is used by the compiler and useful should you need to distribute your kotlin code as a library.
I'm trying to run some NSWindow functions from another thread on OSX. I am doing this via ctypes so need to find the library files.
dispatch_sync I found in libc.dylib but I can't find dispatch_get_main_queue, does anyone know the library that is in? Is it not in libc? I thought to use this based on here: Objective C Multi thread NSWindow alternative?
I also couldn't find the docs of the types used on opensource.apple can someone also help me find that for this Dispatch module.
dispatch_get_main_queue() is an inline function, so it doesn't end up in any library. It's compiled into every [Objective-]C/C++ file that uses it.
It compiles down to just (dispatch_queue_t)&_dispatch_main_q, more or less. That is, there's a global variable _dispatch_main_q and dispatch_get_main_queue() just returns its address, type cast to dispatch_queue_t.
On my 10.9.5 system, _dispatch_main_q is exported by /usr/lib/system/libdispatch.dylib.
I want to load special dll without execute dllmain function.
I think, set a breakpoint at dllmain can solve this problem.
But I don't know How can I do?
Also I want call dll's export function.
I have tried to use LoadLibraryEx with dont_resolve_dll_references, but it occurs error with dll's function call.
How can I solve this? Please give me your idea.
Thanks.
As explained in this question: Win32 API to enumerate dll export functions?
You can use LoadLibraryEx with the DONT_RESOLVE_DLL_REFERENCES flag, even though use of that flag is strongly discouraged.
If so you will likely have to free and reload the dll if you actually want to use it.
Well as explained here:
An optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. The system also calls the entry-point function for a DLL when it is loaded or unloaded using the LoadLibrary and FreeLibrary functions.
calling the DllMain is an OS feature mandatory (although implementing that function is optional) if you use the standard way in loading and executing a dynamic library. So there is no official way in doing this.