c*****t 发帖数: 1879 | 1 最近无聊,稍微研究了下两个语言,彻底被雷了。
第一是 R 。可以说是世界上最 fucked up 的语言之一(COBOL 是另外一个)。
你看一下这篇文章就明白了:
https://xianblog.wordpress.com/2010/09/13/simply-start-over-and-build-
something-better/
如果你非要写 R 代码。建议你把所有的 variable 都弄个 prefix 。免得你
不小心碰到这种麻烦事。
第二就是 Go 。整个一傻逼语言。
1) 如果该语言有 pointer,但是其速度比 Java 还慢点,谁 TMD 有病才用它。
再不用说,Go 里面需要知道很多很多 low level 的东西,但是搞了半天比 Java
还慢?!!
2) Stupid copies 。好吧,你有 pointer 不用,非得 pass by value (i.e.
struct copy),真是脑袋抽筋了。copy 大部分情况下比 reference 慢。
reference 是可以放在 register 里的,而 struct 一旦比 register... 阅读全帖 |
|
sc 发帖数: 122 | 2 Sorry for the naive question, but I couldn't figure out a better solution.
In C++, I have A1, A2 derived from A,
B1, B2 derived from B.
A is abstract, has pure virtual fooA(), which gets overloaded later. A1, A2
have their fooA1(), fooA2() respectively.
B "has-a" A. B::fooB() will be calling A::fooA(). At the same time, B1 and
B2 will need to call A1::fooA1() and A2::fooA2() as well.
Option 1:
If I make A as a data member of base B, and use polymorphism to instantiate
A with A1 or A2 (in B1 or B... 阅读全帖 |
|
s*****e 发帖数: 33 | 3 Want to have the following definitions:
class Foo
{
private:
class FooA
{
};
struct FooB
{
int x_;
FooA *p_;
}
}
Do you know how to make the above definition possible, basically, how to make
FooA is accessible from FooB? Thanks a lot. |
|
h*****n 发帖数: 209 | 4 突然间有点不确定了,以下两个C代码应该是完全等价的吧?
代码 1:
int fooA()
{
//blabla
}
int fooB()
{
int ret;
ret = fooA();
return ret;
}
代码 2:
int fooA()
{
//blabla
}
int fooB()
{
return fooA();
}
代码1是不是把temp的值放在寄存器(e.g., EAX)里面返回了?
代码2是不是也会在stack里面分配一个临时变量(跟代码1一样),然后把fooA()的值赋
给这个临时变量,这个临时变量的值再放在寄存器里面返回? |
|
d****p 发帖数: 685 | 5 To me, both are fine since the binding between A{i} and B{i} is at compile
time . It would be nicer if we place such binding to a higher level instead
of inside class body.
I would propose
template // T could be either A1 or A2
class DerivedB : public B
{
DerivedB(T* t) : B(t) // use the same type of T to initialize B
subobj
{
//...
}
Foo()
{
FooB();
T::FooA();
}
};
A2
instantiate |
|