Extensions of classes depends on namespace
Looks like extensions of classes depends on namespace.
If my class and my extension of class are declared under the same namespace - all fine, but if namespaces are different - I get error Error : Value of type 'other.A' has no member named 'Test'
I attached zip with test1 and test2. test2 produces error.
Don't know exactly, but such behaviour is unexpected for me (bug).
Haven't tried it yet, but from memory this is something that needs to be fixed. You should be able to go:
Class other.A Extension End
But parser can't handle it yet.
On Fri, Aug 3, 2018 at 3:57 AM Evgeniy Goroshkin [email protected] wrote:
Looks like extensions of classes depends on namespace. If my class and my extension of class are declared under the same namespace - all fine, but if namespaces are different - I get error Error : Value of type 'other.A' has no member named 'Test'
I attached zip with test1 and test2. test2 produces error.
Don't know exactly, but such behaviour is unexpected for me (bug).
ext-test.zip https://github.com/blitz-research/monkey2/files/2254190/ext-test.zip
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blitz-research/monkey2/issues/416, or mute the thread https://github.com/notifications/unsubscribe-auth/ADU3QkgLEJ9G7sU9Y8SrICg3fEUxBlbiks5uMyFXgaJpZM4VskMU .
Ok, possibly something different, I'm getting c++ build error with test1 and the above error with test2.
Is this really as simple as you can make the example? I't's pretty convoluted, is all the generic/function pointer stuff really necessary?
On Fri, Aug 3, 2018 at 9:12 AM Mark Sibly [email protected] wrote:
Haven't tried it yet, but from memory this is something that needs to be fixed. You should be able to go:
Class other.A Extension End
But parser can't handle it yet.
On Fri, Aug 3, 2018 at 3:57 AM Evgeniy Goroshkin [email protected] wrote:
Looks like extensions of classes depends on namespace. If my class and my extension of class are declared under the same namespace - all fine, but if namespaces are different - I get error Error : Value of type 'other.A' has no member named 'Test'
I attached zip with test1 and test2. test2 produces error.
Don't know exactly, but such behaviour is unexpected for me (bug).
ext-test.zip https://github.com/blitz-research/monkey2/files/2254190/ext-test.zip
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blitz-research/monkey2/issues/416, or mute the thread https://github.com/notifications/unsubscribe-auth/ADU3QkgLEJ9G7sU9Y8SrICg3fEUxBlbiks5uMyFXgaJpZM4VskMU .
Ok, have simplified it down, sorry, was just on my way out the door and kind of in a hurry and not in the mood for spurious de-obsfucation!
Will look into it later today. The 'using other' should work to get around the lack of 'class other.A extension' support so this should work.
Note: test1 is giving a weird c++ error here - you too?
On Fri, Aug 3, 2018 at 9:27 AM Mark Sibly [email protected] wrote:
Ok, possibly something different, I'm getting c++ build error with test1 and the above error with test2.
Is this really as simple as you can make the example? I't's pretty convoluted, is all the generic/function pointer stuff really necessary?
On Fri, Aug 3, 2018 at 9:12 AM Mark Sibly [email protected] wrote:
Haven't tried it yet, but from memory this is something that needs to be fixed. You should be able to go:
Class other.A Extension End
But parser can't handle it yet.
On Fri, Aug 3, 2018 at 3:57 AM Evgeniy Goroshkin < [email protected]> wrote:
Looks like extensions of classes depends on namespace. If my class and my extension of class are declared under the same namespace - all fine, but if namespaces are different - I get error Error : Value of type 'other.A' has no member named 'Test'
I attached zip with test1 and test2. test2 produces error.
Don't know exactly, but such behaviour is unexpected for me (bug).
ext-test.zip https://github.com/blitz-research/monkey2/files/2254190/ext-test.zip
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blitz-research/monkey2/issues/416, or mute the thread https://github.com/notifications/unsubscribe-auth/ADU3QkgLEJ9G7sU9Y8SrICg3fEUxBlbiks5uMyFXgaJpZM4VskMU .
Note: test1 is giving a weird c++ error here - you too?
Oh, yes. I just semant it w/o errors and think it works. I suppose these are kinds of similar bugs in test1 and test2. Extension method is global function, right? And therefore it should be allowed to pass it as an other func parameter.
Mx2cc version 1.1.15
***** Making app 'C:/proj/monkey/trash/ext-test/test1.monkey2' (windows release x86 msvc) *****
Parsing...
Semanting...
Translating...
Compiling...
Build error: System command failed:
cl -c -EHs -W0 -MT -utf-8 -bigobj -O2 -DNDEBUG -I"E:/monkey2/modules/" -I"E:/monkey2/modules/monkey/native" -I"C:/proj/monkey/trash/ext-test/" -I"E:/monkey2/modules/zlib/zlib-1.2.11/" -DNDEBUG=1 -I"C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/build/" -showIncludes -Fo"C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/build/test1534f6eb4.cpp.obj" "C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/src/test1_test1.cpp" >tmp/stdout1.txt
test1_test1.cpp
??????????: ????????? ?????: C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/include/test1_test1.h
??????????: ????????? ?????: E:/monkey2/modules/monkey/native\bbmonkey.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbstd.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\new
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\exception
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\type_traits
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\xstddef
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cstddef
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\stddef.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\sal.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\concurrencysal.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vadefs.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\xtr1common
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\yvals.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\xkeycheck.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\crtdefs.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\use_ansi.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cstdlib
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\stdlib.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_malloc.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_search.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_wstdlib.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\limits.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\math.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_math.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\initializer_list
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\malloc.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime_exception.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\eh.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_terminate.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime_new.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cstdio
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_wstdio.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_stdio_config.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cstring
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\string.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_memory.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_memcpy_s.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\errno.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime_string.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\vcruntime.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_wstring.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cctype
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\ctype.h
??????????: ????????? ?????: E:/monkey2/\devtools\Windows Kits\10\Include\10.0.15063.0\ucrt\corecrt_wctype.h
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\cmath
??????????: ????????? ?????: D:\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include\xtgmath.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbtypes.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbassert.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbstring.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbdebug.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbarray.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbgc.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbfunction.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbobject.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbweakref.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbvariant.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbtypeinfo.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbtypeinfo_t.h
??????????: ????????? ?????: e:\monkey2\modules\monkey\native\bbdeclinfo.h
??????????: ????????? ?????: E:/monkey2/modules/monkey/monkey.buildv1.1.15/windows_release_msvc/include/monkey_types.h
C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/src/test1_test1.cpp(32): error C2065: x_myapp_A_test1_test1: ????????????? ?????????????
C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/src/test1_test1.cpp(32): error C2059: ?????????????? ??????: )
C:/proj/monkey/trash/ext-test/test1.buildv1.1.15/windows_release_msvc/src/test1_test1.cpp(32): error C2653: x_myapp_A_test1_test1: ?? ???????? ?????? ?????? ??? ???????????? ????
?????????????? ?????????? Microsoft (R) C/C++ ?????? 19.13.26128 ??? x86
(C) ?????????? ?????????? (Microsoft Corporation). ??? ????? ????????.
***** Fatal mx2cc error *****
Internal mx2cc build error
I (want to) use code similar to test2 in real project, don't just playing with lang. I want to simplify my localization system - grab Localize methods from classes and store them in the list to recall when lang will be changed, on the fly. And I want to add Localize method into existing classes via extensions.
Ok, will be kind of busy for the next few weeks at least though...
On Fri, Aug 3, 2018 at 1:09 PM Evgeniy Goroshkin [email protected] wrote:
I (want to) use code similar to test2 in real project, don't just playing with lang. I want to simplify my localization system - grab Localize methods from classes and store them in the list to recall when lang will be changed, on the fly. And I want to add Localize method into existing classes via extensions.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/blitz-research/monkey2/issues/416#issuecomment-410113369, or mute the thread https://github.com/notifications/unsubscribe-auth/ADU3QsVFij2RlnAcW55FpCJn8HZzYA8Kks5uM6LHgaJpZM4VskMU .
If you can't fix that (because it seems to happen when c++ resolve and generate concrete classes by its template types, and mx2cc need to somehow replace T.method with extensionmethod - I don't know is it possible) then there is the other question - is it possible to iterate extension methods via reflection? (seems easier task than one above).
Ok, support for the use of extension methods as function values has been added and pushed - lack of this is what was causing the c++ errors. You'll need to rebuild mx2cc.
The other problem was due to lack of correct Using statement in the main myapp namespace code. Using is currently the only way you can use a class extension, so to fix the test2 problem, you need to change 'Using other' to 'Using other..' or add 'Using other.second' as the extension is declared in other.second namespace. Perhaps #import should auto-use all class extensions in the module? I'm OK with it 'as is' though.
It is possible to enumerate extensions via reflection but it's not pretty - see reflection module which does this (I think) to implement a 'GetProperty' style function. There are possibly many lurking bugs in the reflection of extenions stuff though, it's all pretty 'fresh', complex, and largely untested.
'Anonymous' extensions was probably a mistake in retrospect, it has complicated many things enormously internally...
On Sat, Aug 4, 2018 at 3:46 AM Evgeniy Goroshkin [email protected] wrote:
If you can't fix that (because it seems to happen when c++ resolve and generate concrete classes by its template types, and mx2cc need to somehow replace T.method with extensionmethod - I don't know is it possible) then there is the other question - is it possible to iterate extension methods via reflection? (seems easier task than one above).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/blitz-research/monkey2/issues/416#issuecomment-410294527, or mute the thread https://github.com/notifications/unsubscribe-auth/ADU3QiRtTkTOuEFZFSTYMUY9fUGqZvSCks5uNHA6gaJpZM4VskMU .
Wow! Will try it out.
'Anonymous' extensions was probably a mistake in retrospect
What is anonymous extension? That have no proper namespace?
Perhaps #import should auto-use all class extensions in the module? I'm OK with it 'as is' though.
I guess extensions must have namespaces to be part of app.
I tried - it works! It's super-cool, thanks! :)
This issue can be closed.