Talk:Comparison of Object Pascal and C
![]() | This redirect does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||
|
The string example is plain wrong ...
[edit]1. "as is a Keyword. This code will not compile. 2. The concatenation of a AnsiString with a Shortstring into a Shortstring will be silently truncated to 255 bytes if the resulting length exceeds the 255 char limit. I suggest the original author adapts the example accordingly.
Fixed and implemented
[edit]Next time, feel free to edit yourself, it's a wiki after all.
Leledumbo (talk) 02:57, 31 July 2014 (UTC)
A mistake...
[edit]quotation
Despite of its treatment as pointer, not all pointer style constructs could be used to array. For example, this code would compile fine but would cause access violation when executed:
void func(int *a) {
// RUNTIME ERROR! a is allocated statically
a = (int*) malloc(sizeof(int) * 10);
}
int main() {
int a[5];
func(a);
}
end of quotation
No, it is not a run time error. Remember that C/C++ passes parameters by value. So, "a" within "func" is a local copy of the pointer.
a = (int*) malloc(sizeof(int) * 10);
allocates the new memory, and assigns the memory address to "a", which is a local variable (as a byval parameter).
It is a memory leak, because the memory is allocated, and not freed. However, by itself, it will not cause an access violation.
If you were to declare "a" as const:
void func(int * const a) {
then you would get a compiler error. 107.33.42.66 (talk) 06:20, 15 August 2013 (UTC)
Right, please edit accordingly
[edit]I'd like to explain that things like this could happen (I had it some time ago, but I don't remember the exact code), but it looks like I've given a wrong example. Anyway, declaring the parameter as const doesn't give me compile error on gcc 4.8.1.
Leledumbo (talk) 02:58, 31 July 2014 (UTC)
Merge to Comparison of Pascal and C
[edit]- The following discussion is closed. Please do not modify it. Subsequent comments should be made in a new section. A summary of the conclusions reached follows.
- To redirect Comparison of Object Pascal and C to Comparison of Pascal and C now that unique material from the former has been added to the latter; overlap in scope; ease of maintenance. Klbrain (talk) 16:20, 24 April 2022 (UTC)
Hey folks!
I’ve just accidentally found this page. I actually meant to find Comparison of Pascal and C, because I already knew this kind of comparison page existed, I just didn’t know it’s title. The search terms “Pascal comparison” also listed this very page.
I hereby suggest to merge this article into Comparison of Pascal and C. AFAIK C does not have objects. This article is mainly comparing Standard, unextended Pascal to C. All those differences are already (more extensively) covered in Comparison of Pascal and C, so I think this article is rather redundant and should be merged there. But maybe I’m missing something?
‑‑ K (🗪 | ✍) 22:22, 11 February 2021 (UTC)
- Good catch. I havent't really checked, but it looks like there's nothing in the Object Pascal article that isn't also in the Pascal article. If that's true, we could simply delete the Object Pascal article, because there would be no content that we'd need to merge. But I'm not sure. (I'd like to get the opinion of Leledumbo (who wrote most of both articles), but that account seems to have been inactive since 2016.) — Chrisahn (talk) 23:22, 11 February 2021 (UTC)
I don't see the point of this article and recommend it just be deleted. It would not be relevant to merge it into Comparison of Pascal and C. Pascal is Pascal, not Object Pascal. C is C not C++. You can compare Pascal to C, or you can compare Object Pascal to C++. You can compare Pascal to Object Pascal or you can compare C to C++. If there is a good reason to have an article titled Comparison of Object Pascal and C then there is an equally good reason to have an article titled Comparison of C++ and Pascal which would be equally pointless. Chris Burrows (talk) 02:56, 12 February 2021 (UTC)
- @Leledumbo and Chris Burrows: I have now reviewed both articles and I must say Comparison of Pascal and C is in many respects superior to Comparison of Object Pascal and C simply because it’s been maintained. Some differences I couldn’t match are
- Comparison of Object Pascal and C mentions that Pascal identifiers may include underscores. EP (ISO 10206) allows (non-initial, non-consecutive) underscores, but Comparison of Pascal and C artificially restricts itself to ISO 7185 (confer introduction), so it’s legit.
- Comparison of Object Pascal and C claims C does not have “real” arrays, but mere syntax for “bulk declarations”. I’m not sure but I’d favor the “C has no arrays” wording since
int a[10]
apparently merely provides a pointer to a block of10*sizeof(int)
Bytes. There ain’t no particular language support other than that, right?
- I have incorporated some contents to the merge target Comparison of Pascal and C. ‑‑ K (🗪 | ✍) 14:30, 9 October 2021 (UTC)