Recent

Author Topic: maximum number of parameters of a method  (Read 1774 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
maximum number of parameters of a method
« on: March 21, 2023, 05:24:20 pm »
Hello,
is it 255?

I have a idiot function (data recording) that needs to get a huge (about 350) number of params and it does not compile. The reason why I do not put them into a record and have a single parameter is that when function will be modified to include extra values, I want it to stop compiling before I supply everywhere all newly requested parameters (if I use a record I need to find all cals and make sure new parameters are filled as well, for sure this won't happen).
In following program 255 works, while 256 does not.

Code: Pascal  [Select][+][-]
  1. {
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  5. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. }
  9.  
  10. {$mode objfpc}
  11.  
  12. program Hello;
  13.  
  14. function DoTheJob(
  15.  a001: Integer
  16. ;a002: Integer
  17. ;a003: Integer
  18. ;a004: Integer
  19. ;a005: Integer
  20. ;a006: Integer
  21. ;a007: Integer
  22. ;a008: Integer
  23. ;a009: Integer
  24. ;a010: Integer
  25. ;a011: Integer
  26. ;a012: Integer
  27. ;a013: Integer
  28. ;a014: Integer
  29. ;a015: Integer
  30. ;a016: Integer
  31. ;a017: Integer
  32. ;a018: Integer
  33. ;a019: Integer
  34. ;a020: Integer
  35. ;a021: Integer
  36. ;a022: Integer
  37. ;a023: Integer
  38. ;a024: Integer
  39. ;a025: Integer
  40. ;a026: Integer
  41. ;a027: Integer
  42. ;a028: Integer
  43. ;a029: Integer
  44. ;a030: Integer
  45. ;a031: Integer
  46. ;a032: Integer
  47. ;a033: Integer
  48. ;a034: Integer
  49. ;a035: Integer
  50. ;a036: Integer
  51. ;a037: Integer
  52. ;a038: Integer
  53. ;a039: Integer
  54. ;a040: Integer
  55. ;a041: Integer
  56. ;a042: Integer
  57. ;a043: Integer
  58. ;a044: Integer
  59. ;a045: Integer
  60. ;a046: Integer
  61. ;a047: Integer
  62. ;a048: Integer
  63. ;a049: Integer
  64. ;a050: Integer
  65. ;a051: Integer
  66. ;a052: Integer
  67. ;a053: Integer
  68. ;a054: Integer
  69. ;a055: Integer
  70. ;a056: Integer
  71. ;a057: Integer
  72. ;a058: Integer
  73. ;a059: Integer
  74. ;a060: Integer
  75. ;a061: Integer
  76. ;a062: Integer
  77. ;a063: Integer
  78. ;a064: Integer
  79. ;a065: Integer
  80. ;a066: Integer
  81. ;a067: Integer
  82. ;a068: Integer
  83. ;a069: Integer
  84. ;a070: Integer
  85. ;a071: Integer
  86. ;a072: Integer
  87. ;a073: Integer
  88. ;a074: Integer
  89. ;a075: Integer
  90. ;a076: Integer
  91. ;a077: Integer
  92. ;a078: Integer
  93. ;a079: Integer
  94. ;a080: Integer
  95. ;a081: Integer
  96. ;a082: Integer
  97. ;a083: Integer
  98. ;a084: Integer
  99. ;a085: Integer
  100. ;a086: Integer
  101. ;a087: Integer
  102. ;a088: Integer
  103. ;a089: Integer
  104. ;a090: Integer
  105. ;a091: Integer
  106. ;a092: Integer
  107. ;a093: Integer
  108. ;a094: Integer
  109. ;a095: Integer
  110. ;a096: Integer
  111. ;a097: Integer
  112. ;a098: Integer
  113. ;a099: Integer
  114. ;a100: Integer
  115. ;a101: Integer
  116. ;a102: Integer
  117. ;a103: Integer
  118. ;a104: Integer
  119. ;a105: Integer
  120. ;a106: Integer
  121. ;a107: Integer
  122. ;a108: Integer
  123. ;a109: Integer
  124. ;a110: Integer
  125. ;a111: Integer
  126. ;a112: Integer
  127. ;a113: Integer
  128. ;a114: Integer
  129. ;a115: Integer
  130. ;a116: Integer
  131. ;a117: Integer
  132. ;a118: Integer
  133. ;a119: Integer
  134. ;a120: Integer
  135. ;a121: Integer
  136. ;a122: Integer
  137. ;a123: Integer
  138. ;a124: Integer
  139. ;a125: Integer
  140. ;a126: Integer
  141. ;a127: Integer
  142. ;a128: Integer
  143. ;a129: Integer
  144. ;a130: Integer
  145. ;a131: Integer
  146. ;a132: Integer
  147. ;a133: Integer
  148. ;a134: Integer
  149. ;a135: Integer
  150. ;a136: Integer
  151. ;a137: Integer
  152. ;a138: Integer
  153. ;a139: Integer
  154. ;a140: Integer
  155. ;a141: Integer
  156. ;a142: Integer
  157. ;a143: Integer
  158. ;a144: Integer
  159. ;a145: Integer
  160. ;a146: Integer
  161. ;a147: Integer
  162. ;a148: Integer
  163. ;a149: Integer
  164. ;a150: Integer
  165. ;a151: Integer
  166. ;a152: Integer
  167. ;a153: Integer
  168. ;a154: Integer
  169. ;a155: Integer
  170. ;a156: Integer
  171. ;a157: Integer
  172. ;a158: Integer
  173. ;a159: Integer
  174. ;a160: Integer
  175. ;a161: Integer
  176. ;a162: Integer
  177. ;a163: Integer
  178. ;a164: Integer
  179. ;a165: Integer
  180. ;a166: Integer
  181. ;a167: Integer
  182. ;a168: Integer
  183. ;a169: Integer
  184. ;a170: Integer
  185. ;a171: Integer
  186. ;a172: Integer
  187. ;a173: Integer
  188. ;a174: Integer
  189. ;a175: Integer
  190. ;a176: Integer
  191. ;a177: Integer
  192. ;a178: Integer
  193. ;a179: Integer
  194. ;a180: Integer
  195. ;a181: Integer
  196. ;a182: Integer
  197. ;a183: Integer
  198. ;a184: Integer
  199. ;a185: Integer
  200. ;a186: Integer
  201. ;a187: Integer
  202. ;a188: Integer
  203. ;a189: Integer
  204. ;a190: Integer
  205. ;a191: Integer
  206. ;a192: Integer
  207. ;a193: Integer
  208. ;a194: Integer
  209. ;a195: Integer
  210. ;a196: Integer
  211. ;a197: Integer
  212. ;a198: Integer
  213. ;a199: Integer
  214. ;a200: Integer
  215. ;a201: Integer
  216. ;a202: Integer
  217. ;a203: Integer
  218. ;a204: Integer
  219. ;a205: Integer
  220. ;a206: Integer
  221. ;a207: Integer
  222. ;a208: Integer
  223. ;a209: Integer
  224. ;a210: Integer
  225. ;a211: Integer
  226. ;a212: Integer
  227. ;a213: Integer
  228. ;a214: Integer
  229. ;a215: Integer
  230. ;a216: Integer
  231. ;a217: Integer
  232. ;a218: Integer
  233. ;a219: Integer
  234. ;a220: Integer
  235. ;a221: Integer
  236. ;a222: Integer
  237. ;a223: Integer
  238. ;a224: Integer
  239. ;a225: Integer
  240. ;a226: Integer
  241. ;a227: Integer
  242. ;a228: Integer
  243. ;a229: Integer
  244. ;a230: Integer
  245. ;a231: Integer
  246. ;a232: Integer
  247. ;a233: Integer
  248. ;a234: Integer
  249. ;a235: Integer
  250. ;a236: Integer
  251. ;a237: Integer
  252. ;a238: Integer
  253. ;a239: Integer
  254. ;a240: Integer
  255. ;a241: Integer
  256. ;a242: Integer
  257. ;a243: Integer
  258. ;a244: Integer
  259. ;a245: Integer
  260. ;a246: Integer
  261. ;a247: Integer
  262. ;a248: Integer
  263. ;a249: Integer
  264. ;a250: Integer
  265. ;a251: Integer
  266. ;a252: Integer
  267. ;a253: Integer
  268. ;a254: Integer
  269. ;a255: Integer
  270. //;a256: Integer
  271. ): Integer;
  272. begin
  273.   Result := 1
  274. +a001
  275. +a002
  276. +a003
  277. +a004
  278. +a005
  279. +a006
  280. +a007
  281. +a008
  282. +a009
  283. +a010
  284. +a011
  285. +a012
  286. +a013
  287. +a014
  288. +a015
  289. +a016
  290. +a017
  291. +a018
  292. +a019
  293. +a020
  294. +a021
  295. +a022
  296. +a023
  297. +a024
  298. +a025
  299. +a026
  300. +a027
  301. +a028
  302. +a029
  303. +a030
  304. +a031
  305. +a032
  306. +a033
  307. +a034
  308. +a035
  309. +a036
  310. +a037
  311. +a038
  312. +a039
  313. +a040
  314. +a041
  315. +a042
  316. +a043
  317. +a044
  318. +a045
  319. +a046
  320. +a047
  321. +a048
  322. +a049
  323. +a050
  324. +a051
  325. +a052
  326. +a053
  327. +a054
  328. +a055
  329. +a056
  330. +a057
  331. +a058
  332. +a059
  333. +a060
  334. +a061
  335. +a062
  336. +a063
  337. +a064
  338. +a065
  339. +a066
  340. +a067
  341. +a068
  342. +a069
  343. +a070
  344. +a071
  345. +a072
  346. +a073
  347. +a074
  348. +a075
  349. +a076
  350. +a077
  351. +a078
  352. +a079
  353. +a080
  354. +a081
  355. +a082
  356. +a083
  357. +a084
  358. +a085
  359. +a086
  360. +a087
  361. +a088
  362. +a089
  363. +a090
  364. +a091
  365. +a092
  366. +a093
  367. +a094
  368. +a095
  369. +a096
  370. +a097
  371. +a098
  372. +a099
  373. +a100
  374. +a101
  375. +a102
  376. +a103
  377. +a104
  378. +a105
  379. +a106
  380. +a107
  381. +a108
  382. +a109
  383. +a110
  384. +a111
  385. +a112
  386. +a113
  387. +a114
  388. +a115
  389. +a116
  390. +a117
  391. +a118
  392. +a119
  393. +a120
  394. +a121
  395. +a122
  396. +a123
  397. +a124
  398. +a125
  399. +a126
  400. +a127
  401. +a128
  402. +a129
  403. +a130
  404. +a131
  405. +a132
  406. +a133
  407. +a134
  408. +a135
  409. +a136
  410. +a137
  411. +a138
  412. +a139
  413. +a140
  414. +a141
  415. +a142
  416. +a143
  417. +a144
  418. +a145
  419. +a146
  420. +a147
  421. +a148
  422. +a149
  423. +a150
  424. +a151
  425. +a152
  426. +a153
  427. +a154
  428. +a155
  429. +a156
  430. +a157
  431. +a158
  432. +a159
  433. +a160
  434. +a161
  435. +a162
  436. +a163
  437. +a164
  438. +a165
  439. +a166
  440. +a167
  441. +a168
  442. +a169
  443. +a170
  444. +a171
  445. +a172
  446. +a173
  447. +a174
  448. +a175
  449. +a176
  450. +a177
  451. +a178
  452. +a179
  453. +a180
  454. +a181
  455. +a182
  456. +a183
  457. +a184
  458. +a185
  459. +a186
  460. +a187
  461. +a188
  462. +a189
  463. +a190
  464. +a191
  465. +a192
  466. +a193
  467. +a194
  468. +a195
  469. +a196
  470. +a197
  471. +a198
  472. +a199
  473. +a200
  474. +a201
  475. +a202
  476. +a203
  477. +a204
  478. +a205
  479. +a206
  480. +a207
  481. +a208
  482. +a209
  483. +a210
  484. +a211
  485. +a212
  486. +a213
  487. +a214
  488. +a215
  489. +a216
  490. +a217
  491. +a218
  492. +a219
  493. +a220
  494. +a221
  495. +a222
  496. +a223
  497. +a224
  498. +a225
  499. +a226
  500. +a227
  501. +a228
  502. +a229
  503. +a230
  504. +a231
  505. +a232
  506. +a233
  507. +a234
  508. +a235
  509. +a236
  510. +a237
  511. +a238
  512. +a239
  513. +a240
  514. +a241
  515. +a242
  516. +a243
  517. +a244
  518. +a245
  519. +a246
  520. +a247
  521. +a248
  522. +a249
  523. +a250
  524. +a251
  525. +a252
  526. +a253
  527. +a254
  528. +a255
  529. //+a256
  530.    ;
  531. end;
  532.  
  533. var
  534. v001: Integer = 1;
  535. v002: Integer = 1;
  536. v003: Integer = 1;
  537. v004: Integer = 1;
  538. v005: Integer = 1;
  539. v006: Integer = 1;
  540. v007: Integer = 1;
  541. v008: Integer = 1;
  542. v009: Integer = 1;
  543. v010: Integer = 1;
  544. v011: Integer = 1;
  545. v012: Integer = 1;
  546. v013: Integer = 1;
  547. v014: Integer = 1;
  548. v015: Integer = 1;
  549. v016: Integer = 1;
  550. v017: Integer = 1;
  551. v018: Integer = 1;
  552. v019: Integer = 1;
  553. v020: Integer = 1;
  554. v021: Integer = 1;
  555. v022: Integer = 1;
  556. v023: Integer = 1;
  557. v024: Integer = 1;
  558. v025: Integer = 1;
  559. v026: Integer = 1;
  560. v027: Integer = 1;
  561. v028: Integer = 1;
  562. v029: Integer = 1;
  563. v030: Integer = 1;
  564. v031: Integer = 1;
  565. v032: Integer = 1;
  566. v033: Integer = 1;
  567. v034: Integer = 1;
  568. v035: Integer = 1;
  569. v036: Integer = 1;
  570. v037: Integer = 1;
  571. v038: Integer = 1;
  572. v039: Integer = 1;
  573. v040: Integer = 1;
  574. v041: Integer = 1;
  575. v042: Integer = 1;
  576. v043: Integer = 1;
  577. v044: Integer = 1;
  578. v045: Integer = 1;
  579. v046: Integer = 1;
  580. v047: Integer = 1;
  581. v048: Integer = 1;
  582. v049: Integer = 1;
  583. v050: Integer = 1;
  584. v051: Integer = 1;
  585. v052: Integer = 1;
  586. v053: Integer = 1;
  587. v054: Integer = 1;
  588. v055: Integer = 1;
  589. v056: Integer = 1;
  590. v057: Integer = 1;
  591. v058: Integer = 1;
  592. v059: Integer = 1;
  593. v060: Integer = 1;
  594. v061: Integer = 1;
  595. v062: Integer = 1;
  596. v063: Integer = 1;
  597. v064: Integer = 1;
  598. v065: Integer = 1;
  599. v066: Integer = 1;
  600. v067: Integer = 1;
  601. v068: Integer = 1;
  602. v069: Integer = 1;
  603. v070: Integer = 1;
  604. v071: Integer = 1;
  605. v072: Integer = 1;
  606. v073: Integer = 1;
  607. v074: Integer = 1;
  608. v075: Integer = 1;
  609. v076: Integer = 1;
  610. v077: Integer = 1;
  611. v078: Integer = 1;
  612. v079: Integer = 1;
  613. v080: Integer = 1;
  614. v081: Integer = 1;
  615. v082: Integer = 1;
  616. v083: Integer = 1;
  617. v084: Integer = 1;
  618. v085: Integer = 1;
  619. v086: Integer = 1;
  620. v087: Integer = 1;
  621. v088: Integer = 1;
  622. v089: Integer = 1;
  623. v090: Integer = 1;
  624. v091: Integer = 1;
  625. v092: Integer = 1;
  626. v093: Integer = 1;
  627. v094: Integer = 1;
  628. v095: Integer = 1;
  629. v096: Integer = 1;
  630. v097: Integer = 1;
  631. v098: Integer = 1;
  632. v099: Integer = 1;
  633. v100: Integer = 1;
  634. v101: Integer = 1;
  635. v102: Integer = 1;
  636. v103: Integer = 1;
  637. v104: Integer = 1;
  638. v105: Integer = 1;
  639. v106: Integer = 1;
  640. v107: Integer = 1;
  641. v108: Integer = 1;
  642. v109: Integer = 1;
  643. v110: Integer = 1;
  644. v111: Integer = 1;
  645. v112: Integer = 1;
  646. v113: Integer = 1;
  647. v114: Integer = 1;
  648. v115: Integer = 1;
  649. v116: Integer = 1;
  650. v117: Integer = 1;
  651. v118: Integer = 1;
  652. v119: Integer = 1;
  653. v120: Integer = 1;
  654. v121: Integer = 1;
  655. v122: Integer = 1;
  656. v123: Integer = 1;
  657. v124: Integer = 1;
  658. v125: Integer = 1;
  659. v126: Integer = 1;
  660. v127: Integer = 1;
  661. v128: Integer = 1;
  662. v129: Integer = 1;
  663. v130: Integer = 1;
  664. v131: Integer = 1;
  665. v132: Integer = 1;
  666. v133: Integer = 1;
  667. v134: Integer = 1;
  668. v135: Integer = 1;
  669. v136: Integer = 1;
  670. v137: Integer = 1;
  671. v138: Integer = 1;
  672. v139: Integer = 1;
  673. v140: Integer = 1;
  674. v141: Integer = 1;
  675. v142: Integer = 1;
  676. v143: Integer = 1;
  677. v144: Integer = 1;
  678. v145: Integer = 1;
  679. v146: Integer = 1;
  680. v147: Integer = 1;
  681. v148: Integer = 1;
  682. v149: Integer = 1;
  683. v150: Integer = 1;
  684. v151: Integer = 1;
  685. v152: Integer = 1;
  686. v153: Integer = 1;
  687. v154: Integer = 1;
  688. v155: Integer = 1;
  689. v156: Integer = 1;
  690. v157: Integer = 1;
  691. v158: Integer = 1;
  692. v159: Integer = 1;
  693. v160: Integer = 1;
  694. v161: Integer = 1;
  695. v162: Integer = 1;
  696. v163: Integer = 1;
  697. v164: Integer = 1;
  698. v165: Integer = 1;
  699. v166: Integer = 1;
  700. v167: Integer = 1;
  701. v168: Integer = 1;
  702. v169: Integer = 1;
  703. v170: Integer = 1;
  704. v171: Integer = 1;
  705. v172: Integer = 1;
  706. v173: Integer = 1;
  707. v174: Integer = 1;
  708. v175: Integer = 1;
  709. v176: Integer = 1;
  710. v177: Integer = 1;
  711. v178: Integer = 1;
  712. v179: Integer = 1;
  713. v180: Integer = 1;
  714. v181: Integer = 1;
  715. v182: Integer = 1;
  716. v183: Integer = 1;
  717. v184: Integer = 1;
  718. v185: Integer = 1;
  719. v186: Integer = 1;
  720. v187: Integer = 1;
  721. v188: Integer = 1;
  722. v189: Integer = 1;
  723. v190: Integer = 1;
  724. v191: Integer = 1;
  725. v192: Integer = 1;
  726. v193: Integer = 1;
  727. v194: Integer = 1;
  728. v195: Integer = 1;
  729. v196: Integer = 1;
  730. v197: Integer = 1;
  731. v198: Integer = 1;
  732. v199: Integer = 1;
  733. v200: Integer = 1;
  734. v201: Integer = 1;
  735. v202: Integer = 1;
  736. v203: Integer = 1;
  737. v204: Integer = 1;
  738. v205: Integer = 1;
  739. v206: Integer = 1;
  740. v207: Integer = 1;
  741. v208: Integer = 1;
  742. v209: Integer = 1;
  743. v210: Integer = 1;
  744. v211: Integer = 1;
  745. v212: Integer = 1;
  746. v213: Integer = 1;
  747. v214: Integer = 1;
  748. v215: Integer = 1;
  749. v216: Integer = 1;
  750. v217: Integer = 1;
  751. v218: Integer = 1;
  752. v219: Integer = 1;
  753. v220: Integer = 1;
  754. v221: Integer = 1;
  755. v222: Integer = 1;
  756. v223: Integer = 1;
  757. v224: Integer = 1;
  758. v225: Integer = 1;
  759. v226: Integer = 1;
  760. v227: Integer = 1;
  761. v228: Integer = 1;
  762. v229: Integer = 1;
  763. v230: Integer = 1;
  764. v231: Integer = 1;
  765. v232: Integer = 1;
  766. v233: Integer = 1;
  767. v234: Integer = 1;
  768. v235: Integer = 1;
  769. v236: Integer = 1;
  770. v237: Integer = 1;
  771. v238: Integer = 1;
  772. v239: Integer = 1;
  773. v240: Integer = 1;
  774. v241: Integer = 1;
  775. v242: Integer = 1;
  776. v243: Integer = 1;
  777. v244: Integer = 1;
  778. v245: Integer = 1;
  779. v246: Integer = 1;
  780. v247: Integer = 1;
  781. v248: Integer = 1;
  782. v249: Integer = 1;
  783. v250: Integer = 1;
  784. v251: Integer = 1;
  785. v252: Integer = 1;
  786. v253: Integer = 1;
  787. v254: Integer = 1;
  788. v255: Integer = 1;
  789. //v256: Integer = 1;
  790. begin
  791.   writeln ('Hello World');
  792.   DoTheJob(
  793.   v001
  794. , v002
  795. , v003
  796. , v004
  797. , v005
  798. , v006
  799. , v007
  800. , v008
  801. , v009
  802. , v010
  803. , v011
  804. , v012
  805. , v013
  806. , v014
  807. , v015
  808. , v016
  809. , v017
  810. , v018
  811. , v019
  812. , v020
  813. , v021
  814. , v022
  815. , v023
  816. , v024
  817. , v025
  818. , v026
  819. , v027
  820. , v028
  821. , v029
  822. , v030
  823. , v031
  824. , v032
  825. , v033
  826. , v034
  827. , v035
  828. , v036
  829. , v037
  830. , v038
  831. , v039
  832. , v040
  833. , v041
  834. , v042
  835. , v043
  836. , v044
  837. , v045
  838. , v046
  839. , v047
  840. , v048
  841. , v049
  842. , v050
  843. , v051
  844. , v052
  845. , v053
  846. , v054
  847. , v055
  848. , v056
  849. , v057
  850. , v058
  851. , v059
  852. , v060
  853. , v061
  854. , v062
  855. , v063
  856. , v064
  857. , v065
  858. , v066
  859. , v067
  860. , v068
  861. , v069
  862. , v070
  863. , v071
  864. , v072
  865. , v073
  866. , v074
  867. , v075
  868. , v076
  869. , v077
  870. , v078
  871. , v079
  872. , v080
  873. , v081
  874. , v082
  875. , v083
  876. , v084
  877. , v085
  878. , v086
  879. , v087
  880. , v088
  881. , v089
  882. , v090
  883. , v091
  884. , v092
  885. , v093
  886. , v094
  887. , v095
  888. , v096
  889. , v097
  890. , v098
  891. , v099
  892. , v100
  893. , v101
  894. , v102
  895. , v103
  896. , v104
  897. , v105
  898. , v106
  899. , v107
  900. , v108
  901. , v109
  902. , v110
  903. , v111
  904. , v112
  905. , v113
  906. , v114
  907. , v115
  908. , v116
  909. , v117
  910. , v118
  911. , v119
  912. , v120
  913. , v121
  914. , v122
  915. , v123
  916. , v124
  917. , v125
  918. , v126
  919. , v127
  920. , v128
  921. , v129
  922. , v130
  923. , v131
  924. , v132
  925. , v133
  926. , v134
  927. , v135
  928. , v136
  929. , v137
  930. , v138
  931. , v139
  932. , v140
  933. , v141
  934. , v142
  935. , v143
  936. , v144
  937. , v145
  938. , v146
  939. , v147
  940. , v148
  941. , v149
  942. , v150
  943. , v151
  944. , v152
  945. , v153
  946. , v154
  947. , v155
  948. , v156
  949. , v157
  950. , v158
  951. , v159
  952. , v160
  953. , v161
  954. , v162
  955. , v163
  956. , v164
  957. , v165
  958. , v166
  959. , v167
  960. , v168
  961. , v169
  962. , v170
  963. , v171
  964. , v172
  965. , v173
  966. , v174
  967. , v175
  968. , v176
  969. , v177
  970. , v178
  971. , v179
  972. , v180
  973. , v181
  974. , v182
  975. , v183
  976. , v184
  977. , v185
  978. , v186
  979. , v187
  980. , v188
  981. , v189
  982. , v190
  983. , v191
  984. , v192
  985. , v193
  986. , v194
  987. , v195
  988. , v196
  989. , v197
  990. , v198
  991. , v199
  992. , v200
  993. , v201
  994. , v202
  995. , v203
  996. , v204
  997. , v205
  998. , v206
  999. , v207
  1000. , v208
  1001. , v209
  1002. , v210
  1003. , v211
  1004. , v212
  1005. , v213
  1006. , v214
  1007. , v215
  1008. , v216
  1009. , v217
  1010. , v218
  1011. , v219
  1012. , v220
  1013. , v221
  1014. , v222
  1015. , v223
  1016. , v224
  1017. , v225
  1018. , v226
  1019. , v227
  1020. , v228
  1021. , v229
  1022. , v230
  1023. , v231
  1024. , v232
  1025. , v233
  1026. , v234
  1027. , v235
  1028. , v236
  1029. , v237
  1030. , v238
  1031. , v239
  1032. , v240
  1033. , v241
  1034. , v242
  1035. , v243
  1036. , v244
  1037. , v245
  1038. , v246
  1039. , v247
  1040. , v248
  1041. , v249
  1042. , v250
  1043. , v251
  1044. , v252
  1045. , v253
  1046. , v254
  1047. , v255
  1048. //, v256
  1049. );
  1050.  
  1051. end.
  1052.  
« Last Edit: March 21, 2023, 05:29:00 pm by tt »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2066
  • Fifty shades of code.
    • Delphi & FreePascal
Re: maximum number of parameters of a method
« Reply #1 on: March 21, 2023, 05:46:36 pm »
Why not use an array for your parameters? You can easy iterate over to know how much you got etc...
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: maximum number of parameters of a method
« Reply #2 on: March 21, 2023, 05:49:30 pm »
Sorry to be blunt, but this is a really idiotic means of using a function with parameters.

The reason why I do not put them into a record and have a single parameter is that when function will be modified to include extra values...

That's what an array is for.

Code: Pascal  [Select][+][-]
  1. function DoTheJob(a: array of integer): Integer;
  2. begin
  3.   // you can use assert(length(a) = 230); or whatever to check the number of elements in a and give an exception if it's something else
  4.  
  5.  

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: maximum number of parameters of a method
« Reply #3 on: March 21, 2023, 09:36:03 pm »
is it 255?

Yes, it simply makes no sense to pass that many parameters and even 255 is already insanely high.

As others already wrote use a smarter approach to pass the parameters.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: maximum number of parameters of a method
« Reply #4 on: March 21, 2023, 09:52:47 pm »
It's great that someone stresses the compiler to the limits and tries what can squeeze out of it!  :D
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: maximum number of parameters of a method
« Reply #5 on: March 21, 2023, 10:41:56 pm »
maybe some day he will learn to use a dynamic array.
The only true wisdom is knowing you know nothing

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: maximum number of parameters of a method
« Reply #6 on: March 21, 2023, 11:24:54 pm »
The recommendations with using arrays are all nice and all, but as was written in the first post, tt wants to have compile time checks of correctness. I can fully, and everything that can be checked at compiletime should be checked at compiletime understand this because compile time checks are the best kind security you can have. Sure you can add an assertion, but thats just a runtime check, which is much weaker than the guarantees given by a compile time check. Basically a compile time check means the code is provably correct, while a runtime check can at most check that in a set of test cases it is not incorrect, but there still might me cornercases where it fails.
I want it to stop compiling before I supply everywhere all newly requested parameters (if I use a record I need to find all cals and make sure new parameters are filled as well, for sure this won't happen).
You probably generate these functions as well as the calls to those functions automatically, using some sort of script. If this is the case, what you can do is use defines and ifdefs:
Code: Pascal  [Select][+][-]
  1. // Definition of function with 3 inputs
  2.   {$Define FooCount3}
  3.   procedure Foo(input: array of Integer);
  4.   begin
  5.     // ...
  6.   end;
  7.  
  8. begin
  9.   // on usage check assumption
  10.   {$IfNDef FooCount3}
  11.   {$Error Foo Input Count mismatch}
  12.   {$EndIf}
  13.   Foo([1, 2, 3]);
  14. end;

Now let's say you update foo to take 4 inputs, your generator would re-generate the function for four inputs, this would override the definition to:
Code: Pascal  [Select][+][-]
  1.   {$Define FooCount4}
  2.   procedure Foo(input: array of Integer);
  3.   begin
  4.     // ...
  5.   end;
Now because the FooCount3 was replace, the IfNDef triggers, which causes the error to be popped, stopping the compilation.

This of course is not a nice solution, but if you are generating your function then this should work fine. If you don't, why the hell would you write a function with hundreds of parameters by hand?
« Last Edit: March 21, 2023, 11:29:33 pm by Warfley »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: maximum number of parameters of a method
« Reply #7 on: March 22, 2023, 01:31:57 am »
if you want compile time checks then that means it can't be flexible at runtime.

A Constant array of the values needed will set the compile time check because if you don't have them all filled in or try to insert more then guess what?

 And I don't mean using constant arrays where the compiler needs to build it at runtime before calling the function.

A Type needs to be created that can be assigned at compile time as a constant and a function to accept that type.

Type
  TmyArrayOfInts =Array[0..?] of Integer;

 The Size limit will be a compile time thing and it is even writable!

Constant TheArray : TMyArrayOfInts= [.............];   < define the array at compile time.

MyFunction Xyz(TheList:TmyArrayOfInts)....


But still, this is all ridicules.


The only true wisdom is knowing you know nothing

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: maximum number of parameters of a method
« Reply #8 on: March 22, 2023, 08:37:44 am »
The function shown in the above example was only made to verify that the compler accepts 255 params, but refuses 256. I did not find any note about this in the docs.

The function that caused me problems is one where each parameter stands on its own, with its own data type and name compeletely unrelated to others.

Code: Pascal  [Select][+][-]
  1. procedure LibCall_Log_100_01_MachineSettingUpdate(eventDate: TDateTime;
  2.  
  3.     McompensazioneTraino: Single;
  4.     MgolaTraino: Integer;
  5.     MgolaVerticale: Integer;
  6.     MCompensazioneTrainoSec: Single;
  7.     MPiegatoreLento: Boolean;
  8.     MIncLato: Integer;
  9.     MTr2Delay: Integer;
  10.     MEvacTorr: Boolean;
  11.     MQExeSpade: Integer;
  12.     MScaricamento: Boolean;
  13.     MPausaCiclo: Boolean;
  14.     MAnticipoTr2: Boolean;
  15.     MFlagsSpade: Integer;
  16.     MQScarPeso: Single;
  17.     MQScarArea: Single;
  18.     MQScarPesoLeg: Single;
  19.     MQScarAreaLeg: Single;
  20.     MVelocitaCostante: Boolean;
  21.     MCarrelloDisabilitato: Boolean;
  22.     MAnticipoUscitaCan: Boolean;
  23.     MAnticipoRientroCan: Boolean;
  24.     MSpade2: Boolean;
  25.     MScaricoSagomati: Integer;
  26.     // many more parameters coming from a real multifunction machine related to concrete building manufacturing
  27.  
  28.  

Given that the limit is 255 (as PascalDragon said), I believe the I will to split into separate functions so that I can achieve the compile time explicit parameter assignment in case in future new extra values need passed (only Warfley understood correctly that this was my requirement, prob I did not explain it well enough).
« Last Edit: March 22, 2023, 08:44:08 am by tt »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: maximum number of parameters of a method
« Reply #9 on: March 22, 2023, 08:52:10 am »
(only Warfley understood correctly that this was my requirement, prob I did not explain it well enough).
No, I understood that as well. But it's still idiotic to abuse parameters like that.
(There is a reason there is a limit to parameters.)

If you need to do this in your code (and have it check number of param at compile time) then there is something wrong with your design (code or otherwise). You should build in the checks at other points (for example at receiving set values).

There seems to be a fault in design-thinking but we can't seem to get that across.

You could still work with a record.
For example type MyRecord23 (with your 350 values).

When you add a new field, and you would need to change all functions using it, you can also rename the record MyRecord24 at that point. During compile time you will get all the places where you used the (now non existing old) MyRecord23, so also all the places calling of that function, and you can change the code one step at a time.

You could also search all instances of that record in your whole project.

Really... there is a reason you never ever see such code around with 350 parameters.



« Last Edit: March 22, 2023, 08:55:57 am by rvk »

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: maximum number of parameters of a method
« Reply #10 on: March 22, 2023, 09:08:53 am »
(only Warfley understood correctly that this was my requirement, prob I did not explain it well enough).
No, I understood that as well. But it's still idiotic to abuse parameters like that.
(There is a reason there is a limit to parameters.)

If you need to do this in your code (and have it check number of param at compile time) then there is something wrong with your design (code or otherwise). You should build in the checks at other points (for example at receiving set values).

There seems to be a fault in design-thinking but we can't seem to get that across.

You could still work with a record.
For example type MyRecord23 (with your 350 values).

When you add a new field, and you would need to change all functions using it, you can also rename the record MyRecord24 at that point. During compile time you will get all the places where you used the (now non existing old) MyRecord23, so also all the places calling of that function, and you can change the code one step at a time.

You could also search all instances of that record in your whole project.

Really... there is a reason you never ever see such code around with 350 parameters.

The solution of renaming record is ok of course, and the process would be this (correct me if I am wrong):

- add to the record the new field
- rename the record type to a new name
- compile and get the errors to see everytime record was referred
- add the assignments missing in every place record is used and rename it in order that next compile this error point vanishes, until program compiles again (make sure you don't do mistakes because if you miss to add the new assignment your record will pass thru the function call anyway)
- rename the record to the original name
- compile and get the errors to see everytime record was referred
- fix all names to original until program compiles again

With the new parameter in the function the same was achieved like this:

- add the parameter the new function
- compile and get the errors to see everytime function is referred
- add the new parameters values until program compiles again

In the second there are less steps (and to me this seems also less error prone) so this is why I liked most.

But with the 255 limitation, I will probably use the record approach.

Another good of the record approach that it is impossible to get with the params, it that record can ba passed by pointer, and this speeds up the function call (seen that values passed wont be modified inside function in my case).

« Last Edit: March 22, 2023, 09:15:50 am by tt »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: maximum number of parameters of a method
« Reply #11 on: March 22, 2023, 09:35:04 am »
In the second there are less steps (and to me this seems also less error prone) so this is why I liked most.
Haha, no, it actually only feels like that.

For example, you wrote out "rename the record type to a new name". But that isn't really much work.

You also wrote "fix all names to original until program compiles again".
But you NEVER have to change the name of that record back to MyRecord23.
You can just leave the "version number" after it. It's not in the way.

The use of a record will also give you more flexibility.
You can pass it on to a log function, or a check_record function, without the need to create such a large function call.
And yes, also passing it as a reference param (via var) will pass the pointer instead of occupying stack space.

Once you get going, you probably see more benefits (like cleaner code).

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: maximum number of parameters of a method
« Reply #12 on: March 22, 2023, 09:49:41 am »
But you NEVER have to change the name of that record back to MyRecord23.
You can just leave the "version number" after it. It's not in the way.

I don't agree.

It could make sense have record23 and record24, if you must have a system capable of managing at the same time multiple ways of calling the function (with different number of record fields). Otherwise changing the record name would be also visible in the scm, along with the fact that a filed is added to the record. But the latter is the relevant modification, not the record name.

FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: maximum number of parameters of a method
« Reply #13 on: March 22, 2023, 09:53:42 am »
It could make sense have record23 and record24, if you must have a system capable of managing at the same time multiple ways of calling the function (with different number of record fields).
No, you don't need record23 AND record24. You only leave the latter.

You change type MyRecord23 to type MyRecord24 at the moment you add a field.
At that moment MyRecord23 ceases to exists and you get compile errors at places where you used it.
There is no need after that to rename MyRecord24 to anything else.

When you need to add another field, you rename type MyRecord24 to type MyRecord25 so you get compile errors again.
And so again to MyRecord26 when there is yet another new field.
etc.

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: maximum number of parameters of a method
« Reply #14 on: March 22, 2023, 09:58:10 am »
It could make sense have record23 and record24, if you must have a system capable of managing at the same time multiple ways of calling the function (with different number of record fields).
No, you don't need record23 AND record24. You only leave the latter.

You change type MyRecord23 to type MyRecord24 at the moment you add a field.
At that moment MyRecord23 ceases to exists and you get compile errors at places where you used it.
There is no need after that to rename MyRecord24 to anything else.

When you need to add another field, you rename type MyRecord24 to type MyRecord25 so you get compile errors again.
And so again to MyRecord26 when there is yet another new field.
etc.

Who says tha files are only added?
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

 

TinyPortal © 2005-2018