Hi Vini,
I'm not sure I understand your question fully, but:
1. You can probably remove CreateHTML entirely with your usecase, and
just do the appropriate ANSI code printing in the individual functions, e.g.
transitioning javascript builtin
StringPrototypeBold(
js-implicit context: NativeContext, receiver:
JSAny)(...arguments): String {
return "\033[1;1m" + ToThisString(receiver,
'String.prototype.bold') + "\033[0m";
}
2. Torque is lower level than JS code, so you can't directly use JS
functions in it (like String.prototype.replace) -- if you really want to
call something like replace, then you have to manually do the property load
with GetProperty and manually do the function call with Call.
3. typeswitch switches over types, so it can't switch over a string
value. You want a chain of if-else statements (as you have in your
prototype)
4. let myString = "an string" is already type inference, without type
inference this would be let myString : String = "an string". There's no
type inference beyond things like this.
- Leszek
On Thu, May 20, 2021 at 7:30 PM Vini Dalvino <[email protected]>
wrote:
> I am trying to modify the string-html,tq file so it use terminal font
> coloring however I am confused on the thing mention bellow:
>
> Is there a way I can make it so the file doesn't use "return CreateHTML(
> receiver, 'String.prototype.anchor', 'a', 'name', arguments[0]);". I
> am trying to modify it so it take a pair of start of color string like the
> colors module do (
> https://github.com/Marak/colors.js/blob/master/lib/styles.js) however I
> am not sure if doing this is the right thing.
>
> I tough about doing this: https://pastebin.com/zS1KzBJZ however it's not
> the cleanest way I think it could be done.
>
> Also I am wondering how I can use js function like
> String.prototype.replace in torque. I am also wondering wether or not I can
> use `typeswitch` with string with something like this:
> let myFruit: String = "banana";
> typeswitch(myFruit) {
> case "banana":
> print("this is banana");
> break;
> case "blueberry":
> print("this is a blueberry");
> break;
> }
> Another thing I was wondering is if torque had type inference so I don't
> have to do:
> let myString = "an string";
> each time I want to create a string.
> Another thing that I was wondering is whether or not v8 has type inference.
>
>
> Thanks for taking time to read my email and I am sorry for my bad english,
> english isnt my first language.
>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/7fefbd2c-3958-4368-bda4-6653485690a9n%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/7fefbd2c-3958-4368-bda4-6653485690a9n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/v8-dev/CAGRskv-AbMcCuSzvgcqrXKppFwfddDgQst%3De0f5UEHHu8w%3Darg%40mail.gmail.com.