+Jonathan_Blow, C actually does let you use your own buffers for files using the setvbuf function. The line-based buffering for FILEs with a default buffer size of BUFSIZ is just a convenience.
The signed integer code has a bug. If you pass in a -2^63 you will get an error. It will see that it is a signed int, print out the minus sign, and then multiply -2^63 by -1. You will end up with 2^63 in a signed int which has a maximum value of 2^63-1, which is an overflow. I have had to implement an int to string function for a system where I didn't have the standard library, and that was a bug I had.
Recursion also is able prints unsigned decimal/hex numbers without buffer. Since it reverses the output and that's exactly what you want with numbers when using mod (% in c).
Type casting seems to be a little inconsistent. I know this is syntaxual (if that's a word) but because variables are declared like this: `name : type = ...` It makes much more sense to cast with the type afterwards. Current casting: `cast(type) var` Consistent casting: `var as type` `cast(var, type)` Then auto-casting can a little simpler to read: `var as auto_symbol` `cast(var)` `cast(var, auto_symbol)` `autocast(var)` Again this is not that important yet but consistency and readability is good.
printf is the wildcard standard IO function in stdio, can have infinite parametra, i could never work it out. :) is wierd trying to make a version of it.
You've implemented a curious type system. Basically Any is a boxed type where the language takes care of the boxing but not the unboxing. That seems like a mistake to me. It feels like you've partially hacked in higher-level type awareness into a language that doesn't have it. Look at what something like Ceylon does here instead.
Timothy Schmid the point is union typing and putting all this type_info crap behind some macros or operators makes the code strictly easier to read, is zero-cost (yes, really zero cost. It's a compile-time feature) and doesn't expose the guts of the programming language to the user (we want to interface with the hardware on a low level. Not the damn linker tables).
I wrote a program, that is building tetris figures into the smallest square they possibly fit in. I did not know that printf is so stupid, so I was using it a lot for checks. First I generate a map, I display it using printf, then I build the figures and display it again, if I delete the first printf(that displays the empty map, the program does not work any more)! can someone give me a tip?
thats because he's passing pointers just through the address, which is what you'd understand as passing parameters as a void* in C or C++ and then casting them back to the type he wants them to be when using them and dereferences them.. So why should he add this "as_ref"? What he's doing is just fine and it is understandable. as_ref would actually make it harder to understand what is going on, because in my mind it makes it seem like i'd be return a pointer or reference of some sort, while ^ is the pointer symbol here, so... i would not be getting what the name you proposed implies.
+Jonathan_Blow, C actually does let you use your own buffers for files using the setvbuf function. The line-based buffering for FILEs with a default buffer size of BUFSIZ is just a convenience.
The signed integer code has a bug. If you pass in a -2^63 you will get an error. It will see that it is a signed int, print out the minus sign, and then multiply -2^63 by -1. You will end up with 2^63 in a signed int which has a maximum value of 2^63-1, which is an overflow. I have had to implement an int to string function for a system where I didn't have the standard library, and that was a bug I had.
Once the value is in an unsigned integer variable, it doesn't matter.
He writes code faster than I can speak.
hes pretty good. very experienced.
Recursion also is able prints unsigned decimal/hex numbers without buffer. Since it reverses the output and that's exactly what you want with numbers when using mod (% in c).
Type casting seems to be a little inconsistent. I know this is syntaxual (if that's a word) but because variables are declared like this:
`name : type = ...`
It makes much more sense to cast with the type afterwards.
Current casting:
`cast(type) var`
Consistent casting:
`var as type`
`cast(var, type)`
Then auto-casting can a little simpler to read:
`var as auto_symbol`
`cast(var)`
`cast(var, auto_symbol)`
`autocast(var)`
Again this is not that important yet but consistency and readability is good.
in the linux terminal you can use the emacs shortcuts as well ! (in my case fedora)
"I guess it will just work". I never guess i guess.
Hope this is about MS implementation of printf.
Why is printf one of the worst C functions?
steven avery because the formatting rules are designed by 1970s unix programmers with too much free time and no concept of user friendlyness.
steven avery IMO one of the best.
steven avery It isn't.
Gabriel Hasbun It is. If you watch part 2 and 3 you'll understand why. Internationalization.
Oh. True.
I should write myself a language that transpiles to c for fun someday
printf is the wildcard standard IO function in stdio, can have infinite parametra, i could never work it out. :) is wierd trying to make a version of it.
1 being successful would confuse me to no end
You've implemented a curious type system. Basically Any is a boxed type where the language takes care of the boxing but not the unboxing. That seems like a mistake to me. It feels like you've partially hacked in higher-level type awareness into a language that doesn't have it.
Look at what something like Ceylon does here instead.
sadmac7000 Sigh.
Timothy Schmid Necessary in what sense? Vacuously we could all write in assembly language.
Well right, but, none of it is necessary. Language design is a desirability game not a necessity game.
Timothy Schmid the point is union typing and putting all this type_info crap behind some macros or operators makes the code strictly easier to read, is zero-cost (yes, really zero cost. It's a compile-time feature) and doesn't expose the guts of the programming language to the user (we want to interface with the hardware on a low level. Not the damn linker tables).
Timothy Schmid but it's not necessary for the language :P
I kid I kid.
You are going to rewrite printf() during one hour of programming? This is ambitious :)
I wrote a program, that is building tetris figures into the smallest square they possibly fit in. I did not know that printf is so stupid, so I was using it a lot for checks. First I generate a map, I display it using printf, then I build the figures and display it again, if I delete the first printf(that displays the empty map, the program does not work any more)! can someone give me a tip?
You use "*cast(^Type) variable" too often, why wouldn't you implement another keyword for it eg "as_ref(Type) variable"?
Bad trade off sparing a trivial amount of writing by implementing something that makes the language harder to learn.
thats because he's passing pointers just through the address, which is what you'd understand as passing parameters as a void* in C or C++ and then casting them back to the type he wants them to be when using them and dereferences them.. So why should he add this "as_ref"? What he's doing is just fine and it is understandable. as_ref would actually make it harder to understand what is going on, because in my mind it makes it seem like i'd be return a pointer or reference of some sort, while ^ is the pointer symbol here, so... i would not be getting what the name you proposed implies.
Second
Fourth
Thirtythird
Twentieth
+301st
Fifth
Sixth