I fixed Lua

  Рет қаралды 43,834

Tsoding Daily

Tsoding Daily

Күн бұрын

References:
- Lua: www.lua.org/
- Funny Haha Tweet: / 1751380097100058981
Support:
- BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9
- Servers: zap-hosting.com/en/shop/donat...
Chapters:
- 00:00:00 - Announcement
- 00:00:35 - Intro
- 00:03:10 - First Impression
- 00:12:13 - Source Code Tour
- 01:01:22 - New Block
- 01:03:32 - Extending lua-mode
- 01:13:41 - Adding New Token
- 01:28:24 - Implementing Double Block
- 02:00:00 - 0-based Arrays
- 02:08:13 - Goto in Double Block
- 02:15:30 - Outro

Пікірлер: 182
@cobbcoding
@cobbcoding 4 ай бұрын
I like how the most difficult thing in the whole video is the lua syntax highlighting
@chriscoyc
@chriscoyc 4 ай бұрын
teachers: there is not a bad question tsoding: its just a bad question 😎
@hextav
@hextav 4 ай бұрын
based
@opsJson_
@opsJson_ 4 ай бұрын
BRAZIL MENTIONED? 🇧🇷🎉
@joaogabrielv.m328
@joaogabrielv.m328 4 ай бұрын
Brazil, caraleo! huehuhue
@Satoshinork
@Satoshinork 4 ай бұрын
Orakkk Brasil dominando
@Unit_00
@Unit_00 4 ай бұрын
brazil my beloved
@autistadolinux5336
@autistadolinux5336 4 ай бұрын
AE, CARAIO!!!!
@ilovemacross
@ilovemacross 4 ай бұрын
Eu amo esse russo❤
@StaRiToRe
@StaRiToRe 4 ай бұрын
to yet another Pogromming session?
@asdfmonstrosity
@asdfmonstrosity 4 ай бұрын
Lua is a great little language. Tables as data structures work surprisingly well, closures, iterators, everything can be a key and value, ... Even module import just fits so neatly into the language, usually just returning a table (but Lua just lets you do whatever! No restrictions is really cool)
@Mentox2
@Mentox2 4 ай бұрын
Its too bad OOP in LUA is pure pain, though really, you can do with jsut procedural code if you knwo what you are doing.
@valbogda5512
@valbogda5512 4 ай бұрын
@@Mentox2 I consider that one of its advantages.
@asdfmonstrosity
@asdfmonstrosity 4 ай бұрын
@@Mentox2 To get the most out of Lua you may need to do things a little differently, but I think it makes Lua better in the end. First class functions and closures really reduce the need for anything else, but it's not too much work to setup a metatable with methods if you really want it. I see the metatable "classes" more of a way to reduce creating multiple instances of functions, as an optimisation, rather than making Lua act particularly OO
@sournois90
@sournois90 Ай бұрын
@@Mentox2 the lack of formal classes in lua is barely noticeable with the power you get with tables. metatables too if it's still not enough for you.
@skaruts
@skaruts 4 ай бұрын
The code is actually pretty well documented with helpful comments. It really makes it easy to follow the code and get what it's doing. I'll remember this next time I cross paths with one of those clean-code advocates who defend that you should never use any comments in code.
@iamdozerq
@iamdozerq 4 ай бұрын
When you have rules only using them actively and smart can make you able to violate them.
@Evilope
@Evilope 4 ай бұрын
Well named variables, sensible structure and control flow are all that's necessary most of the time...
@skaruts
@skaruts 4 ай бұрын
@@Evilope well, realistically, most of the time that's just a pipe dream. I've read and written enough code to know that. And also what's obvious to you isn't necessarily obvious to others. But either way, no matter how well you name and structure things, the brain always has to decipher the code to some extent, while a comment can simply be read. Comments can and do save us a lot of time and effort.
@theodorealenas3171
@theodorealenas3171 4 ай бұрын
​@@skaruts yep, I've written tiny functions more than once and to modify them you basically need to unwrap them a little, change them and turn them into tiny functions again. I still love them though. Pity that nobody practices how to read and write them.
@skaruts
@skaruts 4 ай бұрын
@@theodorealenas3171 yea, I don't like tiny functions either. You said it yourself, they make it harder and more time-consuming to make changes. But also, the more tiny functions you have, the more one has to jump around to make sense of the code, and the harder it is to follow it. You also have to waste more time restructuring it as you write it, and you make it harder to refactor it in the future.
@progfix
@progfix 4 ай бұрын
You mentioned at the end you look into other open source projects from time to time. Which ones did you look into and found interesting?
@oblivion_2852
@oblivion_2852 4 ай бұрын
A good reason for the app to use the vm is to test whether ALL of the functions of the VM work. Because lua isn't just an app it's value is also in the vm you can embed in literally any other app - like how the vm is embedded in this c app that interprets lua
@IamPyu-v
@IamPyu-v 4 ай бұрын
Gotta implement this fix to the embedded Lua interpreter in my app.
@ErikBongers
@ErikBongers 4 ай бұрын
Next, let's add nullptr to Rust.
@IamPyu-v
@IamPyu-v 4 ай бұрын
perfecto
@burkino7046
@burkino7046 4 ай бұрын
std::ptr::null
@IamPyu-v
@IamPyu-v 4 ай бұрын
@@burkino7046 :0
@igz5553
@igz5553 Ай бұрын
Underrated comment
@IamPyu-v
@IamPyu-v Ай бұрын
@@igz5553 How is the 5th most liked comment underrated
@realdotty5356
@realdotty5356 4 ай бұрын
Lua my beloved
@dieSpinnt
@dieSpinnt 4 ай бұрын
Chat Question: "Is there a [programming] language he [=Tsoding] cannot code [in]?" (around 30:00) This is not really a question, or only a question and not what it looks like in the first place. It shows the respect of the questioner, because he is impressed of your computer programming skills. The person asking in fact implies, that there is no language (to his knowledge), that he thinks of that you couldn't possibly learn and use. This is a highly meta-level question and it lives in the context and also in a social context. That is btw. very impressive and in contrast to programming languages something that computers CAN NOT understand and possibly will never understand (Including large language models. There is no such thing as "understanding something". Thanks for the great video, Tsoding and also to Lua, that actually fixed you! Hehehe:)
@Turalcar
@Turalcar 3 ай бұрын
You mean rhetorical question which this most likely was. Tsoding's issue with that question was the assumption that this is not normal. In every place I worked in you're expected to be able to make small changes in almost any language.
@elgalas
@elgalas 4 ай бұрын
Gonna take note of, Asserting dominance, when joining a new project.
@elirannissani914
@elirannissani914 4 ай бұрын
Where can i find your emacs configuration?
@awesomeguy11000
@awesomeguy11000 4 ай бұрын
I wonder if it would have been possible to backup the lexerstate and effectively run the lexer over the double body twice to get the goto statements into the internal backpatching system.
@nashiora
@nashiora 4 ай бұрын
With the complication of non-local jumps and `goto`, my first thought was to instead just transform `double` into `for i=1,2 do`, i.e. make double less a macro and more a loop so it plays nicely with the relative jumps. I probably would've done this from the start, but it's neat to see you took the code duplication approach first and found out interesting things about the byte code. (edit: I clicked post about 5 seconds before you mentioned the easy solution was to implement it as a loop, forgive me for my hubris haha)
@enderman4
@enderman4 4 ай бұрын
Finally, arrays in Lua (tables reference)
@JuniperHatesTwitterlikeHandles
@JuniperHatesTwitterlikeHandles 4 ай бұрын
Russian луна́ is not from latin, actually, it's from a common ancestor with latin, they just developed in very similar ways.
@dtomvan
@dtomvan 4 ай бұрын
2:05:34: This is not true, the ipairs function will index raw, starting from zero. Which "user-facing-value" for a starting index is used does not matter.
@boody8844
@boody8844 4 ай бұрын
I was waiting for this for so long
@xarchist
@xarchist 4 ай бұрын
Is the code for emacs lua-mode longer than the actual lua interpreter?
4 ай бұрын
"luac" must be the compiler: anything ending with "c" is a compiler, in classic UNIX style. Also --help says the output is "luac.out", similar to the default output file for the C compiler (gcc still does it that way) is "a.out".
@glowiak3430
@glowiak3430 4 ай бұрын
Make it a PR. They would commit a sin not accepting it.
@BlueIsLeet
@BlueIsLeet 4 ай бұрын
Ik ur joking but obviously they cant change it at this point
@skaruts
@skaruts 4 ай бұрын
Yea, unfortunately this is probably set in stone for the foreseeable future. They couldn't change it overnight. They would have to warn the community in advance that, say, version 6 would be 0-indexed. And then they'd have to set a team aside to keep working on versions 5.x for years, like python did with 2.7, because there's a whole ecosystem out there that accounts for 1-indexing.
@BlueIsLeet
@BlueIsLeet 4 ай бұрын
@@skaruts I don't think there's any realistic path to changing the indexing at this point. That's a reason why I don't really use Lua, not enough batteries included like Golang or Java/Kotlin and weird design decisions
@skaruts
@skaruts 4 ай бұрын
@@BlueIsLeet Lua doesn't have weird design decisions apart from 1-indexing. Unlike python... But yea, I don't see it changing any time soon either. That said, while 1-indexing is a perpetual rock-in-the-shoe, all the merits of Lua really make it worth resigning to live with 1-indexing. Batteries it could never include, because Lua was made to be an auxiliary language, where the host application provides the batteries. If it provided batteries, it would become bloated, and it would prevent the host applications from providing them in their own optimal way.
@diskpoppy
@diskpoppy 4 ай бұрын
For everyone who can't see it changing - that's the exact sunk cost fallacy thinking that drowns us in today's inane legacy mess
@kirsanov2008
@kirsanov2008 4 ай бұрын
I FKN LOVE THE POWER OF SIMPLICITY!!!
@stevenaguilera9202
@stevenaguilera9202 4 ай бұрын
Do you know of any resources on how to write and build a website in Lua ?🙏
@daltonyon
@daltonyon 26 күн бұрын
TJ will be happy to see that the 1-based was fixed hahaha
@fabiokleis
@fabiokleis 4 ай бұрын
Welcome to a Brazilian programming language.
@alexloktionoff6833
@alexloktionoff6833 3 ай бұрын
Do you have plans for LuaJIT?
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
I'm not going to say it's better, because it's really just a different way of doing things, but Vim makes it pretty easy to add keywords for highlighting. I defined null as an alias for NULL that I use in my header for every project, and I just added it to the list of keywords and it was highlighting from then on. The weird error you had when trying to compile later was that you added 'a' to the start of lua_load() at around the 41:00 mark. As for adding 0-based indexing, I'd name it Lua++ and use .lpp for the file extensions to differentiate it. And as far as using a double block, you could either convert it into a for loop that runs twice, or convert it to a while loop and use a local inner variable to determine the exit condition of the loop.
@KleptomaniacJames
@KleptomaniacJames 4 ай бұрын
I have a similar thing for vs, I use rust type names, have a special macro "loop" defined as "for(;;)"
@delibellus
@delibellus 4 ай бұрын
I switched from Emacs to Vim because I didn't like configuring Emacs (Emacs distros don't solve this all the way for me, especially when I wanted to disable default stuff). Configuring syntax highlighting is one of my favourite things in Vim because it's so simple and yet so powerful. Probably one of the things that will make me stay for good.
@oblivion_2852
@oblivion_2852 4 ай бұрын
I'd call it Lua-- because it's lua decremented from 1 to 0 xD
@siriusleto3758
@siriusleto3758 4 ай бұрын
Id name Lu0
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
@@siriusleto3758 Out of all the options, this might be the best one.
@Muttisuri
@Muttisuri 4 ай бұрын
Yes Portuguese is Latin based, and Lua is our word for Moon yes. It's to note that Lua (the language) was made in Brazil where Portuguese (of the Brazilian variation (duh)) is spoken. Reading the wiki tells me that there were some trade barriers on software importation which lead to its creation, also seems that Lua was preceded by a language called SOL (Simple Object Language) but in Portuguese Sol mean Sun, so Sun and Moon.
@seropigeorge
@seropigeorge 29 күн бұрын
U are literally the best programmer Livestreamer on yt in my opinion
@brivism
@brivism 4 ай бұрын
"tylko jedno w głowie mam"... lua 5.1gram
@aleksszukovskis2074
@aleksszukovskis2074 4 ай бұрын
get out of here 💀
@artemromanov7411
@artemromanov7411 4 ай бұрын
@@aleksszukovskis2074 hohol
@gregandark8571
@gregandark8571 4 ай бұрын
Ooooooo polska kwa :(
@JamesSjaalman
@JamesSjaalman 4 ай бұрын
The priority limit was first invented/discovered by Bob Floyd.
@shamsiddinavezov5045
@shamsiddinavezov5045 4 ай бұрын
so by doing copy pasting, we can just add proper Table thing, like there is default Table that starts from 1 and properTable that starts with 0) no codebase in the world will be broken that way I guess
@DoYouScribble2
@DoYouScribble2 3 ай бұрын
Impressed. I agree, knowing & being able to follow logic is so much more important than the actual language itself. Instead of finding *int begin, end* with luaK_getlabel then looping through luaK_code, _I wonder if you can simply do_ *block(ls); block(ls);*
@patfre
@patfre 4 ай бұрын
I feel like this is just a dumb way of doing it. Lua basically treats an array as a key value pair so you could literally just say the key is 0, 1, 2… etc instead
@minamur
@minamur 4 ай бұрын
it's been a while since i used lua, but iirc you *can* do that, but any standard function that expects an array won't recognize the zeroth index, e.g. # will return 1 less than the length.
@CoolestPossibleName
@CoolestPossibleName 4 ай бұрын
There should be a specification statement like in fortran to opt out of the 1 indexing of the array
@minamur
@minamur 4 ай бұрын
that's one of the all time greatest bad ideas.
@CoolestPossibleName
@CoolestPossibleName 4 ай бұрын
@@minamur I'd like to know why. I was talking about the "implicit none" thing
@jeffirwin7862
@jeffirwin7862 4 ай бұрын
@@CoolestPossibleName fortran also has arrays that can start at any index, although the default is 1
@CoolestPossibleName
@CoolestPossibleName 4 ай бұрын
@@jeffirwin7862 I'm not talking about fortran's array system. there's a specification statement called "implicit none" to get rid of implicit types. I think it will be great to have such specification statement to make the array start from 0 in lua. I'd love to know why it's a bad idea
@samuelwaller4924
@samuelwaller4924 4 ай бұрын
​@@CoolestPossibleNameits just not worth it it. Worst case, every program/library would have to check for what the index is set to, and act accordingly. Best case, it is block scoped and now you get to have the extra burden of having to add "index 0" or whatever to every single file or function, and the mental overhead of remembering that. And then you are still going to end up writing "startindex" everywhere because that's what happens in every language that does that. You literally just add 1 ffs is it that hard
@whatevermait1
@whatevermait1 4 ай бұрын
...sometimes you gotta do "die Scheiße"
@beegdigit9811
@beegdigit9811 4 ай бұрын
Why fix something when it can fix itself: days = {[0]="Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
@CoolestPossibleName
@CoolestPossibleName 4 ай бұрын
That's it?
@logannday
@logannday 4 ай бұрын
I’d love to see you write an lsp for porth
@jordixboy
@jordixboy 4 ай бұрын
Did Lua move to a register based machine ?
@qxqxqxqxq
@qxqxqxqxq 4 ай бұрын
I literally though about zero indexed lua yesterday
@norude
@norude 4 ай бұрын
what if you jump *into* the double block? or even jump into a condition or a function or a loop. So basically goto is weird
@norude
@norude 4 ай бұрын
what if you goto to a place inside the loop from inside the loop
@douglaslima5199
@douglaslima5199 4 ай бұрын
PUC - RIO, brasil mentioned let's go!!!
@adammontgomery7980
@adammontgomery7980 4 ай бұрын
I'm amazed at the comments in this source code.
@PavelAShvedov
@PavelAShvedov 4 ай бұрын
Waited for double block inside another double block
@GRATHRRAM
@GRATHRRAM 4 ай бұрын
no way bro just chacked lua
@Mentox2
@Mentox2 4 ай бұрын
Impressive, very nice. Now lets see Paul Allen's fix for Javascript.
@Solemn_Lemon
@Solemn_Lemon 4 ай бұрын
You fixed Lua? Why? It's part of the experience!
@almpazel1486
@almpazel1486 4 ай бұрын
how to join ur discord server?
@dickpiano1802
@dickpiano1802 4 ай бұрын
Man... Цoding... what a guy!!!
@cobbcoding
@cobbcoding 4 ай бұрын
when will neovim switch to hacked lua for config
@1Iljo1
@1Iljo1 4 ай бұрын
submit the pull request
@AshliBlattgold
@AshliBlattgold 2 күн бұрын
rawr unprotected
@diegorocha2186
@diegorocha2186 4 ай бұрын
You look like you just won a brand new skateboard or something like this lol kkkkk never saw someone so happy reading code (at least until minute 49:00 lol I'm still watching)
@TankorSmash
@TankorSmash 4 ай бұрын
1:05:00 man gets frustrated its hard to add new syntax highlighting to a language specifically designed to never add new syntax
@TsodingDaily
@TsodingDaily 4 ай бұрын
It's highlighting for a single keyword, come ooooon! 😭
@TankorSmash
@TankorSmash 4 ай бұрын
Just looked, 13 years ago when the lua-mode was created 08cff6e3c2aa860bc26a43dc2cde1ca66558597b it was just a regex. Wonder if the software got smarter during its lifetime.
@Radgerayden-ist
@Radgerayden-ist 4 ай бұрын
Hi tsoding now that you've got some Lua experience you should check out the löve framework, it's very similar to raylib in a lot of ways but focused on lua
@skaruts
@skaruts 4 ай бұрын
And really competent in terms of performance. Although in part it's also LuaJIT being really competent at that too. There's also a 3D lib for Love2d in the works, called 3DreamEngine, and it performs really great too.
@SlinkyD
@SlinkyD 4 ай бұрын
I watch Eskil's data visualization prototype vid every few months. Imma trash programer but his & this.channel gives me motivation to rise to mediocre dev.
@siriusleto3758
@siriusleto3758 4 ай бұрын
And Bitty Engine
@bhavyakukkar
@bhavyakukkar 4 ай бұрын
55:17 i know some devs who have a very different meaning for what "high-level" is lol
@adlen01
@adlen01 4 ай бұрын
I always wonder 🤔 if you are a typical introver programmer ?
@b-rosa
@b-rosa 8 күн бұрын
"lua" is literally the Portuguese word for moon
@hubstrangers3450
@hubstrangers3450 4 ай бұрын
Thank you....
@rudolf-adamkovic
@rudolf-adamkovic 4 ай бұрын
Next up: Fennel. :)
@shaw-krowdashsabe2302
@shaw-krowdashsabe2302 3 ай бұрын
can you do a tutorial of how to make a progeamming language in c++ im stuck
@TsodingDaily
@TsodingDaily 3 ай бұрын
Bruh, you already have C++. Why reinvent another language?
@HumanGamer
@HumanGamer 4 ай бұрын
Can you work on your text editor again soon :) I really enjoyed that project.
@bobtheoutbuilder8552
@bobtheoutbuilder8552 4 ай бұрын
Almost 100k wtf
@RandomGeometryDashStuff
@RandomGeometryDashStuff 3 ай бұрын
00:00 new bookmark
@ivanjermakov
@ivanjermakov 4 ай бұрын
Lua's design is focused on embeddability, so all main does is that it prepares interpreter/bytecode VM and starts file execution.
@test-rj2vl
@test-rj2vl 3 ай бұрын
Lua devs should add compile time parameter to tell what the first element of array should be. So that I could make game whose scripting engine starts arrays with -2 or with 5.
@F_A_F123
@F_A_F123 11 күн бұрын
46:30 you're actually wrong here. Luná in Russian is inherited from Proto-Indo-European *lówksneh₂, and Latin lūna is inherited from the same Proto-Indo-European word. Those things are cognates
@samuelwaller4924
@samuelwaller4924 4 ай бұрын
I was considering doing something similar to this for my capstone and this guy just sits down and does it in 2 hours lol. Talking the whole time as well. I spent an hour just getting to understand the parser an gave up lol
@cacheman
@cacheman 4 ай бұрын
The Roblox people went off and wrote luau-lang which is an "improved lua". Remains to be seen if it'll gain any traction.
@blackhaze3856
@blackhaze3856 4 ай бұрын
Tsluading
@labsendeyshent
@labsendeyshent 4 ай бұрын
This lua-mode for emacs 💀
@mythacker4365
@mythacker4365 4 ай бұрын
Nice
@modley_the_m_guy
@modley_the_m_guy 2 ай бұрын
guys i think he fixed lua
@DobryWujaszekKun
@DobryWujaszekKun 4 ай бұрын
> Doesn't fucking matter so that's important xDDDDD
@kungfooman
@kungfooman 3 ай бұрын
Whenever I used Lua, I used Luajit - what about that?
@adelarsq
@adelarsq 4 ай бұрын
Lua++ lmao
@azergante8268
@azergante8268 4 ай бұрын
Can you hack into Rust and fix what’s wrong with it?
@hamzakhiar3636
@hamzakhiar3636 4 ай бұрын
Now try to fix react
@neededathrowaway1818
@neededathrowaway1818 4 ай бұрын
What's the tool that lets Tscoding zoom in on the screen at any time? I've always wondered but can't find any info regarding it
@lukasaey
@lukasaey 4 ай бұрын
it's on his github, zoomer i think it's called
@Radgerayden-ist
@Radgerayden-ist 4 ай бұрын
It's a tool he wrote himself called "boomer" iirc
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
If you used KDE you could have it built-in already. I'm sure GNOME could do it too, if that's your flavor, but I don't use GNOME.
@SlinkyD
@SlinkyD 4 ай бұрын
Alt+Mouse_Scroll got ya covered in XFCE.
@orizach01
@orizach01 4 ай бұрын
can you fix python and make True -> true, and False -> false
@DimaTiunov
@DimaTiunov 4 ай бұрын
Pogroming My life
@hansdietrich1496
@hansdietrich1496 Ай бұрын
I had to translate a lot of matlab code (that is 1-indexed just like lua) into python/numpy code. Since then I have a very solid disgust against any 1-indexed language.
@blastygamez
@blastygamez 4 ай бұрын
Finally
@SamArmstrong-DrSammyD
@SamArmstrong-DrSammyD 4 ай бұрын
So… you made Lua-
@siriusleto3758
@siriusleto3758 4 ай бұрын
Lu0
@bart2019
@bart2019 3 ай бұрын
And now, think of something useful to extend the language with...
@yaylucasfernandes
@yaylucasfernandes Ай бұрын
BRAZIL MENTIONED? 🇧🇷🇧🇷🇧🇷🇧🇷
@regfinley7111
@regfinley7111 4 ай бұрын
@ 28:00 that was a gem in the rough
@adr420
@adr420 4 ай бұрын
I write my neovim config in lua
@victorandreverdipereira7440
@victorandreverdipereira7440 4 ай бұрын
Chama no Brasil 👌
@petromudrievskyj
@petromudrievskyj 4 ай бұрын
Jebated. You've actually only broken things
@lhpl
@lhpl 4 ай бұрын
So the right fix is to allow any upper and lower index bounds. Please tell me that this is the fix, because if not, there's no reason to watch.
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
It actually already does that. The problem comes in when you manually loop.
@siriusleto3758
@siriusleto3758 4 ай бұрын
One of the reasons I love Lua is that the index starts at 1 😂
@Paxsali
@Paxsali 4 ай бұрын
That's the thing... I don't think you fixed Lua, Tsoding. Lua fixed you.
@joseoncrack
@joseoncrack 4 ай бұрын
Yeah, but that makes a 2-hour long video. What can you say.
@HuntingKingYT
@HuntingKingYT 4 ай бұрын
neovim 😛
@nyvyme
@nyvyme 4 ай бұрын
emacs, bro
@r2com641
@r2com641 4 ай бұрын
@@nyvymeclion
@IamPyu-v
@IamPyu-v 4 ай бұрын
@@r2com641 💀
@kthelemon
@kthelemon 2 ай бұрын
ok now fix python
@1cubealot
@1cubealot 4 ай бұрын
3rd!
@glowiak3430
@glowiak3430 4 ай бұрын
31:04 Look at this code. "chunkname" is a CONST char, and yet, few lines below its value is altered. Great job, lua devs. Lots of laught.
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
It's a const char *, not a char * const. Modifying what it points to is neither bad nor a bad idea when it's passed a null pointer.
@glowiak3430
@glowiak3430 4 ай бұрын
@@anon_y_mousse Yes, but why make it const then?
@sproccoli
@sproccoli 4 ай бұрын
@@glowiak3430 c's type signatures are weird. what the type means is "this points to (a sequence of) constant characters". it does not mean that the value of the variable is itself, the pointer, is constant. I am sure this is about as clear as mud but i don't think i can explain it any better without diagrams and more words.
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
@@glowiak3430 Because the contents of the string aren't meant to be modified by the function. If you want the pointer and what it points to to both be const, then const char * const is what you want, but you generally don't really want that, especially when passing strings to functions.
@IgnacioLosiggio
@IgnacioLosiggio 4 ай бұрын
don't change the chars behind this pointer: `const char*` don't change this pointer: `char* const` don't change the chars behind this pointer nor the pointer: `const char* const`
I tried React and it Ruined My Life
1:19:10
Tsoding Daily
Рет қаралды 113 М.
Hare Programming Language
1:39:25
Tsoding Daily
Рет қаралды 46 М.
I Built a Shelter House For myself and Сat🐱📦🏠
00:35
TooTool
Рет қаралды 24 МЛН
I Need Your Help..
00:33
Stokes Twins
Рет қаралды 156 МЛН
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 12 МЛН
From $erverless To Elixir | Prime Reacts
22:34
ThePrimeTime
Рет қаралды 93 М.
Will Ada Replace C/C++?
44:57
Tsoding
Рет қаралды 80 М.
Web in Native Assembly (Linux x86_64)
2:03:41
Tsoding Daily
Рет қаралды 54 М.
Hash Table in C
2:11:31
Tsoding Daily
Рет қаралды 56 М.
I made JIT Compiler for Brainf*ck lol
3:07:56
Tsoding Daily
Рет қаралды 69 М.
Fixing Lua OOP
10:27
sleitnick
Рет қаралды 17 М.
NeovimConf 2022: Lua, a Primer
30:10
John McBride
Рет қаралды 14 М.
CONCURRENCY IS NOT WHAT YOU THINK
16:59
Core Dumped
Рет қаралды 83 М.
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 644 М.
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
Задача APPLE сделать iPHONE НЕРЕМОНТОПРИГОДНЫМ
0:57
Xiaomi Note 13 Pro по безумной цене в России
0:43
Простые Технологии
Рет қаралды 2,1 МЛН
iphone fold ? #spongebob #spongebobsquarepants
0:15
Si pamerR
Рет қаралды 832 М.
Топ-3 суперкрутых ПК из CompShop
1:00
CompShop Shorts
Рет қаралды 488 М.
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 10 МЛН