I would say it's fine.
A .NET question, where C# is used to illustrate the question, can also be answered using VB.NET or F# code, as long as the type and method names are recognizable.
The same applies here. It doesn't matter how you write this pseudo-code:
var find = FindFirstFile(dir, &findData);do{ HandleFile(findData);} while (FindNextFile(dir, &findData))
It's clear that you're supposed to call FindFirstFile()
first and FindNextFile()
after that until it returns a falsey value in order to find all files in a directory.
It shouldn't matter in the slightest whether that code sample is given in C, C++, C#, Delphi or in any kind of pseudocode: its intentions are very clear, and who needs to initialize what and pass which variable in what way is something for the implementor to look up in the documentation anyway.
So yes, API questions can be closed as a duplicate of a question where the exact same problem, but in another (yet commonly used) language is being discussed.
Look, the problem I have with duplication is that usually the code is spread around, but not the explanation. For the Windows API, there is for example the common question "How can I drag a borderless window?". The simple answer to that is simple: "Let your entire window act as the title bar, by responding with HTCAPTION
to a WM_NCHITTEST
message". And that answer is copy-pasted around a lot - and is language-agnostic.
What this copy-pasted answer doesn't tell you, is for example that now wherever you drag the mouse on your window, drags that window around. So you may want to inspect the X and Y parameter of the hittest message to designate a certain area of your window as draggable.
A decent answer explains this, and even if it is accompanied by C++ code, the logic explained therein can be applied to any programming language.
Of course it is a different story altogether when a framework provides a wrapper. Setting .NET's WinForms Control.Text
to a string is not comparable at all to calling SetWindowText()
- unless the question is about an API-specific part of setting a control's text that applies to both approaches equally.
So to be thorough, if you don't agree with the above, you'd need to copy the entire accepted answer of the non-duplicate, and replace all ->
with .
or ::
, or vice versa. What are we doing then?