TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

_Application.Run(Object, Object, Object, Object, Object, Object, Object, Object

306 pointsby jamespwilliamsover 3 years ago

36 comments

jugover 3 years ago
It's funny to see but this is just documentation for a COM API function that runs a macro with any number of arguments (depending on the macro you want to run). That's why it doesn't use a typesafe delegate or something more clear but a lot of ugly "object"s; it has to pull it off with the lowest common denominator for .NET and COM. It's also not part of .NET but a generated COM interop shim to make the Excel interface callable from .NET.
评论 #29873959 未加载
评论 #29873019 未加载
petecooperover 3 years ago
&gt;Object, Object, Object, Object, Object, Object, Object, Object<p>Cmd+F, badger (Not found).<p>Cmd+F, mushroom (Not found).<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=EIyixC9NsLI" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=EIyixC9NsLI</a> (video sfw, comments may be the usual YouTube battleground)
评论 #29877240 未加载
wiradikusumaover 3 years ago
I first saw this &quot;hardcoded&quot; varargs in Scala e.g. <a href="https:&#x2F;&#x2F;www.scala-lang.org&#x2F;api&#x2F;2.12.2&#x2F;scala&#x2F;Tuple22.html" rel="nofollow">https:&#x2F;&#x2F;www.scala-lang.org&#x2F;api&#x2F;2.12.2&#x2F;scala&#x2F;Tuple22.html</a> (replace 22 to 1-21). I guess it&#x27;s platform (JVM) limitation? Newer Java also has something like this, but I can&#x27;t remember which class.
评论 #29872811 未加载
评论 #29873080 未加载
评论 #29872746 未加载
评论 #29875810 未加载
Joker_vDover 3 years ago
&quot;Why not just pass an array of arguments?&quot;<p>Speed and convenience, I&#x27;d imagine? IIRC, arrays are marshalled as SAFEARRAYs in COM and those things are quite heavy-weight, you&#x27;d <i>really</i> rather call a 31-parameter function and pass it 27 NULLs in places of extraneous parameters.
评论 #29872559 未加载
Ensorceledover 3 years ago
I feel like the &quot;Who wrote this shit?&quot; article and this one should be linked together ...
评论 #29879731 未加载
jveover 3 years ago
Well, not sure why that&#x27;s implemented as is, interop is some old technology and there are quirks or whatever. But .NET provides convenience methods&#x2F;delegates, like typed Action&lt;&gt;[1] (or Func&lt;&gt;) with 16 arguments, so you don&#x27;t have to explicitly define delegate yourself: [1] <a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;api&#x2F;system.action-16?view=net-6.0" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;api&#x2F;system.action-16...</a><p>Today as of C# 4 you can for example have optional arguments. Not sure if this applies to this method which surely predates C#4.
评论 #29872790 未加载
评论 #29877610 未加载
dfoxover 3 years ago
PostgreSQL used to have two different APIs for internal&#x2F;C language SQL functions, with the older one implemented in more or less this manner, but with distinct types for each argument count. The actual function call was then implemented as giant switch on number of arguments which called function pointer with progressively more Datum-typed arguments.<p>It got deprecated sometime around 8.0 and today it is not even supported (the giant switch got replaced by error message).
评论 #29876376 未加载
bugmen0tover 3 years ago
&quot;Thirty arguments should be enough for everybody&quot;
评论 #29876456 未加载
评论 #29881538 未加载
评论 #29878728 未加载
colonwqbangover 3 years ago
Reminds me of IFn from Clojure<p><a href="https:&#x2F;&#x2F;clojure.github.io&#x2F;clojure&#x2F;javadoc&#x2F;clojure&#x2F;lang&#x2F;IFn.html" rel="nofollow">https:&#x2F;&#x2F;clojure.github.io&#x2F;clojure&#x2F;javadoc&#x2F;clojure&#x2F;lang&#x2F;IFn.h...</a>
rackjackover 3 years ago
Rust has something similar, where some libraries implement on all the different tuples (X1, X2), (X1, X2, X3), (X1, X2, X3, X4), etc.
评论 #29872806 未加载
评论 #29873305 未加载
cfedukeover 3 years ago
Somewhat related, one of my favorites from &quot;Be Developer&#x27;s Guide&quot;[0]:<p><pre><code> is_computer_on_fire() double is_computer_on_fire(void) </code></pre> Returns the temperature of the motherboard if the computer is currently on fire. Smoldering doesn&#x27;t count. If the computer isn&#x27;t on fire, the function returns some other value.<p>---<p>Though of course, the Microsoft engineer[ing committee] was entirely serious when they wrote the OP&#x27;s function signature, while I imagine the Be engineer having a laugh while adding it to the SDK and then getting it into the official docs in print.<p>0. <a href="https:&#x2F;&#x2F;www.google.com&#x2F;books&#x2F;edition&#x2F;Be_Developer_s_Guide&#x2F;WoQ_AQAAIAAJ?hl=en&amp;gbpv=1&amp;bsq=be%20developers%20guide%20fire" rel="nofollow">https:&#x2F;&#x2F;www.google.com&#x2F;books&#x2F;edition&#x2F;Be_Developer_s_Guide&#x2F;Wo...</a>
评论 #29881908 未加载
Loeffelmaennover 3 years ago
Why wouldn&#x27;t the just use the params [0] keyword for stuff like this?<p>[0]: <a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;csharp&#x2F;language-reference&#x2F;keywords&#x2F;params" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;csharp&#x2F;language-refe...</a>
评论 #29872990 未加载
评论 #29872465 未加载
评论 #29874989 未加载
millermover 3 years ago
Clojure has to do the same thing to interface with Java: <a href="https:&#x2F;&#x2F;clojure.github.io&#x2F;clojure&#x2F;javadoc&#x2F;clojure&#x2F;lang&#x2F;IFn.html" rel="nofollow">https:&#x2F;&#x2F;clojure.github.io&#x2F;clojure&#x2F;javadoc&#x2F;clojure&#x2F;lang&#x2F;IFn.h...</a>
评论 #29877462 未加载
bradfitzover 3 years ago
&quot;If you have a procedure with ten parameters, you probably missed some.&quot; -- Alan Perlis
tupac_speedrapover 3 years ago
Why did they pick 30 optional arguments? I assume they just picked a number of arguments way bigger than you would actually require in the real world.
评论 #29872810 未加载
m_stover 3 years ago
I think this (and similar) Office interop method signatures were the reason they created optional parameters in C#.
评论 #29877202 未加载
commandlinefanover 3 years ago
I&#x27;m glad they provided documentation for all thirty parameters.
jhoelzelover 3 years ago
run object run!<p>I can see how this is not beautifull but works. Especially when its probably been there for 20 years already :D
oshiar53-0over 3 years ago
Clearly you haven&#x27;t heard of HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor<p><a href="http:&#x2F;&#x2F;dev.eclipse.org&#x2F;viewcvs&#x2F;index.cgi&#x2F;org.aspectj&#x2F;modules&#x2F;weaver&#x2F;src&#x2F;org&#x2F;aspectj&#x2F;weaver&#x2F;patterns&#x2F;HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor.java?revision=1.1&amp;root=Tools_Project" rel="nofollow">http:&#x2F;&#x2F;dev.eclipse.org&#x2F;viewcvs&#x2F;index.cgi&#x2F;org.aspectj&#x2F;modules...</a>
评论 #29875220 未加载
评论 #29875196 未加载
Mikeb85over 3 years ago
Why not just App.run(Object &amp;Args?) ?
yodelshadyover 3 years ago
I check you, Rust static-size arrays that implement common traits... as long as they&#x27;re no more than 32 elements long.<p>Yes, this bit me hard on first Rust-based project, to the point of abandonment. (A list that grow and shrink is <i>absolutely not the same thing</i>).
评论 #29874010 未加载
saagarjhaover 3 years ago
Another day, another example for why argument labels and variadics are really nice to have ;)
评论 #29872948 未加载
评论 #29872887 未加载
mro_nameover 3 years ago
hmmm - I love strict static typing. Fewer runtime errors and great tool support.
undebuggableover 3 years ago
...and that&#x27;s how _Application.Run.apply was invented
zeitgeist_y2kover 3 years ago
I would really like to hear the story told by a product manager about this... and learn about the discussions with the engineers on this :)
评论 #29874155 未加载
marcodiegoover 3 years ago
Doesn&#x27;t the language supports variadic functions?
评论 #29880854 未加载
mikotodomoover 3 years ago
Where do I even start to begin to understand this?
评论 #29877153 未加载
yua_mikamiover 3 years ago
Working without variadic templates is painful.
ok123456over 3 years ago
Rust does the same thing with tuples.
skeeter2020over 3 years ago
The ultimate abstraction!
vmceptionover 3 years ago
wow even solidity is better than this, and thats a super low bar! just pass an array
评论 #29879836 未加载
spondylover 3 years ago
I see your function with many parameters and I raise you this constant: CNLabelContactRelationYoungerCousinMothersSiblingsDaughterOrFathersSistersDaughter<p><a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;contacts&#x2F;cnlabelcontactrelationyoungercousinmotherssiblingsdaughterorfatherssistersdaughter" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;contacts&#x2F;cnlabelco...</a>
评论 #29877698 未加载
评论 #29872858 未加载
评论 #29877059 未加载
评论 #29875149 未加载
评论 #29873385 未加载
评论 #29873309 未加载
评论 #29881945 未加载
评论 #29874615 未加载
评论 #29879964 未加载
评论 #29875377 未加载
评论 #29875641 未加载
评论 #29874213 未加载
评论 #29875592 未加载
评论 #29872819 未加载
评论 #29872994 未加载
评论 #29872905 未加载
评论 #29872973 未加载
RedShift1over 3 years ago
Object arguments go brrrrr
rich_sashaover 3 years ago
Buffalo buffalo buffalo buffalo buffalo buffalo buffalo buffalo.
rightbyteover 3 years ago
Whatever it takes to make things work! =)<p>I guess stdarg.h like functionality would have been good for C#. Maybe some clean code purist argued against it because it is bad practice or something.
评论 #29872550 未加载
评论 #29872830 未加载
评论 #29872534 未加载
评论 #29872726 未加载
ivolimmenover 3 years ago
This is exactly why I dropped using C# and wend back to Java. Documentation on Microsoft products is really bad sometimes.<p>EDIT: Thanks for the downvotes. I am a professional software engineer for hire and in each company this is EXACTLY the issue: documentation. You want me to help you build software? Fine: give me your documentation. Complain about the fact that it takes 2 months to properly understand your software and business rules? Improve your documentation.
评论 #29872823 未加载
评论 #29872522 未加载
评论 #29872794 未加载
评论 #29872517 未加载