Oh, once again we're at the language/library boundary. Making a language platform-independent is easy. The only problem is that you need more than compiler - but if you, for example, write the compiler as a GCC front-end, you get that for free.
The libraries, however, need to interface with the OS to do anything meaningful, so yes, there platform-independence would be a lot of work.
On the other hand, it's not necessarily you who must do the work. If you simply design the libraries so that they don't clearly favour one OS, you can then implement them for the OS you're using and leave the porting to other people.
Take a look at C#, for example. Porting C# itself was simple and done in the Mono project within a few weeks, I think. Writing the CLR wasn't too hard either. The real issue is porting the .Net framework, especially the System.Windows.Forms namespace, which is extremely clearly modeled after the Win32 model, thus making implementation on top of X Windows all but impossible - the Mono project uses the WINE WinAPI implementation for this namespace.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Ok, so just incase I didn't hint at it enough, I am going to state it clearly: I have to back out of this project. I realized I can't afford to even be posting here often (after school starts) and really can't afford to be making a compiler and a new language. But I will definitely stay ontop of this thread and whats going on.
I'm going to upload the full text of the first post as a .txt and let JR copy paste that into the first reply so he can edit it as things progress.
Last edited by eyeRmonkey; Sep 5th, 2005 at 03:00 PM.
Ok, so just incase I didn't hint at it enough, I am going to state it clearly: I have to back out of this project. I realized I can't afford to even be posting here often (after school starts) and really can't afford to be making a compiler and a new language. But I will definitely stay ontop of this thread and whats going on.
I'm going to upload the full text of the first post as a .txt and let JR copy paste that into the first reply so he can edit it as things progress.
Don't worry. Leave the compiler stuff to me. I'm gonna pick me up a book on it sometime soon.
Totally silly example, but it shows (if I'm correct) that you'd need to write an operator for each expression. This would just be a compiler substitution.
Oh yeah, I meant to mention, it would be nice if we did our For loops like penagate just posted.
[code]for ([assignment of counter variable], [rule], [increment]) {
Code:
}
And I like doing returns like that also instead of
Code:
Private Sub Factorial() {
Factorial = blah
}
I like
Code:
Private Sub Factorial() {
return = blah
}
I think it increases readability a lot.
We also definitley need single increment and single decrement operaters. I miss those a lot in VB.
Code:
a = a + 1 // is the same as
a++
// same applies to --
My code I posted doesn't work (it goes into an infinite loop). But, the flip side is, I just coded my first working piece of assembly... w00t
Code:
int factorial(int n)
{
__asm {
mov eax, n ; number n
mov ecx, eax ; initial multiplier
LoopStart: ; loop through numbers
sub ecx, 1 ; reduce by one (n*(n-1))
imul eax, ecx ; multiply number (n*(n-i))
cmp ecx, 2 ; loop down to 2
jne LoopStart
}
}
I'll help out as much as I can in this thread. Don't know that I'll actually have the time to knuckle down and write a lot of code at once, at least not until mid November or so when my exams are over. Plus I have a few other things I am doing.
Tell you what, I'll write you ASM-optimised functions for your library
I'll help out as much as I can in this thread. Don't know that I'll actually have the time to knuckle down and write a lot of code at once, at least not until mid November or so when my exams are over. Plus I have a few other things I am doing.
Tell you what, I'll write you ASM-optimised functions for your library
Great to have you!
You'll probably be more active than me after tomorrow (when I start school).
I gave up on the For loop, it always returned the input number for some reason. I used a While loop instead
Code:
int __stdcall factorial(int n)
{
int i = (n - 1);
while (i > 1) {
n *= i;
--i;
}
return n;
}
A few things from that to add to the Lightfusion collection. While() block, *= operator (I like all these shorthand operators) and -- which eyeRmonkey alrady mentioned above.
Edit: Oh and maybe the ability to pick calling convention
Last edited by penagate; Sep 6th, 2005 at 11:50 AM.
I do not think that factorial is an operation common enough to warrant an operator. Preserving ! for its C use of logical NOT seems to make more sense.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.