|
I ran into that two days ago and made my parser backtrack to accommodate.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
You are welcome to outlaw postfix operators in your code generator. Just be prepared for the howls of protest from the potential users.
At the very least, I would add a check for postfix operators, with a clear message saying that they are not supported, and should be replaced by the prefix form.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Frankly, the CodeDOM gets plenty of howls of protest from its users!
Fortunately, slang isn't designed to be a full language replacement. It's just a helper for making abstract generated code.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Well - how about you build your compiler so the ++ and -- operators are clever enough to use inc and dec on the assembly side? That's generally faster than actual addition.
You're (sort of) treating them like += and -= . . . and that would work, take advantage of their unique signature for that extra speed boost in a operation that is often repeated.
You read OG's tome so I don't need to tell you why you need both and how they interact. Interesting that two different language's spec's can result in different answers (on occasion)
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I'm only building roughly 2/3 of what a compiler does. The code generation isn't part of it. Instead I'm rendering to an abstract-syntax-tree of code elements that are rendered to a target .NET language via a 3rd party.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: is ++<target> really so much worse that <target>++?
No. Based on my super intense all conclusive test, they are same. Here is the test. I hope you can understand this complex set up.
static void Main(string[] args)
{
List<double> preIncrement = new List<double>();
List<double> postIncrement = new List<double>();
for (int i = 0; i < 10000; i++)
{
preIncrement.Add(PreIncrement());
postIncrement.Add(PostIncrement());
}
double letsSeeIfYouAreABadOperator = preIncrement.SkipWhile(x => x == 0).Average();
double youBetterPerformWell = postIncrement.SkipWhile(x => x == 0).Average();
}
private static double PreIncrement()
{
DateTime start1 = DateTime.Now;
int i = 0;
int x = 1;
int y = 1;
for (i = 0; i < 100000; i++)
{
x = ++y;
}
DateTime end1 = DateTime.Now;
return (end1 - start1).TotalMilliseconds;
}
private static double PostIncrement()
{
DateTime start1 = DateTime.Now;
int i = 0;
int x = 1;
int y = 1;
for (i = 0; i < 100000; i++)
{
x = y++;
}
DateTime end1 = DateTime.Now;
return (end1 - start1).TotalMilliseconds;
}
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Yeeaaah that's not a benchmark.
Those times aren't accurate at all.
At worst you need to use Stopwatch.
At best you need to use interop
[DllImport("Kernel32.dll", EntryPoint = "GetSystemTimePreciseAsFileTime", CallingConvention = CallingConvention.Winapi)]
static extern void _GetSystemTimePreciseAsFileTime(out long filetime);
internal static DateTime PreciseUtcNow {
get {
long filetime;
_GetSystemTimePreciseAsFileTime(out filetime);
return DateTime.FromFileTimeUtc(filetime);
}
}
internal static long PreciseUtcNowTicks {
get {
long filetime;
_GetSystemTimePreciseAsFileTime(out filetime);
return filetime + 504911232000000000;
}
}
and then use that PreciseUtcNowTicks property
Finally, convert that to a timespan after getting the difference
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I said all conclusive. My tests are the bests.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
i know the feeling
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Just because I am the nicest kind around, I tried your version as well. Still same. Now is the good time to praise me.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
The other problem is your version isn't contesting the stack
try something like
if(i++>--i) {
}
vs
if(++i>--i) {
}
in your test, and then run it in release mode
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Nope.
0.0861007099999955 milliseconds
0.0865207899999961 milliseconds
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
that's interesting. I wonder what the IL looks like. you can email me your code (i'll PM you my address) or I'll write the benchmark myself when I get the time and disassemble it.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Guy proves with code what I've been telling you on the other strand of this thread and you shift to arguing about the best way to time code. Mmm, I see a pattern emerging.
|
|
|
|
|
One hundred pop artists use sticks (10)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Clever. I see what you did there.
|
|
|
|
|
Feel free to educate the others!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
DRUMSTICKS
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Nope!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
CandyStore
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Nice try! Nope.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Chopsticks
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Nope!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have no idea, but I feel bad that it hasn't been solved, so I am going to throw out my best guess (even though it's probably 2 words, not one).
Candycanes
C = One hundred
andy = (Warhol) pop artist
canes = sticks
Although knowing your trickery, I expect "sticks" is more about being sticky like toffee - but I got nowhere with that angle.
|
|
|
|
|
CANDYCANES is correct!
You are up tomorrow!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|