language-features

In which languages is it a security hole to use user-supplied regular expression?

a 夏天 提交于 2019-12-18 04:39:15
问题 Edit: tchrist has informed me that my original accusations about Perl's insecurity are unfounded. However, the question still stands. I know that in Perl, you can embed arbitrary code in a regular expression, so obviously accepting a user-supplied regex and matching it allows arbitrary code execution and is a clear security hole. But is this true for all languages that use regular expressions? Is it true for all languages that use "Perl-compatible" regular expressions? In which languages are

How do you force constructor signatures and static methods?

帅比萌擦擦* 提交于 2019-12-18 04:29:19
问题 Is there a way of forcing a (child) class to have constructors with particular signatures or particular static methods in C# or Java? You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when you want to enforce some design guideline, for example: Exceptions They should all have the four canonical constructors, but there is no way to enforce it. You have to rely on a tool like FxCop (C# case) to catch these.

Java Private Field Visibility

此生再无相见时 提交于 2019-12-17 22:51:39
问题 So I was making a class the other day and used Eclipse's method to create the equals method when I realized that it generated the following working code: class Test { private int privateInt; [...] public boolean equals(Object obj) { [...] Test t = (Test) obj; if ( t.privateInt == privateInt ) { [...] } } t.privateInt..???? It's suppose to be private! So I guess there is one more field visibility other than private, protected, package protected and public. So what is happening here? How is

What is the use of the := syntax?

大憨熊 提交于 2019-12-17 20:47:19
问题 I'm a C# developer working on a VB.NET project, and VS keeps trying to get me to use the := thingie when I call a function with a ByRef parameter like so: While reader.Read() HydrateBookFromReader(reader:=???) the HydrateBookFromReader function has the following signature: Public Function HydrateBookFromReader(ByRef reader As SqlDataReader) As Book Why does intellisense keep insisting that I use that := construction, and what is it for? 回答1: In VB, the := is used in specifying named

java partial classes

懵懂的女人 提交于 2019-12-17 20:19:50
问题 Small preamble. I was good java developer on 1.4 jdk. After it I have switched to another platforms, but here I come with problem so question is strongly about jdk 1.6 (or higher :) ). I have 3 coupled class, the nature of coupling concerned with native methods. Bellow is example of this 3 class public interface A { public void method(); } final class AOperations { static native method(. . .); } public class AImpl implements A { @Override public void method(){ AOperations.method( . . . ); } }

Scoped using-directive within a struct/class declaration? [duplicate]

喜夏-厌秋 提交于 2019-12-17 10:39:07
问题 This question already has answers here : Why “using namespace X;” is not allowed inside class/struct level? (3 answers) Closed 2 years ago . I find that my C++ header files are quite hard to read (and really tedious to type) with all the fully-qualified types (which goes as deep as 4 nested namespaces). This is the question (all the answers give messy alternatives to implementing it, but that's not the question): Is there a strong reason against introducing scoped using-directive in structs

Is SQL or even TSQL Turing Complete?

杀马特。学长 韩版系。学妹 提交于 2019-12-17 04:10:59
问题 This came up at the office today. I have no plans of doing such a thing, but theoretically could you write a compiler in SQL? At first glance it appears to me to be turing complete, though extremely cumbersome for many classes of problems. If it is not turing complete, what would it require to become so? Note: I have no desire to do anything like write a compiler in SQL, I know it would be a silly thing to do, so if we can avoid that discussion I would appreciate it. 回答1: It turns out that

Why are private fields private to the type, not the instance?

余生长醉 提交于 2019-12-17 03:23:06
问题 In C# (and many other languages) it's perfectly legitimate to access private fields of other instances of the same type. For example: public class Foo { private bool aBool; public void DoBar(Foo anotherFoo) { if (anotherFoo.aBool) ... } } As the C# specification (sections 3.5.1, 3.5.2) states access to private fields is on a type, not an instance. I've been discussing this with a colleague and we're trying to come up with a reason why it works like this (rather than restricting access to the

Does any dialect of Pascal allow a variable number of arguments?

会有一股神秘感。 提交于 2019-12-13 16:31:19
问题 This is a question for the older programmers. Years ago, I encountered a dialect of Pascal which allowed a variable number of arguments, through some kind of extension. Does anyone know of a current dialect of Pascal which allows a variable number of arguments? Given that Pascal is not as popular as it used to be, I wouldn't be surprised if the answer is no. BTW, it is more correct, isn't it, to say variable number of arguments , rather than parameters ? 回答1: No. The answer is based on the

Why was constness removed from Java and C#?

為{幸葍}努か 提交于 2019-12-13 11:58:55
问题 I know this has been discussed many times, but I am not sure I really understand why Java and C# designers chose to omit this feature from these languages. I am not interested in how I can make workarounds (using interfaces, cloning, or any other alternative), but rather in the rationale behind the decision. From a language design perspective, why has this feature been declined? P.S: I'm using words such as "omitted", which some people may find inadequate, as C# was designed in an additive