I cannot find implementation code of append() or any other builtin functions anywhere? I tried finding the code through godoc and using jump-to-definition feature of IDE's. May be i am looking at wrong places. Could anyone show me the way to see actual implementation?
You may be interested by :
the code generating bit append is in here https://github.com/golang/go/blob/go1.16.7/src/cmd/compile/internal/gc/ssa.go
and growslice, used by the former, and that lives in here : https://github.com/golang/go/blob/go1.16.7/src/runtime/slice.go
Related
In Rust, you can use the black_box function to force the compiler to
assume that the function's argument is used (forcing it not to optimize away code that generates that value)
not be able to inspect how its return value is produced (preventing it from doing constant-folding and other such optimizations).
Is there a similar facility in Go (to accomplish either task)?
Is there a similar facility in Go (to accomplish either task)?
No.
If you want to use a result: Assign to an exported global.
I believe runtime.KeepAlive is recommended, as per the following Github issue. Unfortunately, it's unclear whether anything exists for function arguments, or whether KeepAlive is even guaranteed to work.
https://github.com/golang/go/issues/27400
Can anyone point me to documentation for CodeAuthzpComputeImageHash() in advapi32.dll?
I can't seem to find documentation anywhere.
The reason you can't find documentation for this function is that this function is undocumented.
Not all winapi functions are documented, unfortunately.
There is a mention of the function at http://technet.microsoft.com/en-us/library/cc786941(v=WS.10).aspx, though:
ItemData (REG_BINARY). The actual hash to the file. This value should always be 16 bytes and is generated with a call to CodeAuthzpComputeImageHash().
Also, you can use a trampoline to hook the function, and if you know how to cause it to be executed, you can then try to see its arguments and return type.
Also, try searching at WINE if they have implemented it. Ask in their mailing list. Since they try to implement winapi, they need to implement the undocumented parts, too, there's a good chance they have some understanding about the function.
Out of curiosity, i tried a few tutorials on code.org.
I began with this one.
Have you seen this graphical syntax using blocks ?
Is it some kind of standard ?
Or is completely home made ?
Here is what it looks like :
http://files.websitetoolbox.com/149581/1788549
Where can i learn more about it ?
I think it is really easy to read, and i wonder if i could use somewhere else, programming c# or c++, java, even javascript.
I am still not sure if business code would really be easy to read using this syntax.
It's likely to be some form of OpenBlocks, it's a way of representing your code and what it does in a more intuitive fashion, you can read more about it at the link I posted as a comment.
Notably, a similar solution was in use for creating Android apps too .
This is called blockly. You can find a lot of information from blockly's FAQ. Hope that helps.
I would like to know if the following is possible in Scala (but I think the question can be applied also to Java):
Create a Scala file dynamically (ok, no problem here)
Compile it (I don't think this would be a real problem)
Load/Unload the new class dynamically
Aside from knowing if dynamic code loading/reloading is possible (it's possible in Java so I think it's feasible also in Scala) I would like also to know the implication of this in terms of performance degradation (I could have many many classes, with no name clash but really many of them!).
TIA!
P.S.: I know other questions about class loading in Scala exist, but I haven't been able to find an answer about performance!
Yes, everything you want to do is certainly possible. You might like to take a look at ScalaMock, which is an example of creating Scala source code dynamically. And at SBT which is an example of calling the compiler from code. And then there are many different systems that load classes dynamically - look at the documentation for loadLibrary as a starting point.
But, depending on what you want to achieve, you might like to look at Scala Macros instead. They provide the same kind of flexibility as you would get by generating source code and then compiling it, but without many of the downsides of that approach. The original version of ScalaMock used to work by generating source code, but I'm in the process of moving to using macros instead.
It's all possible in Scala, as is clearly demonstrated by the REPL. It's even going to be relatively easy with Scala 2.10.
As per my understanding scheme procedures like map,apply,append etc are written in scheme itself. Is there an easy way to see the implementation of these procedues right inside the REPL ?
I do not believe there is a standard way to dump the source code of a procedure, but a lot of the list functions are defined here, and you can look through the source code for your implementation to see the rest. Note that apply is probably a primitive, though.