[Cython] [FEATURE REQUEST] VisualBasic "Option Explicit" / Perl "use strict" -- bringing variable pre-declaration to cython optionally
Subject: [FEATURE REQUEST] VisualBasic "Option Explicit" / Perl "use strict" -- bringing variable pre-declaration to cython optionally === Background: already cython supports the following: #program1 a1 = cython.declare(cython.int) # cdef int a1 a2 = cython.declare(cython.double,0.57721) # cdef double a2 =0.57721 #end program1 The New Feature Request: but will there be - a feature in cython, in which - even though we are "not" declaring "data types" of variables, but we are declaring variables themselves. like: #program2 cython.option_strict(True) ## <--- see this statement a1 = cython.declare(cython.int) # cdef int a1 a2 = cython.declare(cython.double,0.57721) # cdef double a2 =0.57721 a3 = cython.declare(cython.var) #cdef var a3 ## <--- see this statement a4 = cython.declare(cython.var,0.57721) #cdef var a4=0.57721 ## <--- see this statement a3 = 10 # <- This statement will not give error b1 = 10 # <- This statement will give warning/error, as variable b1 was not declared and cython.option_strict() is enabled #end program2 - Here we have declared the variables a3 and a4 using "cdef var", but we have not declared their data types. For a1 and a2, we have declared their datatypes too. But now, as cython.option_strict() is enabled(i.e., true); HENCE "b1=10" statement will give error when cython compiles, because "b1" variable which was not declared in any sense using "cython.declare(cython.var) or cdef var" . But "a3 = 10" statement in above program will not warning/error,as "a3" is already declared var NOTE: This feature request is analogous to VisualBasic's "Option Explicit" and perl's "use strict" == Here are other people also requesting the similar thing: http://stackoverflow.com/questions/613364/is-there-a-need-for-a-use-strict-python-compiler http://stackoverflow.com/questions/13425715/does-python-have-a-use-strict-and-use-warnings-like-in-perl http://stevesprogramming.blogspot.in/2013/03/why-python-needs-perls-use-strict.html http://bytes.com/topic/python/answers/632587-python-feature-request-explicit-variable-declarations Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] [FEATURE REQUEST] VisualBasic
Thanks for reply @Sturla. 1) Sturla>>> Originally Fortran's "implicit none". Zaxebo>> Yes, you are right :-) --- 2) Sturla>>> I am not sure why you use Python (including Cython) if you prefer to turn off duck typing, though. You know where to find Java or C++ if that is what you want. Zaxebo>> I am NOT saying to implement datatyping(that is already part of cython by "cdef int","cdef double"). I am NOT saying to turn off duck typing. What i am requesting is: declaration of variables without data typing (like: cdef "var" ). And "optionally making them to be explicit". It is not required to make each variables data type to be put in the program, only declared as: cdef var a1 So there is no problem to the concept of duck typing in this case. Hence Again , THEIR PRE-DECLARATION (using "var") is to be made explicit, not their datatypes ("int,double" etc do not need to be specified). Hence, we are not making duck typing off. We are still using datatype. --- 3) If this idea seems acceptable and in congruence with cython philosophy, then I can humbly offer some token amount as sponsor in my individual capacity to the implementor, for this feature to be implemented in cython in a prioritised timeframe. Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] [FEATURE REQUEST] VisualBasic
ooops,following line in my earlier email: "We are still using datatype." should be read as: "We are still using duck datatyping." Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] [FEATURE REQUEST] VisualBasic
Sturla>>> Ok, so it is to guard against spelling errors? Yes, thats a real big problem, once . Others are sufferring from this too, as i mentioned in my original post Here are other people also requesting the similar thing: http://stackoverflow.com/questions/613364/is-there-a-need-for-a-use-strict- python-compiler http://stackoverflow.com/questions/13425715/does-python-have-a-use-strict- and-use-warnings-like-in-perl http://stevesprogramming.blogspot.in/2013/03/why-python-needs-perls-use- strict.html http://bytes.com/topic/python/answers/632587-python-feature-request-explicit- variable-declarations As cython already implements "cdef int a1","cdef double a2" type statements, so implementing "cdef var a1" and optionally making their explicit declaration on, should be a do-able thing. This "explcit declaration of variables - on" can be made by the programmer - either by "cython.option_strict(True)" or by some command line option to cython. == As i already mentioned, if this idea is fine with cython community then I am ready to donate some token money for implementation of this feature as soon as possible. Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] [FEATURE REQUEST] VisualBasic
Stefan>>> A directive, see Options.py. There are already two directives called "warn.undeclared" and "infer_types.verbose". Combining those should get close to what you are looking for. Zaxebo1>> thanks. it works as i wished. You are really really my saviour. === Now only thing left, is that I will NOT want to declare the type of each variable as cdef int a1 cdef double a2 I will also want an additional option of "var", so that I can take advantage of DUCK TYPING etc etc, as in: cdef var a3 If this small leftover feature-request of "cdef var" is implemented, then there is nothing like it:-) :-) thanks again Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] [FEATURE REQUEST] VisualBasic
o good, that solved this issue. Thanks a lot Zaxebo1 ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel