zephir
zephir copied to clipboard
CBLOCK docs...
So I looked into Zephir for some code I am currently writing, and it poked me that Zephir is compiled to C. So I was like: Why can't I use C functions, then?
Answer: https://github.com/phalcon/zephir/blob/master/test/cblock.zep
Why is this not documented, like, at all? :/ When looking at zephir-lang website, I see no mention of this feature, which I think is VERY impressive.
Mostly because it's not recommended, Zephir is unable to analyse the code inside c-blocks making the whole compiler useless. You only must use it if you need to do something that only works in C.
So effectively, I can not use Zephir in order to build a C extension with a better OO layer? Oh… Because, I thought that this would be a really cool feature of Zephir - being able to create an OO wrapper of an existing API without all the zend hassle. The only other alternative is PHP-CPP, though…
Maybe Zephir will implement a similar feature in the future?
Am 28.11.2014 um 21:29 schrieb Phalcon [email protected]:
Mostly because it's not recommended, Zephir is unable to analyse the code inside c-blocks making the whole compiler useless. You only must use it if you need to do something that only works in C.
— Reply to this email directly or view it on GitHub https://github.com/phalcon/zephir/issues/654#issuecomment-64926546.
Feel free to use the tool you think it's more appropriate for your work
@IngwiePhoenix I am contributor of cblock
and extern-libraries
supports.
I am using Zephir to writing PHP Extensions that wrapper exists linux system calls and APIs.
Zephir supports Optimizers
could do the same thinks to generate target c codes, and easier debugging for Zephir, you must consider it first.
And cblock
only to be used at small codes, sometimes less than 10 lines for including c headers /
define c struct , or declare c variables.
Zephir Compiler (zep to c) can not analyse the code inside c-blocks, the warnings and errors are throws
from Compiler (GCC / LLVM) ,but sometimes with 3rd libraries, there are over 100 lines warnings throws from GCC , that's why i say not easier for debugging.
But, if you are C guys , this was piece of cake .
Here is the other one example of CURL php-extension written by Zephir (https://github.com/racklin/zephir-testcurl)
@phalcon
Could we consider add a document for cblock
and extern-libraries
supports and with warning messages there are extreme features.
I can't found where to send document PR.
For cblock
syntax: https://github.com/phalcon/zephir/pull/21
For extern-libraries
syntax: https://github.com/phalcon/zephir/pull/636
Thanks .
@phalcon @IngwiePhoenix cblock
idea is inspired by golang cgo
http://blog.golang.org/c-go-cgo
@racklin
That example of using libcurl within Zephir is very awesome! I am glad your PRs got merged.